Пример #1
0
class Scale(Model):
    value = FloatType(deserialize_from="value")
    unit = StringType(deserialize_from="unit")
Пример #2
0
class Database(Model):
    name = StringType(serialize_when_none=False)
    id = StringType()
    kind = StringType(serialize_when_none=False)
    location = StringType()
    managed_by = StringType(serialize_when_none=False)
    server_name = StringType(serialize_when_none=False)
    subscription_id = StringType(serialize_when_none=False)
    resource_group = StringType(serialize_when_none=False)

    administrator_login = StringType(default='-')
    auto_pause_delay = IntType(serialize_when_none=False)
    catalog_collation = StringType(choices=('DATABASE_DEFAULT',
                                            'SQL_Latin1_General_CP1_CI_AS'),
                                   serialize_when_none=False)
    collation = StringType(serialize_when_none=False)
    create_mode = StringType(
        choices=('Copy', 'Default', 'OnlineSecondary', 'PointInTimeRestore',
                 'Recovery', 'Restore', 'RestoreExternalBackup',
                 'RestoreExternalBackupSecondary',
                 'RestoreLongTermRetentionBackup', 'Secondary'),
        serialize_when_none=False)
    creation_date = DateTimeType(serialize_when_none=False)
    current_service_objective_name = StringType(serialize_when_none=False)
    current_sku = ModelType(Sku, serialize_when_none=False)
    database_id = StringType(serialize_when_none=False)
    default_secondary_location = StringType(serialize_when_none=False)
    earliest_restore_date = DateTimeType(serialize_when_none=False)
    elastic_pool_id = StringType(serialize_when_none=False)
    failover_group_id = StringType(serialize_when_none=False)
    high_availability_replica_count = IntType(serialize_when_none=False)
    license_type = StringType(choices=('BasePrice', 'LicenseIncluded'),
                              serialize_when_none=False)
    long_term_retention_backup_resource_id = StringType(default='-')
    maintenance_configuration_id = StringType(serialize_when_none=False)
    max_log_size_bytes = IntType(serialize_when_none=False)
    max_size_bytes = IntType(serialize_when_none=False)
    max_size_gb = FloatType(serialize_when_none=False)
    min_capacity = FloatType(serialize_when_none=False)
    paused_date = DateTimeType(serialize_when_none=False)
    read_scale = StringType(choices=('Disabled', 'Enabled'),
                            default='Disabled')
    recoverable_database_id = StringType(serialize_when_none=False)
    recovery_services_recovery_point_id = StringType(serialize_when_none=False)
    requested_service_objective_name = StringType(serialize_when_none=False)
    restorable_dropped_database_id = StringType(serialize_when_none=False)
    restore_point_in_time = StringType(serialize_when_none=False)
    resumed_date = DateTimeType(serialize_when_none=False)
    sample_name = StringType(choices=('AdventureWorksLT',
                                      'WideWorldImportersFull',
                                      'WideWorldImportersStd'),
                             serialize_when_none=False)
    secondary_type = StringType(choices=('Geo', 'Named'),
                                serialize_when_none=False)
    source_database_deletion_date = StringType(serialize_when_none=False)
    source_database_id = StringType(serialize_when_none=False)
    status = StringType(
        choices=('AutoClosed', 'Copying', 'Creating', 'Disabled',
                 'EmergencyMode', 'Inaccessible', 'Offline',
                 'OfflineChangingDwPerformanceTiers', 'OfflineSecondary',
                 'Online', 'OnlineChangingDwPerformanceTiers', 'Paused',
                 'Pausing', 'Recovering', 'RecoveryPending', 'Restoring',
                 'Resuming', 'Scaling', 'Shutdown', 'Standby', 'Suspect'),
        serialize_when_none=False)
    storage_account_type = StringType(choices=('GRS', 'LRS', 'ZRS'),
                                      serialize_when_none=False)
    zone_redundant = BooleanType(serialize_when_none=False)
    diagnostic_settings_resource = ListType(
        ModelType(DiagnosticSettingsResource), serialize_when_none=False)
    replication_link = ListType(ModelType(ReplicationLink),
                                serialize_when_none=False)
    sync_group = ListType(ModelType(SyncGroup), serialize_when_none=False)
    sync_agent = ListType(ModelType(SyncAgent), serialize_when_none=False)
    sync_group_display = ListType(StringType, serialize_when_none=False)
    sync_agent_display = ListType(StringType, serialize_when_none=False)
    sku = ModelType(Sku, serialize_when_none=False)
    pricing_tier_display = StringType(default='-')
    service_tier_display = StringType(default='-')
    compute_tier = StringType(serialize_when_none=False)
    tags = (ModelType(Tags))
    type = StringType(serialize_when_none=False)
