Exemplo n.º 1
0
        fields.Nested(dataset_ref_fields,
                      description='The processed dataset',
                      allow_null=True),
        'status':
        fields.String(description='The item status',
                      required=True,
                      enum=HARVEST_ITEM_STATUS.keys()),
        'created':
        fields.ISODateTime(description='The item creation date',
                           required=True),
        'started':
        fields.ISODateTime(description='The item start date'),
        'ended':
        fields.ISODateTime(description='The item end date'),
        'errors':
        fields.List(fields.Nested(error_fields),
                    description='The item errors'),
        'args':
        fields.List(fields.String,
                    description='The item positional arguments',
                    default=[]),
        'kwargs':
        fields.Raw(description='The item keyword arguments', default={}),
    })

job_fields = api.model(
    'HarvestJob', {
        'id':
        fields.String(description='The job execution ID', required=True),
        'created':
        fields.ISODateTime(description='The job creation date', required=True),
        'started':
Exemplo n.º 2
0
 fields.String(description='The post permalink string', readonly=True),
 'headline':
 fields.String(description='The post headline', required=True),
 'content':
 fields.Markdown(description='The post content in Markdown',
                 required=True),
 'image':
 fields.ImageField(description='The post image'),
 'credit_to':
 fields.String(
     description='An optionnal credit line (associated to the image)'),
 'credit_url':
 fields.String(
     description='An optionnal link associated to the credits'),
 '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',
Exemplo n.º 3
0
            default=DEFAULT_CHECKSUM_TYPE,
            enum=CHECKSUM_TYPES),
        'value':
        fields.String(description="The resulting checksum/hash", required=True)
    })

license_fields = api.model(
    'License', {
        'id': fields.String(description='The license identifier',
                            required=True),
        'title': fields.String(description='The resource title',
                               required=True),
        'maintainer':
        fields.String(description='The license official maintainer'),
        'url': fields.String(description='The license official URL'),
        'flags': fields.List(fields.String, description='Some arbitry flags'),
    })

frequency_fields = api.model(
    'Frequency', {
        'id': fields.String(description='The frequency identifier'),
        'label': fields.String(description='The frequency display name')
    })

badge_fields = api.model(
    'DatasetBadge', {
        'kind':
        fields.String(description='Kind of badge (pivotal-data, etc)',
                      required=True,
                      enum=DATASET_BADGE_KINDS.keys()),
    })
Exemplo n.º 4
0
    'month_of_year': fields.String(description='Cron expression for month of year', required=True, default='*'),
})

interval_fields = api.model('Interval', {
    'every': fields.Integer(description='The interval without unit', required=True),
    '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'),
})
Exemplo n.º 5
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=list(REUSE_TYPES)),
 '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'),
Exemplo n.º 6
0
})

item_fields = api.model('HarvestItem', {
    'remote_id': fields.String(description='The item remote ID to process',
                               required=True),
    'dataset': fields.Nested(dataset_ref_fields,
                             description='The processed dataset',
                             allow_null=True),
    'status': fields.String(description='The item status',
                            required=True,
                            enum=list(HARVEST_ITEM_STATUS)),
    'created': fields.ISODateTime(description='The item creation date',
                                  required=True),
    'started': fields.ISODateTime(description='The item start date'),
    'ended': fields.ISODateTime(description='The item end date'),
    'errors': fields.List(fields.Nested(error_fields),
                          description='The item errors'),
    'args': fields.List(fields.String,
                        description='The item positional arguments',
                        default=[]),
    'kwargs': fields.Raw(description='The item keyword arguments',
                         default={}),
})

