Exemple #1
0
 fields.String(description='The source display name', required=True),
 'description':
 fields.Markdown(description='The source description'),
 'url':
 fields.String(description='The source base URL', required=True),
 'backend':
 fields.String(description='The source backend',
               enum=backends_ids,
               required=True),
 'config':
 fields.Raw(description='The configuration as key-value pairs'),
 'created_at':
 fields.ISODateTime(description='The source creation date',
                    required=True),
 'active':
 fields.Boolean(
     description='Is this source active', required=True, default=False),
 'validation':
 fields.Nested(validation_fields,
               readonly=True,
               description='Has the source been validated'),
 'last_job':
 fields.Nested(job_fields,
               description='The last job for this source',
               allow_null=True,
               readonly=True),
 'owner':
 fields.Nested(user_ref_fields,
               allow_null=True,
               description='The owner information'),
 'organization':
 fields.Nested(org_ref_fields,
Exemple #2
0
        'comment':
        fields.String(description='The content of the initial comment',
                      required=True),
        'subject':
        fields.Nested(api.model_reference,
                      description='The discussion target object',
                      required=True),
    })

comment_discussion_fields = api.model(
    'DiscussionResponse', {
        'comment':
        fields.String(description='The comment to submit', required=True),
        'close':
        fields.Boolean(
            description=
            'Is this a closing response. Only subject owner can close')
    })

discussion_page_fields = api.model('DiscussionPage',
                                   fields.pager(discussion_fields))

parser = api.parser()
parser.add_argument('sort',
                    type=str,
                    default='-created',
                    location='args',
                    help='The sorting attribute')
parser.add_argument(
    'closed',
    type=boolean,
Exemple #3
0
 'tags':
 fields.List(fields.String,
             description='Some keywords to help in search'),
 'datasets':
 fields.List(fields.Nested(dataset_ref_fields),
             description='The post datasets'),
 'reuses':
 fields.List(fields.Nested(reuse_ref_fields),
             description='The post reuses'),
 'owner':
 fields.Nested(user_ref_fields,
               description='The owner user',
               readonly=True,
               allow_null=True),
 'private':
 fields.Boolean(description='Is the post visible'),
 'created_at':
 fields.ISODateTime(description='The post creation date',
                    readonly=True),
 'last_modified':
 fields.ISODateTime(description='The post last modification date',
                    readonly=True),
 'uri':
 fields.UrlFor('api.post',
               lambda o: {'post': o},
               description='The post API URI',
               readonly=True),
 'page':
 fields.UrlFor('posts.show',
               lambda o: {'post': o},
               description='The post page URL',
Exemple #4
0
                           description='The resource creation date'),
        'published':
        fields.ISODateTime(description='The resource publication date'),
        'last_modified':
        fields.ISODateTime(attribute='modified',
                           readonly=True,
                           description='The resource last modification date'),
        'metrics':
        fields.Raw(description='The resource metrics', readonly=True),
    })

upload_fields = api.extend(
    'UploadedResource', resource_fields, {
        'success':
        fields.Boolean(description='Whether the upload succeeded or not.',
                       readonly=True,
                       default=True),
    })

resources_order = api.as_list(fields.String(description='Resource ID'))

temporal_coverage_fields = api.model(
    'TemporalCoverage', {
        'start':
        fields.ISODateTime(description='The temporal coverage start date',
                           required=True),
        'end':
        fields.ISODateTime(description='The temporal coverage end date',
                           required=True),
    })
Exemple #5
0
    'period': fields.String(description='The period/interval type', required=True, enum=PERIODS),
})

job_fields = api.model('Job', {
    'id': fields.String(description='The job unique identifier', readonly=True),
    'name': fields.String(description='The job unique name', required=True),
    'description': fields.String(description='The job description'),
    'task': fields.String(description='The task name', required=True, enum=[job.name for job in schedulables()]),
    'crontab': fields.Nested(crontab_fields, allow_null=True),
    'interval': fields.Nested(interval_fields, allow_null=True),
    'args': fields.List(fields.Raw, description='The job execution arguments', default=[]),
    'kwargs': fields.Raw(description='The job execution keyword arguments', default={}),
    'schedule': fields.String(attribute='schedule_display', description='The schedule display', readonly=True),
    'last_run_at': fields.ISODateTime(description='The last job execution date', readonly=True),
    'last_run_id': fields.String(description='The last execution task id', readonly=True),
    'enabled': fields.Boolean(description='Is this job enabled', default=False),
})

task_fields = api.model('Task', {
    'id': fields.String(description='Tha task execution ID', readonly=True),
    'status': fields.String(description='Cron expression for hour', readonly=True, enum=list(states.ALL_STATES)),
    'result': fields.String(description='The task results if exists'),
    'exc': fields.String(description='The exception thrown during execution'),
    'traceback': fields.String(description='The execution traceback'),
})