Пример #3
0
class Hardware(Model):
    serial_number = StringType(serialize_when_none=False)
    core = IntType(default=0)
    memory = FloatType(default=0.0)
Пример #4
0
class NestedManifest(Model):
    """ The nested manifest description for multi_challenge jobs """
    job_id = UUIDType(default=uuid.uuid4)

    requester_restricted_answer_set = DictType(DictType(StringType))

    def validate_requester_restricted_answer_set(self, data, value):
        """image_label_area_select should always have a single RAS set"""

        # validation runs before other params, so need to handle missing case
        if not data.get('request_type'):
            raise ValidationError("request_type missing")

        if data['request_type'] == 'image_label_area_select':
            if not value or len(value.keys()) == 0:
                value = {'label': {}}
                data['requester_restricted_answer_set'] = value
        return value

    requester_description = StringType()
    requester_max_repeats = IntType(default=100)
    requester_min_repeats = IntType(default=1)
    requester_question = DictType(StringType)

    requester_question_example = UnionType((URLType, ListType), field=URLType)

    def validate_requester_question_example(self, data, value):
        # validation runs before other params, so need to handle missing case
        if not data.get('request_type'):
            raise ValidationError("request_type missing")

        # based on https://github.com/hCaptcha/hmt-basemodels/issues/27#issuecomment-590706643
        supports_lists = ['image_label_area_select', 'image_label_binary']

        if isinstance(value,
                      list) and not data['request_type'] in supports_lists:
            raise ValidationError(
                "Lists are not allowed in this challenge type")
        return value

    unsafe_content = BooleanType(default=False)
    requester_accuracy_target = FloatType(default=.1)
    request_type = StringType(required=True, choices=BASE_JOB_TYPES)
    validate_request_type = validate_request_type

    request_config = ModelType(RequestConfig, required=False)

    # Groundtruth data is stored as a URL or optionally as an inlined json-serialized stringtype
    groundtruth_uri = URLType(required=False)
    groundtruth = StringType(required=False)

    def validate_groundtruth(self, data, value):
        if data.get('groundtruth_uri') and data.get('groundtruth'):
            raise ValidationError(
                "Specify only groundtruth_uri or groundtruth, not both.")
        return value

    # Configuration id -- XXX LEGACY
    confcalc_configuration_id = StringType(required=False)

    webhook = ModelType(Webhook)
Пример #5
0
class Guarantee(Model):
    amount = FloatType(required=True, min_value=0)  # Amount as a number.
    currency = StringType(required=True, default=u'UAH', max_length=3, min_length=3)  # The currency in 3-letter ISO 4217 format.
Пример #6
0
class Ticket(Model):
    name = StringType()
    departure = StringType()
    arrival = StringType()
    price = FloatType()
    member_ref = StringType(required=True)
