Beispiel #1
0
        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),
    })

dataset_fields = api.model(
    'Dataset', {
        'id':
        fields.String(description='The dataset identifier', readonly=True),
Beispiel #2
0
        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),
    'is_available': fields.Raw(
        description='The resource availability', 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),
})

dataset_ref_fields = api.inherit('DatasetReference', base_reference, {
    'title': fields.String(description='The dataset title', readonly=True),
    'uri': fields.UrlFor(
        'api.dataset', lambda d: {'dataset': d},
        description='The API URI for this dataset', readonly=True),
    'page': fields.UrlFor(
        'datasets.show', lambda d: {'dataset': d},
Beispiel #3
0
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(
    'GeoJSONFeatureCollection', {
        'type': fields.String(required=True, enum=['FeatureCollection']),
        'features': api.as_list(fields.Nested(feature_fields))
    })

level_fields = api.model(
    'TerritoryLevel', {
        'id':
        fields.String(description='The level identifier', required=True),
        'label':
        fields.String(description='The level name', required=True),
        'position':
        fields.Integer(
            description='The position in the level tree (top is zero)',
            min=0,
            required=True),
        'parent':
        fields.String(description='The parent level'),
Beispiel #4
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),
Beispiel #5
0
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),
})

dataset_fields = api.model('Dataset', {
    'id': fields.String(description='The dataset identifier', required=True),
    'title': fields.String(description='The dataset title', required=True),
    'slug': fields.String(description='The dataset permalink string', required=True),
    'description': fields.String(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'),
    'featured': fields.Boolean(description='Is the dataset featured'),
    'tags': fields.List(fields.String),
    'resources': api.as_list(fields.Nested(resource_fields, description='The dataset resources')),
    'community_resources': api.as_list(fields.Nested(resource_fields,
        description='The dataset community submitted resources')),
    'frequency': fields.String(description='The update frequency', required=True, enum=UPDATE_FREQUENCIES.keys()),
    'extras': fields.Raw(description='Extras attributes as key-value pairs'),
    'metrics': fields.Raw(description='The dataset metrics'),
    'organization': OrganizationReference(description='The producer organization'),
    'supplier': OrganizationReference(description='The supplyer organization (if different from the producer)'),
    'temporal_coverage': fields.Nested(temporal_coverage_fields, allow_null=True,
        description='The temporal coverage'),
    'spatial': fields.Nested(spatial_coverage_fields, allow_null=True, description='The spatial coverage'),
    'license': fields.String(attribute='license.id', description='The dataset license'),

    'uri': fields.UrlFor('api.dataset', lambda o: {'dataset': o},
        description='The dataset API URI', required=True),
    'page': fields.UrlFor('datasets.show', lambda o: {'dataset': o},
Beispiel #6
0
    '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('GeoJSONFeatureCollection', {
    'type': fields.String(required=True, enum=['FeatureCollection']),
    'features': api.as_list(fields.Nested(feature_fields))
})

level_fields = api.model('TerritoryLevel', {
    'id': fields.String(description='The level identifier', required=True),
    'label': fields.String(description='The level name', required=True),
    'position': fields.Integer(description='The position in the level tree (top is zero)', min=0, required=True),
    'parent': fields.String(description='The parent level'),
    'children': fields.List(fields.String, description='The known children levels'),
})

granularity_fields = api.model('SpatialGranularity', {
    'id': fields.String(description='The granularity identifier', required=True),
    'label': fields.String(description='The granularity name', required=True),
})