@ns.route('/jobs/', endpoint='jobs')
class JobsAPI(API):
    @api.doc(id='list_jobs')
    @api.marshal_list_with(job_fields)
Exemple #6
0
 'url':
 fields.String(description='The reuse remote URL (website)', required=True),
 'description':
 fields.Markdown(description='The reuse description in Markdown',
                 required=True),
 'tags':
 fields.List(fields.String, description='Some keywords to help in search'),
 'badges':
 fields.List(fields.Nested(badge_fields),
             description='The reuse badges',
             readonly=True),
 'topic':
 fields.String(
     description='The reuse topic', required=True, enum=list(REUSE_TOPICS)),
 'featured':
 fields.Boolean(description='Is the reuse featured', readonly=True),
 'private':
 fields.Boolean(
     description='Is the reuse private to the owner or the organization'),
 'image':
 fields.ImageField(
     description='The reuse thumbnail thumbnail (cropped) URL'),
 'image_thumbnail':
 fields.ImageField(
     attribute='image',
     size=BIGGEST_IMAGE_SIZE,
     description='The reuse thumbnail thumbnail URL. This is the square '
     '({0}x{0}) and cropped version.'.format(BIGGEST_IMAGE_SIZE)),
 'created_at':
 fields.ISODateTime(description='The reuse creation date', readonly=True),
 'last_modified':
Exemple #7
0
org_suggestion_fields = api.model(
    'OrganizationSuggestion', {
        'id':
        fields.String(description='The organization identifier',
                      readonly=True),
        'name':
        fields.String(description='The organization name', readonly=True),
        'acronym':
        fields.String(description='The organization acronym', readonly=True),
        'slug':
        fields.String(description='The organization permalink string',
                      readonly=True),
        'image_url':
        fields.String(description='The organization logo URL', readonly=True),
        'score':
        fields.Float(description='The internal match score', readonly=True),
    })

logo_fields = api.model(
    'UploadedLogo',
    {
        'success':
        fields.Boolean(description='Whether the upload succeeded or not.',
                       readonly=True,
                       default=True),
        'logo':
        fields.ImageField(),
        # 'error': fields.String(description='An error message if success is false', readonly=True),
    })
