class PhotometryJobSchema(JobSchema): type = 'photometry' result: PhotometryJobResultSchema = Nested( PhotometryJobResultSchema, default={}) file_ids: TList[int] = List(Integer(), default=[]) sources: TList[SourceExtractionDataSchema] = List( Nested(SourceExtractionDataSchema), default=[]) settings: PhotSettingsSchema = Nested(PhotSettingsSchema, default={})
class FieldCalResultSchema(AfterglowSchema): """ Result of field calibration for a data file """ file_id: int = Integer() phot_results: TList[PhotometryDataSchema] = List( Nested(PhotometryDataSchema), default=[]) zero_point_corr: float = Float() zero_point_error: float = Float()
class WorkloadSchema(Schema): """Schema of a Workload.""" workload_name = String( description="Name of the workload.", required=True, ) frequency = Integer(description="Number of queries generated per second.", required=True)
class ActionTypeSchema(Schema): id = Integer() name = Str() code = Str() description = Str() @post_load def make_type(self, data, **kwargs): return DeClass(_name="ActionType", _resp=("id", "name"), **data)
class CroppingJobSchema(JobSchema): type = 'cropping' result: CroppingJobResultSchema = Nested(CroppingJobResultSchema, default={}) file_ids: TList[int] = List(Integer(), default=[]) settings: CroppingSettingsSchema = Nested(CroppingSettingsSchema, default={}) inplace: bool = Boolean(default=False)
class ReservationSchema(CreateReservationSchema): id = Integer() made_at = DateTime() ended_at = DateTime() status = EnumField(ReservationOutcome, default=ReservationOutcome.OPEN) user = Nested(UserSchema()) user_id = Integer() user_url = Url(relative=True) pickup = Nested(PickupPointSchema()) pickup_id = Integer() pickup_url = Url(relative=True) rental = Nested(RentalSchema()) rental_io = Integer() rental_url = Url(relative=True)
class ProductSchema(ma.SQLAlchemyAutoSchema): name = String(required=True) count = Integer(required=True) category_id = UUID(required=True) class Meta: model = Product load_instance =True
class MetadataParameters(Schema): first = Integer(default=1, description='Limit the range of the query') last = Integer(default=50, description='Limit the range of the query') sort_by = String( description= 'Sorts results in forward or backward, based on column name (e.g. "id" vs "-id")' ) sort_desc = Boolean(default=True) txt_filter = String(description='FTS search on the chosen word* terms') hide_xxx = Boolean(default=False, description='Toggles xxx filter') category = String() exclude_deleted = Boolean(default=False) remote_query = Boolean(default=False) metadata_type = List( String( description= 'Limits query to certain metadata types (e.g. "torrent" or "channel")' ))
class MessageSchema(ma.ModelSchema): id = Integer(required=False) text = Str(required=True) created_at = DateTime(required=False) author = Pluck('UserSchema', "id", required=True, many=False) chat = Pluck('ChatSchema', "id", required=True, many=False) class Meta(BaseSchema.Meta): model = Message
class OrganisationPatchRequestSchema(StrictSchema): name = String( required=True, validate=Length(max=128) ) status = Integer( required=True, validate=OneOf(OrganisationStatus.values()) )
class Camera(Component): __doc__ = m.Camera.__doc__ focal_length = Integer(data_key='focalLength') video_height = Integer(data_key='videoHeight') video_width = Integer(data_key='videoWidth') horizontal_view_angle = Integer(data_key='horizontalViewAngle') facing = Integer() vertical_view_angle = Integer(data_key='verticalViewAngle') video_stabilization = Integer(data_key='videoStabilization') flash = Integer()
def app_config(app_config): """Override conftest.py's app_config """ app_config['ILS_RECORDS_METADATA_NAMESPACES'] = { "document": { "accelerator_experiments": { "@context": "https://example.com/accelerator_experiments/terms" }, "standard_status": { "@context": "https://example.com/standard_status/terms" }, } } app_config['ILS_RECORDS_METADATA_EXTENSIONS'] = { "document": { "accelerator_experiments:accelerator": { "elasticsearch": "keyword", "marshmallow": SanitizedUnicode(required=True) }, 'accelerator_experiments:project': { 'elasticsearch': 'text', 'marshmallow': SanitizedUnicode() }, 'accelerator_experiments:number_in_sequence': { 'elasticsearch': 'long', 'marshmallow': Integer() }, 'accelerator_experiments:scientific_sequence': { 'elasticsearch': 'long', 'marshmallow': List(Integer()) }, 'standard_status:original_presentation_date': { 'elasticsearch': 'date', 'marshmallow': DateString() }, 'standard_status:right_or_wrong': { 'elasticsearch': 'boolean', 'marshmallow': Bool() } } } return app_config
class StackingJobSchema(JobSchema): type = 'stacking' result: StackingJobResultSchema = Nested(StackingJobResultSchema, default={}) file_ids: TList[int] = List(Integer(), default=[]) # alignment_settings: AlignmentSettingsSchema = Nested( # AlignmentSettings, default={}) stacking_settings: StackingSettingsSchema = Nested(StackingSettingsSchema, default={})
class UserSchema(Schema): id = Str() email = Str() is_admin = Boolean() first_name = Str() last_name = Str() age = Integer() country = Str() registered_at = DateTime(format=DATETIME_FORMAT) last_login_at = DateTime(format=DATETIME_FORMAT)
class FolderSchema(ContentSchema): ''' Schema for the Folder model ''' content_id = Integer(dump_only=True) index_content_id = Integer(missing=None) polymorphic_loading = Boolean(missing=False) polymorphic_children = Nested(ContentTypeSchema, dump_only=True, many=True) polymorphic_children_ids = List(Integer, load_only=True) default_order = Nested(FolderOrder, many=True, default=None) ######## # LOAD # ######## @pre_load def pre_load_adapt_polymorphic(self, data): try: data['polymorphic_children_ids'] = as_list( data['polymorphic_children_ids']) except KeyError: data['polymorphic_children_ids'] = [] try: data['default_order'] = json.loads(data['default_order']) except (ValueError, TypeError): del data['default_order'] return data @post_load def post_load_adapt_polymorphic(self, data): if data['polymorphic_loading']: pc = data.get('polymorphic_children_ids', []) if pc: pc = self.dbsession.query(ContentType).filter( ContentType.id.in_(pc)).all() data['polymorphic_children'] = pc else: data['polymorphic_children'] = [] return data
class TorrentSchema(Schema): type = Integer() id = Integer() origin_id = Integer() public_key = String() name = String() category = String() status = Integer() torrents = Integer() state = String() dirty = Boolean() infohash = String() size = Integer() num_seeders = Integer() num_leechers = Integer() last_tracker_check = Integer() updated = Integer() subscribed = Boolean() votes = Float()
class ChatSchema(ma.ModelSchema): id = Integer(required=False, data_key="chat") name = Str(required=True) created_at = DateTime(required=False) messages = Nested('MessageSchema', many=True, exclude=('chat', ), required=False) users = Pluck('UserSchema', 'id', many=True, required=True) event = Pluck('EventSchema', 'id', many=False, required=True) class Meta(BaseSchema.Meta): model = Chat
def app_config(app_config): """Override conftest.py's app_config""" app_config["ILS_RECORDS_METADATA_NAMESPACES"] = { "document": { "accelerator_experiments": { "@context": "https://example.com/accelerator_experiments/terms" }, "standard_status": { "@context": "https://example.com/standard_status/terms" }, } } app_config["ILS_RECORDS_METADATA_EXTENSIONS"] = { "document": { "accelerator_experiments_accelerator": { "elasticsearch": "keyword", "marshmallow": SanitizedUnicode(required=True), }, "accelerator_experiments_project": { "elasticsearch": "text", "marshmallow": SanitizedUnicode(), }, "accelerator_experiments_number_in_sequence": { "elasticsearch": "long", "marshmallow": Integer(), }, "accelerator_experiments_scientific_sequence": { "elasticsearch": "long", "marshmallow": List(Integer()), }, "standard_status_original_presentation_date": { "elasticsearch": "date", "marshmallow": DateString(), }, "standard_status_right_or_wrong": { "elasticsearch": "boolean", "marshmallow": Bool(), }, } } return app_config
class CustomerSchema(Schema): id = Integer(dump_only=True) created = DateTime(dump_only=True) first_name = String(required=True) last_name = String(required=True) address1 = String(required=True) address2 = String() city = String(required=True) state = String(required=True) code = String(required=True)
class ApplicantStatusSchema(Schema): __entity__ = ApplicantStatus applicant_email = Email(missing=None) receipt_code = Integer(missing=None) is_paid = Boolean(missing=False) is_printed_application_arrived = Boolean(missing=False) is_passed_first_apply = Boolean(missing=False) is_final_submit = Boolean(missing=False) exam_code = String(missing=None, length=6)
class Exception_Response_Schema(Schema): reason = Raw(required=True, example='Connection timeout', description='Exception reason.') filename = Str(required=True, example='lib/connection.py', description='Filename where the exception is raised.') line = Integer(required=True, example=80, description='Line where the exception is raised.')
class HotelSchema(Schema): id = Integer(required=True) name = String(required=True) is_active = Boolean(data_key=HotelCamelKey.mapping['is_active'], required=True) description = String(required=True) city_or_province = String( data_key=HotelCamelKey.mapping['city_or_province'], required=True) address = String(required=True) longitude = Float(required=True) latitude = Float(required=True) checkin = DateTime(format='%H:%M', required=True) checkout = DateTime(format='%H:%M', required=True) utilities = Method(serialize='get_utilities') room_types = Method(serialize='get_room_types', data_key=HotelCamelKey.mapping['room_types']) phone_number = String(data_key=HotelCamelKey.mapping['phone_number'], required=True) email = String(required=True) image = String(required=True) price_standard = Float(data_key=HotelCamelKey.mapping['price_standard']) available_room_standard = Integer( data_key=HotelCamelKey.mapping['available_room_standard']) tax_standard = Float(data_key=HotelCamelKey.mapping['tax_standard']) image_standard = String(data_key=HotelCamelKey.mapping['image_standard']) price_deluxe = Float(data_key=HotelCamelKey.mapping['price_deluxe']) available_room_deluxe = Integer( data_key=HotelCamelKey.mapping['available_room_deluxe'], allow_none=True) tax_deluxe = Float(data_key=HotelCamelKey.mapping['tax_deluxe']) image_deluxe = String(data_key=HotelCamelKey.mapping['image_deluxe']) def get_utilities(self, obj): utilities = obj.utilities if utilities is not None: utilities = utilities.split(',') return utilities def get_room_types(self, obj): room_types = obj.room_types if room_types is not None: room_types = room_types.split(',') return room_types
class MySchema(marshmallow.Schema): # byr = Number(required=True,validate=Range(min=1920,max=2002)) iyr = Number(required=True,validate=Range(min=2010,max=2020)) eyr = Number(required=True,validate=Range(min=2020,max=2030)) hgt = String(required=True) hcl = String(required=True,validate=Regexp('#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]')) ecl = String(required=True,validate=OneOf(['amb','blu','brn','gry','grn','hzl','oth'])) pid = Integer(required=True) cid = String(required=False)
class UserSchema(Schema): id = Integer(dump_only=True) first_name = String(required=True, validate=Length(1, 64)) last_name = String(required=True, validate=Length(1, 64)) birth_date = Date(required=True) email = Email(required=True) password = String(required=True, validate=Length(5, 32), load_only=True) created_at = DateTime(dump_only=True) updated_at = DateTime(dump_only=True) deleted_at = DateTime(dump_only=True)
class TaxonomySchemaV1(StrictKeysMixin): """Taxonomy schema.""" id = Integer(required=False) slug = SanitizedUnicode(required=False) path = SanitizedUnicode(required=False) title = Nested(TaxonomyTitleSchemaV1, many=True, required=False) tooltip = SanitizedUnicode(required=False) level = Integer(required=False) links = Nested(TaxonomyLinksSchemaV1, required=False) ref = SanitizedUnicode(required=False, attribute='$ref', **load_dump('$ref')) descendants_count = Integer(required=False, dump_only=True) ancestors = Nested(TaxonomyAncestorSchemaV1, many=True, required=False) @pre_load def convert_ref(self, in_data, **kwargs): ref = None if '$ref' in in_data: ref = in_data['$ref'] elif 'links' in in_data: ref = (in_data['links'] or {}).get('self', None) if not ref: # No reference found - don't convert anything return in_data resp = before_taxonomy_marshmallow.send(self, ref=ref) for r in resp: if r[1]: if r[1] is True: return {'$ref': ref} return r[1] path = url_to_path(ref) term = Taxonomy.get_taxonomy_term(path) if not term: raise ValidationError( 'Taxonomy $ref link is invalid: {}'.format(ref)) # noqa after_taxonomy_marshmallow.send(self, ref=ref, taxonomy_term=term) return {'$ref': ref}
class DocumentSchema(Schema, DatedSchema): id = String(dump_only=True) collection_id = Integer(dump_only=True, required=True) schema = SchemaName(dump_only=True) schemata = List(SchemaName(), dump_only=True) status = String(dump_only=True) type = String(dump_only=True) foreign_id = String() content_hash = String(dump_only=True) parent = Nested(DocumentReference()) uploader_id = Integer(dump_only=True) error_message = String(dump_only=True) # title = String(validate=Length(min=2, max=5000), missing=None) title = String() summary = String() countries = List(Country(), missing=[]) languages = List(Language(), missing=[]) keywords = List(String(validate=Length(min=1, max=5000)), missing=[]) dates = List(PartialDate(), dump_only=True) file_name = String() file_size = Integer(dump_only=True) author = String() mime_type = String() extension = String(dump_only=True) encoding = String(dump_only=True) source_url = String() pdf_version = String(dump_only=True) text = String(dump_only=True) html = String(dump_only=True) columns = List(String(), dump_only=True) children = Boolean(dump_to='$children', attribute='$children', dump_only=True) @post_dump def transient(self, data): data['$uri'] = url_for('documents_api.view', document_id=data.get('id')) data['$ui'] = document_url(data.get('id')) collection_id = data.get('collection_id') data['$writeable'] = request.authz.can_write(collection_id) return data
class FieldCal(AfterglowSchema): """ Field calibration prescription """ id: int = Integer() name: str = String() catalog_sources: TList[CatalogSource] = List(Nested(CatalogSource)) catalogs: TList[str] = List(String()) custom_filter_lookup: TDict[str, TDict[str, str]] = Dict(keys=String, values=Dict(keys=String, values=String)) source_inclusion_percent: float = Float() min_snr: float = Float() max_snr: float = Float() source_match_tol: float = Float() variable_check_tol: float = Float() max_star_rms: float = Float() max_stars: int = Integer()
class BackendStatusSchema(BaseSchema): """Schema for BackendStatus.""" # Required properties. backend_name = String(required=True) backend_version = String(required=True, validate=Regexp("[0-9]+.[0-9]+.[0-9]+$")) operational = Boolean(required=True) pending_jobs = Integer(required=True, validate=Range(min=0)) status_msg = String(required=True)
class UserPostRequestSchema(StrictSchema): first_name = String(required=True, validate=validate.Length(max=128)) last_name = String(required=True, validate=validate.Length(max=128)) email = Email(required=True, validate=[ validate.Length(max=254), validate.Email(), validate_unique_user_email ], allow_none=False) organisation_id = Integer(required=True, validate=validate_organisation_exists)
class RequestExcludeSchema(BaseSchema): """ Configuration schema for request exclusion, that is only used in RequestSchema, is used to exclude unknown sources, applications, methods and status codes. """ unknown = Boolean(missing=False) applications = Set(SearchString(), missing=set()) methods = Set(LowerCaseString(), missing={'GET'}) status = Set(Integer(validate=Range(min=0)), missing={200})