Пример #7
0
class Monitoring(BaseModel):

    class Options:
        _perm_edit_whitelist = whitelist('status', 'reasons', 'procuringStages')
        roles = {
            'plain': blacklist('_attachments', 'revisions') + schematics_embedded_role,
            'revision': whitelist('revisions'),
            'create': whitelist(
                "tender_id", "reasons", "procuringStages", "status",
                "mode", "monitoringDetails", "parties", "decision",
                "riskIndicators", "riskIndicatorsTotalImpact", "riskIndicatorsRegion",
            ),
            'edit_draft': whitelist('decision', 'cancellation') + _perm_edit_whitelist,
            'edit_active': whitelist('conclusion', 'cancellation') + _perm_edit_whitelist,
            'edit_addressed': whitelist('eliminationResolution', 'cancellation') + _perm_edit_whitelist,
            'edit_declined': whitelist('cancellation') + _perm_edit_whitelist,
            'edit_completed': whitelist('documents'),
            'edit_closed': whitelist('documents'),
            'edit_stopped': whitelist('documents'),
            'edit_cancelled': whitelist('documents'),
            'view': blacklist(
                'tender_owner_token', '_attachments', 'revisions',
                'decision', 'conclusion', 'cancellation'
            ) + schematics_embedded_role,
            'listing': whitelist('dateModified', 'doc_id'),
            'default': schematics_default_role,
        }

    tender_id = MD5Type(required=True)
    monitoring_id = StringType()
    status = StringType(choices=MONITORING_STATUS_CHOICES, default=DRAFT_STATUS)

    reasons = ListType(StringType(choices=MONITORING_REASON_CHOICES), required=True)
    procuringStages = ListType(StringType(choices=MONITORING_PROCURING_STAGES), required=True)
    monitoringPeriod = ModelType(Period)

    documents = ListType(ModelType(Document), default=[])

    riskIndicators = ListType(StringType(), default=[])
    riskIndicatorsTotalImpact = FloatType()
    riskIndicatorsRegion = StringType()

    decision = ModelType(Decision)
    conclusion = ModelType(Conclusion)
    eliminationReport = ModelType(EliminationReport)
    eliminationResolution = ModelType(EliminationResolution)
    eliminationPeriod = ModelType(Period)
    posts = ListType(ModelType(Post), default=[])
    cancellation = ModelType(Cancellation)
    appeal = ModelType(Appeal)

    parties = ListType(ModelType(Party), default=[])

    dateModified = IsoDateTimeType()
    endDate = IsoDateTimeType()
    dateCreated = IsoDateTimeType(default=get_now)
    tender_owner = StringType()
    tender_owner_token = StringType()
    revisions = ListType(ModelType(Revision), default=[])
    _attachments = DictType(DictType(BaseType), default=dict())

    mode = StringType(choices=['test'])
    if SANDBOX_MODE:
        monitoringDetails = StringType()

    @serializable(serialized_name='decision', serialize_when_none=False, type=ModelType(Decision))
    def monitoring_decision(self):
        role = self.__parent__.request.authenticated_role
        if self.decision and self.decision.datePublished or role == 'sas':
            return self.decision

    @serializable(serialized_name='conclusion', serialize_when_none=False, type=ModelType(Conclusion))
    def monitoring_conclusion(self):
        role = self.__parent__.request.authenticated_role
        if self.conclusion and self.conclusion.datePublished or role == 'sas':
            return self.conclusion

    @serializable(serialized_name='cancellation', serialize_when_none=False, type=ModelType(Cancellation))
    def monitoring_cancellation(self):
        role = self.__parent__.request.authenticated_role
        if self.cancellation and self.cancellation.datePublished or role == 'sas':
            return self.cancellation

    def get_role(self):
        role = super(Monitoring, self).get_role()
        status = self.__parent__.request.context.status
        return 'edit_{}'.format(status) if role == 'edit' else role

    def __acl__(self):
        return [
            (Allow, '{}_{}'.format(self.tender_owner, self.tender_owner_token), 'create_post'),
            (Allow, '{}_{}'.format(self.tender_owner, self.tender_owner_token), 'create_elimination_report'),
            (Allow, '{}_{}'.format(self.tender_owner, self.tender_owner_token), 'create_appeal'),
        ]

    def __repr__(self):
        return '<%s:%r-%r@%r>' % (type(self).__name__, self.tender_id, self.id, self.rev)
Пример #8
0
class LimitOrder(BetfairModel):
    size = FloatType(required=True)
    price = FloatType(required=True)
    persistence_type = EnumType(constants.PersistenceType, required=True)
Пример #9
0
class LimitOnCloseOrder(BetfairModel):
    liability = FloatType(required=True)
    price = FloatType(required=True)