Exemple #8
0
dataset_fields = apiv2.model('Dataset', {
    'id': fields.String(description='The dataset identifier', readonly=True),
    'title': fields.String(description='The dataset title', required=True),
    'acronym': fields.String(description='An optional dataset acronym'),
    'slug': fields.String(
        description='The dataset permalink string', required=True),
    'description': fields.Markdown(
        description='The dataset description in markdown', required=True),
    'created_at': fields.ISODateTime(
        description='The dataset creation date', required=True),
    'last_modified': fields.ISODateTime(
        description='The dataset last modification date', required=True),
    'deleted': fields.ISODateTime(description='The deletion date if deleted'),
    'archived': fields.ISODateTime(description='The archival date if archived'),
    'featured': fields.Boolean(description='Is the dataset featured'),
    'private': fields.Boolean(
        description='Is the dataset private to the owner or the organization'),
    'tags': fields.List(fields.String),
    'badges': fields.List(fields.Nested(badge_fields),
                          description='The dataset badges',
                          readonly=True),
    'resources': fields.Raw(attribute=lambda o: {
        'rel': 'subsection',
        'href': url_for('apiv2.resources', dataset=o.id, page=1, page_size=DEFAULT_PAGE_SIZE, _external=True),
        'type': 'GET',
        'total': len(o.resources)
        }, description='Link to the dataset resources'),
    'community_resources': fields.Raw(attribute=lambda o: {
        'rel': 'subsection',
        'href': url_for('api.community_resources', dataset=o.id, page=1, page_size=DEFAULT_PAGE_SIZE, _external=True),
Exemple #9
0
 'avatar':
 fields.ImageField(original=True, description='The user avatar URL'),
 'avatar_thumbnail':
 fields.ImageField(
     attribute='avatar',
     size=BIGGEST_AVATAR_SIZE,
     description='The user avatar thumbnail URL. This is the square '
     '({0}x{0}) and cropped version.'.format(BIGGEST_AVATAR_SIZE)),
 'website':
 fields.String(description='The user website'),
 'about':
 fields.Markdown(description='The user self description'),
 'roles':
 fields.List(fields.String, description='Site wide user roles'),
 'active':
 fields.Boolean(),
 'organizations':
 fields.List(fields.Nested(org_ref_fields),
             description='The organization the user belongs to'),
 'since':
 fields.ISODateTime(attribute='created_at',
                    description='The registeration date',
                    required=True),
 'page':
 fields.UrlFor('users.show',
               lambda u: {'user': u},
               description='The user profile page URL',
               readonly=True,
               fallback_endpoint='api.user'),
 'uri':
 fields.UrlFor('api.user',
Exemple #10
0
 fields.String(description='The topic permalink string', readonly=True),
 'description':
 fields.Markdown(description='The topic description in Markdown',
                 required=True),
 'tags':
 fields.List(fields.String,
             description='Some keywords to help in search',
             required=True),
 'datasets':
 fields.List(fields.Nested(dataset_fields),
             description='The topic datasets'),
 'reuses':
 fields.List(fields.Nested(reuse_fields),
             description='The topic reuses'),
 'featured':
 fields.Boolean(description='Is the topic featured'),
 'private':
 fields.Boolean(description='Is the topic private'),
 'created_at':
 fields.ISODateTime(description='The topic creation date',
                    readonly=True),
 'last_modified':
 fields.ISODateTime(description='The topic last modification date',
                    readonly=True),
 'deleted':
 fields.ISODateTime(description='The organization identifier',
                    readonly=True),
 'owner':
 fields.Nested(user_ref_fields,
               description='The owner user',
               readonly=True,
Exemple #11
0
 fields.String(description='The source display name', required=True),
 'description':
 fields.Markdown(description='The source description'),
 'url':
 fields.String(description='The source base URL', required=True),
 'backend':
 fields.String(description='The source backend',
               enum=backends_ids,
               required=True),
 'config':
 fields.Raw(description='The configuration as key-value pairs'),
 'created_at':
 fields.ISODateTime(description='The source creation date',
                    required=True),
 'active':
 fields.Boolean(
     description='Is this source active', required=True, default=False),
 'autoarchive':
 fields.Boolean(
     description=
     'If enabled, datasets not present on the remote source will be automatically archived',  # noqa
     required=True,
     default=True),
 'validation':
 fields.Nested(validation_fields,
               readonly=True,
               description='Has the source been validated'),
 'last_job':
 fields.Nested(job_fields,
               description='The last job for this source',
               allow_null=True,
               readonly=True),
Exemple #12
0
 'id': fields.String(description='The reuse identifier', readonly=True),
 'title': fields.String(description='The reuse title', required=True),
 'slug': fields.String(
     description='The reuse permalink string', readonly=True),
 'type': fields.String(
     description='The reuse type', required=True, enum=REUSE_TYPES.keys()),
 'url': fields.String(
     description='The reuse remote URL (website)', required=True),
 'description': fields.Markdown(
     description='The reuse description in Markdown', required=True),
 'tags': fields.List(
     fields.String, description='Some keywords to help in search'),
 'badges': fields.List(
     fields.Nested(badge_fields, description='The reuse badges'),
     readonly=True),
 'featured': fields.Boolean(
     description='Is the reuse featured', readonly=True),
 'private': fields.Boolean(
     description='Is the reuse private to the owner or the organization'),
 'image': fields.ImageField(description='The reuse thumbnail'),
 'created_at': fields.ISODateTime(
     description='The reuse creation date', readonly=True),
 'last_modified': fields.ISODateTime(
     description='The reuse last modification date', readonly=True),
 'deleted': fields.ISODateTime(
     description='The organization identifier', readonly=True),
 'datasets': fields.List(
     fields.Nested(dataset_ref_fields), description='The reused datasets'),
 'organization': fields.Nested(
     org_ref_fields, allow_null=True,
     description='The publishing organization', readonly=True),
 'owner': fields.Nested(
Exemple #13
0
        description='The user identifier', required=True),
    'slug': fields.String(
        description='The user permalink string', required=True),
    'first_name': fields.String(
        description='The user first name', required=True),
    'last_name': fields.String(
        description='The user last name', required=True),
    'avatar': fields.ImageField(original=True,
        description='The user avatar URL'),
    'avatar_thumbnail': fields.ImageField(attribute='avatar', size=BIGGEST_AVATAR_SIZE,
        description='The user avatar thumbnail URL. This is the square '
        '({0}x{0}) and cropped version.'.format(BIGGEST_AVATAR_SIZE)),
    'website': fields.String(description='The user website'),
    'about': fields.Markdown(description='The user self description'),
    'roles': fields.List(fields.String, description='Site wide user roles'),
    'active': fields.Boolean(),
    'organizations': fields.List(
        fields.Nested(org_ref_fields),
        description='The organization the user belongs to'),
    'since': fields.ISODateTime(
        attribute='created_at',
        description='The registeration date', required=True),
    'page': fields.UrlFor(
        'users.show', lambda u: {'user': u},
        description='The user profile page URL', readonly=True),
    'uri': fields.UrlFor(
        'api.user', lambda o: {'user': o},
        description='The user API URI', required=True),
    'metrics': fields.Raw(
        description='The user metrics', readonly=True),
})