class JobResponseSchema(ResponseSchema): job_id = fields.UUID(attribute="type_uuid") status = fields.Integer() step_number = fields.Integer() total_steps = fields.Integer() result_ref = fields.Url(required=False, allow_none=True, missing=None) error = fields.String(required=False, allow_none=True) job_ref = fields.Function( lambda job: f"{constants.URLBASE}/jobs/{job.type_uuid}")
class RevRegUpdateTailsFileUriSchema(OpenAPISchema): """Request schema for updating tails file URI.""" tails_public_uri = fields.Url( description="Public URI to the tails file", example=("http://192.168.56.133:6543/revocation/registry/" f"{INDY_REV_REG_ID['example']}/tails-file"), required=True, )
class BuildInfoSchema(Schema): build_id = fields.String(required=True) build_status = fields.String(required=True) build_url = fields.Url(required=False, allow_none=True) build_log_url = fields.Url(required=False, allow_none=True) ocp_info = fields.Nested(OCPSchema, required=False) first_timestamp = fields.DateTime(required=False) last_timestamp = fields.DateTime(required=False) log_level = fields.Integer(required=False) @post_load def make_build_info(self, data: dict) -> BuildInfo: return BuildInfo(**data)
class InvoiceSchema(BaseSchema): """ Schema class for the :class:`Invoice` class """ __model__ = Invoice id = fields.Integer() """int: |NAMI| id""" reDatum = fields.DateTime() """:class:`~datetime.datetime`: Date of the invoice""" reCreated = fields.DateTime() """:class:`~datetime.datetime`: Creation date of the invoice""" reNr = fields.String() """str: Official invoice number""" status = fields.String() """str: If the invoice has been released""" debitor = fields.String() """str: Id of the debitor""" freigabeDatum = fields.DateTime() """:class:`~datetime.datetime`: When the invoice was released""" debitor_document_id = fields.Integer() """int: Some other internal id""" rechnungsLauf = fields.Integer() """int: Internal invoice number""" displayName = fields.String() """str: Human-readable string describing the invoice""" debitorName = fields.String() """str: Debitor, e.g. a group""" einzugsDatum = fields.DateTime() """:class:`~datetime.datetime`: Date of money collection""" zahlungsweise = fields.String() """str: Way of payment (e.g. ``'Lastschrift'``)""" zahlungsweiseId = fields.String() """str: Id of the way of payment (e.g. ``'LASTSCHRIFT'``)""" pdf = fields.Url(relative=True) """str: Relative download |URL|""" debitorKonto = fields.String() """str: Some account id""" erloesKtoName = fields.String(allow_none=True) """str: This may be empty""" total = fields.String() """str: Total amount""" currency = fields.String() """str: Currency (e.g. ``'EUR'``)""" @pre_load def get_download_url(self, data, **kwargs): """ Extract the |HTML| enclosed |URL| string from the pdf download field Args: data (dict): Data dictionary Returns: dict: The updated data dictionary """ data['pdf'] = extract_url(data['pdf']) return data
class TestingFieldsSchema(Schema): integer = fields.Integer() float = fields.Float() boolean = fields.Boolean() datetime = fields.DateTime() timedelta = fields.TimeDelta() dictionary = fields.Dict() url = fields.Url() email = fields.Email()
class AssetSchema(BaseSchema): """Schema to store information about an asset.""" href = fields.Url(required=True) title = fields.String() description = fields.String() type_ = fields.String(data_key="type", attribute="type") roles = fields.List(fields.String()) name = fields.String(required=True) # Asset's dict key
class TaskSchema(ma.Schema): id = fields.String(dump_only=True) url = fields.Url(required=True) email = fields.Email() @post_load def create_task(self, data): data['id'] = get_task_id() return data
class DaoCreateCategorySchema(Schema): description = fields.Str( required=True, validate=[validate.Length(min=1, max=80)] ) url = fields.Url(required=True) challenge = fields.Integer( required=True )
class OutputEntitySchema(Schema): id = fields.Str() url = fields.Url() salience = fields.Float() name = fields.Str() type = fields.Str() @post_load def make_object(self, data): return OutputEntity(**data)
class NewLinkRequestSchema(Schema): url = fields.Url(required=True, relative=False, schemes=["http", "https"]) @validates("url") def validate_cycle(self, url): if not self.context.get("app_host"): return parts = urlparse(url) if parts.hostname == self.context["app_host"]: raise ValidationError("Cannot store URL to own host.")
def test_url_field_deserialization(self): field = fields.Url() assert field.deserialize('https://duckduckgo.com') == 'https://duckduckgo.com' with pytest.raises(ValidationError) as excinfo: field.deserialize('badurl') assert excinfo.value.args[0][0] == 'Not a valid URL.' # Relative URLS not allowed by default with pytest.raises(ValidationError) as excinfo: field.deserialize('/foo/bar') assert excinfo.value.args[0][0] == 'Not a valid URL.'
class SendRequestSchema(Schema): _sendto = fields.Email(required=True) _replyto = fields.Email(allow_none=True) _next = fields.Url(allow_none=True) _subject = fields.String(allow_none=True) _cc = fields.String(allow_none=True) _gotcha = fields.String(allow_none=True) class Meta: unknown = INCLUDE
class RepositorySchema(Schema): class Meta: ordered = True type = fields.String(required=True) location = fields.Url(required=True) @post_load def make(self, data): return Repository(**data)
class ArticleSchema(Schema): url = fields.Url(required=True) body = fields.Str(required=True) title = fields.Str(required=True) authors = fields.List(fields.Str(required=True)) videos = fields.List(fields.Str(required=True)) images = fields.List(fields.Str(required=True)) keywords = fields.List(fields.Str(required=True)) tags = fields.List(fields.Str(required=True)) summary = fields.Str(required=True)
class JobSchema(Schema): id = fields.UUID(dump_only=True) start_time = fields.DateTime(dump_only=True) end_time = fields.DateTime(dump_only=True, allow_none=True) status = fields.Str(dump_only=True, allow_none=True) details = fields.Str(dump_only=True, allow_none=True) type = fields.Str(dump_only=True, allow_none=True) url = fields.Url(dump_only=True, allow_none=True) user = fields.Str(dump_only=True, allow_none=True) settings = fields.Dict()
class JobSchema(Schema): id = fields.Int(dump_only=True) url = fields.Url() image = fields.Url() title_job = fields.Str() company = fields.Str() location = fields.Str() posted = fields.Str() contents = fields.Str() contents_text = fields.Str() concepts = fields.Str() keywords = fields.Str() created_at = fields.DateTime() applicants = fields.List( fields.Nested("ApplicantSchema", exclude=("job", ))) overall_score = fields.Nested("OverallScoreSchema", exclude=("job", )) user = fields.Nested("UserSchema", only=("id", "email"))
class NewsItemSchema(Schema): title = fields.Str(data_key='title') summary = fields.Str(data_key='summary') category = fields.Str(required=False, data_key='category') # pub_date = fields.DateTime(format='rfc822', data_key='published') link = fields.Url(data_key='link') @post_load def make_feed(self, data): return NewsItem(**data)
class EndpointSchema(Schema): """ Configuration for a REST or RESTish endpoint """ url = fields.Url() timeout = fields.Int() @post_load def make_object(self, data): return Endpoint(**data)
class OSRelease(Schema): name = fields.Str(default="Linux") version = fields.Str(default=None) id = fields.Str(default="linux") id_like = fields.Str(default=None) version_codename = fields.Str(default=None) version_id = fields.Str(default=None) pretty_name = fields.Str(default=None) ansi_color = fields.Str(default=None) cpe_name = fields.Str(default=None) home_url = fields.Url(default=None) support_url = fields.Url(default=None) bug_report_url = fields.Url(default=None) privacy_policy_url = fields.Url(default=None) build_id = fields.Str(default=None) variant = fields.Str(default=None) variant_id = fields.Str(default=None)
class AlbumSchema(Schema): artist = fields.Str() title = fields.Str() release_year = fields.Int() label = fields.Str() cover_url = fields.Url() @post_load def create_album(self, data): return Album(**data)
class AwardNumberSchema(Schema): '''AwardNumber object schema''' awardNumber = fields.String(required=True) awardURI = fields.Url() @post_load def make_award_number(self, data): '''Return AwardNumber object after loading''' return AwardNumber(**data)
class UserSchema(Schema): """ User model. This might be used with User class. If there is no need to have instances of Users in this application, then only dictionaries might be used. """ name = fields.Str(required=True) email = fields.Email(required=True) description = fields.Str(required=True) picture = fields.Url(required=True) favorites = fields.List(fields.Url(), required=True) social_media = fields.List(fields.Url(), required=True) metadata = fields.List(fields.Nested(MetadataSchema), required=True) is_admin = fields.Bool(required=True) @post_load def make_user(self, data, **kwargs): return User(**data)
class ConfigSchema(Schema): max_submissions_per_period = fields.Integer( missing=1, metadata='number of submissions allowed per user per quota period') max_submissions_total = fields.Integer( missing=10000, metadata='number of submissions allowed per user for eternity') refresh_period_seconds = fields.Integer( missing=60, metadata= '(for daemon mode) number of seconds to wait before checking for new submissions again', ) max_leaderboard_size = fields.Integer( missing=10000, metadata= 'maximum number of bundles you expect to have on the log worksheet') quota_period_seconds = fields.Integer( missing=24 * 60 * 60, metadata='window size for the user submission quotas in seconds') count_failed_submissions = fields.Boolean( missing=True, metadata='whether to count failed evaluations toward submission quotas' ) make_predictions_public = fields.Boolean( missing=False, metadata= 'whether to make newly-created prediction bundles publicly readable') allow_orphans = fields.Boolean( missing=True, metadata= 'whether to keep leaderboard entries that no longer have corresponding submission bundles', ) allow_multiple_models = fields.Boolean( missing=False, metadata= 'whether to distinguish multiple models per user by bundle name') host = fields.Url( missing='https://worksheets.codalab.org', metadata='address of the CodaLab instance to connect to', ) username = fields.String(metadata='username for CodaLab account to use') password = fields.String(metadata='password for CodaLab account to use') submission_tag = fields.String( required=True, metadata='tag for searching for submissions') log_worksheet_uuid = fields.String( validate=validate_uuid, metadata='UUID of worksheet to create new bundles in') predict = fields.Nested(MimicConfigSchema, required=True) evaluate = fields.Nested(RunConfigSchema, required=True) # Leaderboard sorted by the first key in this list score_specs = fields.List(fields.Nested(ScoreSpecSchema), required=True) # Gets passed directly to the output JSON metadata = fields.Dict( missing={}, metadata='additional metadata to include in the leaderboard file')
class ComicSchema(Schema): id = fields.Int() digitalId = fields.Int(attribute='digital_id') title = fields.Str() issueNumber = fields.Int(attribute='issue_number') variantDescription = fields.Str(attribute='variant_description') description = fields.Str(allow_none=True) modified = fields.DateTime() isbn = fields.Str() up = fields.Str() diamondCode = fields.Str(attribute='diamond_code') ean = fields.Str() issn = fields.Str() format = fields.Str() pageCount = fields.Int(attribute='page_count') # textObjects resourceURI = fields.Url(attribute='resource_uri') urls = fields.Nested(urls.UrlsSchema) series = fields.Nested(series.SeriesSchema) # variants # collections # collectedIssues dates = fields.Nested(dates.DatesSchema) # prices # thumbnail images = fields.List(fields.Url) # creators # characters # stories events = fields.Nested(events.EventsSchema, many=True) @pre_load def process_input(self, data): new_data = data # Marvel comic 1768, and maybe others, returns a modified of # "-0001-11-30T00:00:00-0500". The best way to handle this is # probably just to ignore it, since I don't know how to fix it. if new_data.get('modified', ' ')[0] == '-': del new_data['modified'] if 'events' in new_data: new_data['events'] = new_data['events']['items'] if 'images' in new_data: new_data['images'] = [ '{}.{}'.format(img['path'], img['extension']) for img in new_data['images'] ] return new_data @post_load def make(self, data): return Comic(**data)
class KeepOrder(Schema): class Meta: ordered = True name = fields.String(allow_none=True) email = fields.Email(allow_none=True) age = fields.Integer() created = fields.DateTime() id = fields.Integer(allow_none=True) homepage = fields.Url() birthdate = fields.Date()
class DataDetailsSchema(Schema): state = fields.Str() size = fields.Float() uri = fields.Url() class Meta: ordered = True @post_load def make(self, data): return DataDetailsConfig(**data)
class CreateRepo(Schema): name = fields.Str(required=True) description = fields.Str() homepage = fields.Url() private = fields.Bool() has_issues = fields.Bool() has_wiki = fields.Bool() team_id = fields.Int() auto_init = fields.Bool() gitignore_template = fields.Str() licence_template = fields.Str()
class AverageAreaSoldPriceResultSchema(BaseResultSchema): average_sold_price_1year = fields.Float() average_sold_price_3year = fields.Float() average_sold_price_5year = fields.Float() average_sold_price_7year = fields.Float() number_of_sales_1year = fields.Integer() number_of_sales_3year = fields.Integer() number_of_sales_5year = fields.Integer() number_of_sales_7year = fields.Integer() turnover = fields.Float() prices_url = fields.Url()
class PaymentMethodSchema(Schema): """marshmallow payment schema""" name = fields.Str(required=True, validate=validate.Length( min=1, error="Payment name cannot be empty")) type = fields.Int(required=True) image = fields.Url() @post_load def make_payment_method(self, data): """creates a Payment object from data dictionary""" return PaymentMethod(**data)
class QQUserAlbumSchema(Schema): identifier = fields.Int(required=True, data_key='albumid') mid = fields.Str(required=True, data_key='albummid') name = fields.Str(required=True, data_key='albumname') cover = fields.Url(required=True, data_key='pic') @post_load def create_model(self, data, **kwargs): # if data.get('desc') is None: # data['desc'] = '' return QQUserAlbumModel(**data)