job_fields = api.model('HarvestJob', {
    'id': fields.String(description='The job execution ID', required=True),
    'created': fields.ISODateTime(description='The job creation date',
                                  required=True),
    'started': fields.ISODateTime(description='The job start date'),
    'ended': fields.ISODateTime(description='The job end date'),
    'status': fields.String(description='The job status',
                            required=True, enum=list(HARVEST_JOB_STATUS)),
Exemplo n.º 7
0
        description='The organization creation date', readonly=True),
    'last_modified': fields.ISODateTime(
        description='The organization last modification date', readonly=True),
    'deleted': fields.ISODateTime(
        description='The organization deletion date if deleted',
        readonly=True),
    'metrics': fields.Raw(
        description='The organization metrics', readonly=True),
    'uri': fields.UrlFor(
        'api.organization', lambda o: {'org': o},
        description='The organization API URI', readonly=True),
    'page': fields.UrlFor(
        'organizations.show', lambda o: {'org': o},
        description='The organization page URL', readonly=True),
    'logo': fields.ImageField(description='The organization logo URLs'),
    'members': fields.List(
        fields.Nested(member_fields, description='The organization members')),
    'badges': fields.List(fields.Nested(badge_fields),
                          description='The organization badges',
                          readonly=True),
})

org_page_fields = api.model('OrganizationPage', fields.pager(org_fields))

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),
Exemplo n.º 8
0
from __future__ import unicode_literals

from udata.api import api, fields


GEOM_TYPES = (
    'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString',
    'MultiPolygon'
)


geojson = api.model('GeoJSON', {
    'type': fields.String(
        description='The GeoJSON Type', required=True, enum=GEOM_TYPES),
    'coordinates': fields.List(
        fields.Raw(), description='The geometry as coordinates lists',
        required=True),
})

feature_fields = api.model('GeoJSONFeature', {
    'id': fields.String,
    'type': fields.String(required=True, enum=['Feature']),
    'geometry': fields.Nested(geojson, required=True),
    'properties': fields.Raw,
})

feature_collection_fields = api.model('GeoJSONFeatureCollection', {
    'type': fields.String(required=True, enum=['FeatureCollection']),
    'features': fields.List(fields.Nested(feature_fields), required=True)
})
Exemplo n.º 9
0
 '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),
     'type': 'GET',
     'total': len(o.community_resources)
     }, description='Link to the dataset community resources'),
Exemplo n.º 10
0
from udata.core.organization.api_fields import org_ref_fields

user_fields = api.model('User', {
    'id': fields.String(
        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(description='The user avatar URL'),
    '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'),
    'organizations': fields.List(
        fields.Nested(org_ref_fields),
        description='The organization the user belongs to'),
    'metrics': fields.Raw(description='Th last user metrics'),
    '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),
})
Exemplo n.º 11
0
        'value':
        fields.String(description="The resulting checksum/hash", required=True)
    })

license_fields = api.model(
    'License', {
        'id':
        fields.String(description='The license identifier', required=True),
        'title':
        fields.String(description='The resource title', required=True),
        'maintainer':
        fields.String(description='The license official maintainer'),
        'url':
        fields.String(description='The license official URL'),
        'flags':
        fields.List(fields.String, description='Some arbitry flags'),
        'alternate_urls':
        fields.List(
            fields.String,
            description='Same alternative known URLs (improve rematch)'),
        'alternate_titles':
        fields.List(
            fields.String,
            description='Same alternative known titles (improve rematch)'),
    })

frequency_fields = api.model(
    'Frequency', {
        'id': fields.String(description='The frequency identifier'),
        'label': fields.String(description='The frequency display name')
    })
Exemplo n.º 12
0
        fields.Raw(description='The organization metrics', readonly=True),
        'uri':
        fields.UrlFor('api.organization',
                      lambda o: {'org': o},
                      description='The organization API URI',
                      readonly=True),
        'page':
        fields.UrlFor('organizations.show',
                      lambda o: {'org': o},
                      description='The organization page URL',
                      readonly=True),
        'logo':
        fields.ImageField(description='The organization logo URLs'),
        'members':
        fields.List(
            fields.Nested(member_fields,
                          description='The organization members')),
    })

org_page_fields = api.model('OrganizationPage', fields.pager(org_fields))

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':
Exemplo n.º 13
0
ns = api.namespace('topics', 'Topics related operations')