Пример #10
0
class MarketProfitAndLoss(BetfairModel):
    market_id = StringType()
    commission_applied = FloatType()
    profit_and_losses = ListType(ModelType(RunnerProfitAndLoss))
Пример #11
0
class ExBestOffersOverrides(BetfairModel):
    best_prices_depth = IntType()
    rollup_model = EnumType(constants.RollupModel)
    rollup_limit = IntType()
    rollup_liability_threshold = FloatType()
    rollup_liability_factor = IntType()
Пример #12
0
class RunnerProfitAndLoss(BetfairModel):
    selection_id = IntType()
    if_win = FloatType()
    if_lose = FloatType()
Пример #13
0
class StartingPrices(BetfairModel):
    near_price = FloatType()
    far_price = FloatType()
    back_stake_taken = ListType(ModelType(PriceSize))
    lay_liability_taken = ListType(ModelType(PriceSize))
    actual_SP = FloatType()
Пример #14
0
class PriceSize(BetfairModel):
    price = FloatType(required=True)
    size = FloatType(required=True)
Пример #15
0
class Woman(Model):
    type = PolymorphicID('woman')
    emotional_strength = FloatType(required=True)
Пример #16
0
class MarketOnCloseOrder(BetfairModel):
    liability = FloatType(required=True)
Пример #17
0
class Man(Model):
    type = PolymorphicID('man')
    arm_strength = FloatType(required=True)
Пример #18
0
class CancelInstruction(BetfairModel):
    bet_id = StringType(required=True)
    size_reduction = FloatType()
Пример #19
0
class Refly(Model):
    enabled = BooleanType(
        default=True,
        required=True,
    )
    death_penalty = IntType(
        min_value=0,
        default=0,
        required=True,
    )
    death_penalty_multiplier = FloatType(
        min_value=0.0,
        default=0.0,
        required=True,
    )
    death_limit = IntType(
        min_value=1,
        default=None,
        required=False,
    )

    @classmethod
    def from_ini(cls, ini):
        death_limit = field_from_ini(
            cls.death_limit,
            ini,
            'NET',
            'maxAllowedKIA',
        )
        death_limit = (None
                       if death_limit == NO_DEATH_LIMIT_FLAG else death_limit)

        return cls({
            'enabled':
            not field_from_ini(
                cls.enabled,
                ini,
                'NET',
                'reflyDisabled',
                False,
            ),
            'death_penalty':
            field_from_ini(
                cls.death_penalty,
                ini,
                'NET',
                'reflyKIADelay',
            ),
            'death_penalty_multiplier':
            field_from_ini(
                cls.death_penalty_multiplier,
                ini,
                'NET',
                'reflyKIADelayMultiplier',
            ),
            'death_limit':
            death_limit,
        })

    def to_ini(self, ini):
        death_limit = (NO_DEATH_LIMIT_FLAG
                       if self.death_limit is None else self.death_limit)

        field_to_ini(not self.enabled, ini, 'NET', 'reflyDisabled')
        field_to_ini(self.death_penalty, ini, 'NET', 'reflyKIADelay')
        field_to_ini(self.death_penalty_multiplier, ini, 'NET',
                     'reflyKIADelayMultiplier')
        field_to_ini(death_limit, ini, 'NET', 'maxAllowedKIA')

    @classmethod
    def default(cls):
        return cls({
            field_name: field.default
            for field_name, field in cls.fields.items()
        })
Пример #20
0
class ReplaceInstruction(BetfairModel):
    bet_id = StringType(required=True)
    new_price = FloatType(required=True)
Пример #21
0
 class MyModel(Model):
     a = JSONType()
     b = FloatType()
Пример #22
0
class PlaceInstructionReport(BaseInstructionReport):
    instruction = ModelType(PlaceInstruction, required=True)
    bet_id = StringType()
    placed_date = DateTimeType()
    average_price_matched = FloatType()
    size_matched = FloatType()
Пример #23
0
class Manifest(Model):
    """ The manifest description. """
    job_mode = StringType(required=True,
                          choices=["batch", "online", "instant_delivery"])
    job_api_key = UUIDType(default=uuid.uuid4)
    job_id = UUIDType(default=uuid.uuid4)
    job_total_tasks = IntType(required=True)

    requester_restricted_answer_set = DictType(DictType(StringType))

    def validate_requester_restricted_answer_set(self, data, value):
        """image_label_area_select should always have a single RAS set"""
        # validation runs before other params, so need to handle missing case
        if not data.get('request_type'):
            raise ValidationError("request_type missing")

        if data['request_type'] == 'image_label_area_select':
            if not value or len(value.keys()) == 0:
                value = {'label': {}}
                data['requester_restricted_answer_set'] = value
        return value

    requester_description = StringType()
    requester_max_repeats = IntType(default=100)
    requester_min_repeats = IntType(default=1)
    requester_question = DictType(StringType)

    requester_question_example = UnionType((URLType, ListType), field=URLType)

    def validate_requester_question_example(self, data, value):
        # validation runs before other params, so need to handle missing case
        if not data.get('request_type'):
            raise ValidationError("request_type missing")

        # based on https://github.com/hCaptcha/hmt-basemodels/issues/27#issuecomment-590706643
        supports_lists = ['image_label_area_select', 'image_label_binary']

        if isinstance(value,
                      list) and not data['request_type'] in supports_lists:
            raise ValidationError(
                "Lists are not allowed in this challenge type")
        return value

    unsafe_content = BooleanType(default=False)
    task_bid_price = DecimalType(required=True)
    oracle_stake = DecimalType(required=True)
    expiration_date = IntType()
    requester_accuracy_target = FloatType(default=.1)
    manifest_smart_bounty_addr = StringType()
    hmtoken_addr = StringType()
    minimum_trust_server = FloatType(default=.1)
    minimum_trust_client = FloatType(default=.1)
    recording_oracle_addr = StringType(required=True)
    reputation_oracle_addr = StringType(required=True)
    reputation_agent_addr = StringType(required=True)
    requester_pgp_public_key = StringType()
    ro_uri = StringType()
    repo_uri = StringType()

    batch_result_delivery_webhook = URLType()
    online_result_delivery_webhook = URLType()
    instant_result_delivery_webhook = URLType()

    multi_challenge_manifests = ListType(ModelType(NestedManifest),
                                         required=False)

    request_type = StringType(required=True,
                              choices=BASE_JOB_TYPES + ["multi_challenge"])
    validate_request_type = validate_request_type

    request_config = ModelType(RequestConfig, required=False)

    # If taskdata is directly provided
    taskdata = ListType(ModelType(TaskData))

    # If taskdata is separately stored
    taskdata_uri = URLType()

    # Groundtruth data is stored as a URL or optionally as an inlined json-serialized stringtype
    groundtruth_uri = URLType(required=False)
    groundtruth = StringType(required=False)

    def validate_groundtruth(self, data, value):
        if data.get('groundtruth_uri') and data.get('groundtruth'):
            raise ValidationError(
                "Specify only groundtruth_uri or groundtruth, not both.")
        return value

    # internal config options for param tests etc.
    internal_config = ModelType(InternalConfig, required=False)

    # Configuration id -- XXX LEGACY
    confcalc_configuration_id = StringType(required=False)

    restricted_audience = DictType(
        UnionType([FloatType,
                   ListType(DictType(DictType(FloatType)))]))

    def validate_taskdata_uri(self, data, value):
        if data.get('taskdata') and len(
                data.get('taskdata')) > 0 and data.get('taskdata_uri'):
            raise ValidationError(
                u'Specify only one of taskdata {} or taskdata_uri {}'.format(
                    data.get('taskdata'), data.get('taskdata_uri')))
        return value

    validate_taskdata = validate_taskdata_uri

    webhook = ModelType(Webhook)
Пример #24
0
class CancelInstructionReport(BaseInstructionReport):
    instruction = ModelType(CancelInstruction)
    size_cancelled = FloatType(required=True)
    cancelled_date = DateTimeType()