topic_fields = api.model(
    'Topic', {
        'id':
        fields.String(description='The topic identifier'),
        'name':
        fields.String(description='The topic name', required=True),
        'slug':
        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':
Exemplo n.º 14
0
GEOM_TYPES = ('Point', 'LineString', 'Polygon', 'MultiPoint',
              'MultiLineString', 'MultiPolygon')

ns = api.namespace('spatial', 'Spatial references')


@api.model(
    fields={
        'type':
        fields.String(description='The GeoJSON Type',
                      required=True,
                      enum=GEOM_TYPES),
        'coordinates':
        fields.List(fields.Raw(),
                    description='The geometry as coordinates lists',
                    required=True),
    })
class GeoJSON(fields.Raw):
    pass


feature_fields = api.model(
    'GeoJSONFeature', {
        'id': fields.String,
        'type': fields.String(required=True, enum=['Feature']),
        'geometry': GeoJSON(required=True),
        'properties': fields.Raw,
    })

feature_collection_fields = api.model(
Exemplo n.º 15
0
ns = api.namespace('harvest', 'Harvest related operations')

error_fields = api.model('HarvestError', {
    'created_at': fields.ISODateTime(description='The error creation date', required=True),
    'message': fields.String(description='The error short message', required=True),
    'details': fields.String(description='Optionnal details (ie. stacktrace)'),
})

item_fields = api.model('HarvestItem', {
    'remote_id': fields.String(description='The item remote ID to process', required=True),
    'status': fields.String(description='The item status', required=True, enum=HARVEST_ITEM_STATUS.keys()),
    'created': fields.ISODateTime(description='The item creation date', required=True),
    'started': fields.ISODateTime(description='The item start date'),
    'ended': fields.ISODateTime(description='The item end date'),
    'errors': api.as_list(fields.Nested(error_fields, description='The item errors')),
    'args': fields.List(fields.String, description='The item positional arguments', default=[]),
    'kwargs': fields.Raw(description='The item keyword arguments', default={}),
})

source_fields = api.model('HarvestSource', {
    'id': fields.String(description='The source unique identifier', required=True),
    'name': fields.String(description='The source display name', required=True),
    'description': fields.String(description='The source description'),
    'url': fields.String(description='The source base URL', required=True),
    'backend': fields.String(description='The source backend', required=True, enum=actions.list_backends()),
    'config': fields.Raw(description='The configuration as key-value pairs'),
    'args': fields.List(fields.Raw, description='The job execution arguments', default=[]),
    'kwargs': fields.Raw(description='The job execution keyword arguments', default={}),
    'created_at': fields.ISODateTime(description='The source creation date', required=True),
    'active': fields.Boolean(description='Is this source active', required=True, default=False),
})
Exemplo n.º 16
0
from udata.core.spatial.api import spatial_coverage_fields

from .models import UPDATE_FREQUENCIES, RESOURCE_TYPES, DEFAULT_FREQUENCY, CHECKSUM_TYPES, DEFAULT_CHECKSUM_TYPE

checksum_fields = api.model('Checksum', {
    'type': fields.String(description='The hashing algorithm used to compute the checksum',
            default=DEFAULT_CHECKSUM_TYPE, enum=CHECKSUM_TYPES),
    'value': fields.String(description="The resulting checksum/hash", required=True)
})

license_fields = api.model('License', {
    'id': fields.String(description='The license identifier', required=True),
    'title': fields.String(description='The resource title', required=True),
    'maintainer': fields.String(description='The license official maintainer'),
    'url': fields.String(description='The license official URL'),
    'flags': fields.List(fields.String, description='Some arbitry flags'),
})

resource_fields = api.model('Resource', {
    'id': fields.String(description='The resource unique ID', readonly=True),
    'title': fields.String(description='The resource title', required=True),
    'description': fields.Markdown(description='The resource markdown description'),
    'type': fields.String(description='Whether the resource is an uploaded file, a remote file or an API',
        required=True, enum=RESOURCE_TYPES.keys()),
    'format': fields.String(description='The resource format', required=True),
    'url': fields.String(description='The resource URL', required=True),
    'checksum': fields.Nested(checksum_fields, allow_null=True,
        description='A checksum to validate file validity'),
    'size': fields.Integer(description='The resource file size in bytes'),
    'mime': fields.String(description='The resource mime type'),
    'created_at': fields.ISODateTime(description='The resource creation date', readonly=True),