Пример #25
0
class Manifest(Model):
    """ The manifest description. """
    job_mode = StringType(
        required=True, choices=["batch", "online", "instant_delivery"])
    job_api_key = UUIDType(default=uuid.uuid4)
    job_id = UUIDType(default=uuid.uuid4)
    job_total_tasks = IntType()

    requester_restricted_answer_set = DictType(DictType(StringType))
    requester_description = StringType()
    requester_max_repeats = IntType()
    requester_min_repeats = IntType()
    requester_question = DictType(StringType)
    requester_question_example = URLType()
    unsafe_content = BooleanType(default=False)
    task_bid_price = DecimalType(required=True)
    oracle_stake = DecimalType(required=True)
    expiration_date = IntType()
    requester_accuracy_target = FloatType(default=.1)
    manifest_smart_bounty_addr = StringType()
    minimum_trust_server = FloatType(default=.1)
    minimum_trust_client = FloatType(default=.1)
    recording_oracle_addr = StringType(required=True)
    reputation_oracle_addr = StringType(required=True)
    reputation_agent_addr = StringType(required=True)
    requester_pgp_public_key = StringType()

    # Future TODO: replace with KV lookup on recording_oracle_addr
    # NOTE: URLType fails without TLD (examples: http://localhost/,
    #       http://exchange/, etc), so using StringType instead.
    ro_uri = StringType()
    repo_uri = StringType()

    batch_result_delivery_webhook = URLType()
    online_result_delivery_webhook = URLType()
    instant_result_delivery_webhook = URLType()
    request_type = StringType(
        required=True,
        choices=[
            "image_label_binary", "image_label_multiple_choice_one_option",
            "image_label_multiple_choice_multiple_options", "text_free_entry",
            "text_multiple_choice_one_option",
            "text_multiple_choice_multiple_options",
            "image_label_area_select_one_option",
            "image_label_area_select_multiple_options",
            "image_label_area_adjust"
        ])
    # if taskdata is directly provided
    taskdata = ListType(ModelType(TaskData))  # ListType(DictType(StringType))

    # if taskdata is separately stored
    taskdata_uri = URLType()

    def validate_taskdata_uri(self, data, value):
        if data.get('taskdata') and len(
                data.get('taskdata')) > 0 and data.get('taskdata_uri'):
            raise ValidationError(
                u'Specify only one of taskdata {} or taskdata_uri {}'.format(
                    data.get('taskdata'), data.get('taskdata_uri')))
        return value

    validate_taskdata = validate_taskdata_uri
Пример #26
0
class RunnerCatalog(BetfairModel):
    selection_id = IntType(required=True)
    runner_name = StringType(required=True)
    handicap = FloatType(required=True)
    sort_priority = IntType(required=True)
    metadata = DictType(StringType)
Пример #27
0
class ElasticPoolPerDatabaseSettings(Model):
    max_capacity = FloatType(serialize_when_none=False)
    min_capacity = FloatType(serialize_when_none=False)
Пример #28
0
class CurrencyRate(BetfairModel):
    currency_code = StringType()
    rate = FloatType()
Пример #29
0
class FeatureValue(BaseFeatureValue):
    value = FloatType(required=True, min_value=0.0, max_value=0.25)
Пример #30
0
class MonthInvestorSituationModel(Model):
    date = StringType(required=True)
    unit = StringType(required=True)
    new_investor = FloatType(required=True)
    new_natural_person = FloatType(required=True)
    new_non_natural_person = FloatType(required=True)
    final_investor = FloatType(required=True)
    final_natural_person = FloatType(required=True)
    final_natural_a_person = FloatType(required=True)
    final_natural_b_person = FloatType(required=True)
    final_non_natural_person = FloatType(required=True)
    final_non_natural_a_person = FloatType(required=True)
    final_non_natural_b_person = FloatType(required=True)
    final_hold_investor = FloatType(required=True)
    final_a_hold_investor = FloatType(required=True)
    final_b_hold_investor = FloatType(required=True)
    trading_investor = FloatType(required=True)
    trading_a_investor = FloatType(required=True)
    trading_b_investor = FloatType(required=True)