コード例 #1
0
 def __init__(self,
              response=WithChallengeClientResponse,
              children=None,
              **kwargs):
     super().__init__(
         **kwargs,
         description=('The result of a challenge-blocked method.'
                      ' Contains information relevant to the open challenge'
                      ' needed to complete the method execution.'),
         response=response,
         children=merge(
             {
                 with_challenge_constants.CHALLENGE_COMPLETE:
                 Schema(
                     description=
                     'A flag indicating whether the challenge is complete',
                     types=types.BOOLEAN(),
                 ),
                 with_challenge_constants.OPEN_CHALLENGE_ID:
                 Schema(
                     description='The ID of the open challenge',
                     types=types.UUID(),
                 ),
             },
             children,
         ),
     )
コード例 #2
0
 def __init__(self, field, **kwargs):
     self.field = field
     super().__init__(**kwargs,
                      client=Schema(response=PropertyResponse),
                      children={
                          set_constants.NULL: Schema(types=types.BOOLEAN()),
                      })
コード例 #3
0
 def __init__(self, Model):
     self.model = Model
     super().__init__(
         origin=lock_constants.ORIGIN,
         response=AccountSuperadminLockResponse,
         children={
             lock_constants.LOCK: Schema(types=types.BOOLEAN()),
             lock_constants.ACCOUNT_ID: Schema(types=types.UUID()),
         },
     )
コード例 #4
0
 def __init__(self, Model, **kwargs):
   self.model = Model
   super().__init__(
     **kwargs,
     description=(
       'The schema for the TransactionMatch get method.'
       ' Basic filters are available for the ID and'
       ' active status of the TransactionMatch.'
     ),
     response=TransactionMatchGetResponse,
     children={
       get_constants.TRANSACTION_REPORT_ID: Schema(
         description='Filter by the ID of the parent TransactionReport.',
         types=types.UUID(),
       ),
       get_constants.TRANSACTION_REPORT_TARGET_ADDRESS: Schema(
         description='Filter by the target address of the parent TransactionReport.',
       ),
       get_constants.TRANSACTION_REPORT_IS_ACTIVE: Schema(
         description='Filter by the active status of the parent TransactionReport.',
         types=types.BOOLEAN(),
       ),
       get_constants.TRANSACTION_MATCH_ID: Schema(
         description=(
           'The ID of the TransactionMatch in question. This value'
           ' will override any filters applied.'
         ),
         types=types.UUID(),
       ),
       transaction_match_fields.IS_NEW: Schema(
         description=(
           'Filter by the new status of the TransactionMatch.'
         ),
         types=types.BOOLEAN(),
       ),
       transaction_match_fields.BLOCK_HASH: Schema(
         description='Filter by the block hash of the TransactionMatch.',
       ),
     },
   )
コード例 #5
0
 def __init__(self, Model, mode=None, **kwargs):
     self.model = Model
     super().__init__(
         **kwargs,
         response=PrototypeResponse,
         client=Schema(types=types.BOOLEAN()),
         children={
             schema_constants.ATTRIBUTES:
             AttributesSchema(Model, mode=mode),
             schema_constants.RELATIONSHIPS:
             RelationshipsSchema(Model, mode=mode),
         },
     )
コード例 #6
0
  def passes_pre_response_checks(self, payload):
    if self.active_response.active_type == types.BOOLEAN():
      return True

    values = payload.values()
    if any(values) and not all(values):
      self.active_response.add_error(model_schema_errors.UNIFORM_INCLUSIVE())
      return False

    if all(values):
      self.active_response.is_inclusive = True

    return super().passes_pre_response_checks(payload)
コード例 #7
0
 def __init__(self, Model):
     self.model = Model
     super().__init__(
         description=(
             'The schema for the TransactionReport create method.'),
         response=TransactionReportCreateResponse,
         origin=create_constants.ORIGIN,
         children={
             transaction_report_fields.IS_ACTIVE:
             Schema(
                 description=(
                     'Whether or not the report should be initially active.'
                 ),
                 types=types.BOOLEAN(),
             ),
             transaction_report_fields.TARGET_ADDRESS:
             Schema(
                 description=('The address to watch'),
                 types=types.STRING(),
             ),
             transaction_report_fields.VALUE_EQUAL_TO:
             Schema(
                 description=
                 ('A match will be recorded if the integer Satoshi amount'
                  ' of an output to the target address is equal to this value.'
                  ' WARNING: cannot be used in conjunction with the value_less_than'
                  ' or value_greater_than properties.'),
                 types=types.POSITIVE_INTEGER(),
             ),
             transaction_report_fields.VALUE_LESS_THAN:
             Schema(
                 description=
                 ('A match will be recorded if the integer Satoshi amount'
                  ' of an output to the target address is less than this value,'
                  ' depending on the value of the value_greater_than property.'
                  ' WARNING: cannot be used in conjunction with the value_equal_to'
                  ' property.'),
                 types=types.POSITIVE_INTEGER(),
             ),
             transaction_report_fields.VALUE_GREATER_THAN:
             Schema(
                 description=
                 ('A match will be recorded if the integer Satoshi amount'
                  ' of an output to the target address is greater than this value,'
                  ' depending on the value of the value_less_than property.'
                  ' WARNING: cannot be used in conjunction with the value_equal_to'
                  ' property.'),
                 types=types.POSITIVE_INTEGER(),
             ),
         },
     )
コード例 #8
0
 def __init__(self, Model, mode=None, **kwargs):
   self.model = Model
   self.mode = mode
   super().__init__(
     **kwargs,
     response=AttributeResponse,
     children={
       attribute.name: Schema(
         description='Attribute flag for {}'.format(attribute.name),
         types=types.BOOLEAN(),
       )
       for attribute in Model.objects.attributes(mode=mode)
     },
   )
コード例 #9
0
 def __init__(self, Model, mode=None, **kwargs):
     self.model = Model
     self.mode = mode
     super().__init__(
         **kwargs,
         response=RelationshipResponse,
         children={
             relationship.name: Schema(
                 description='',
                 types=types.BOOLEAN(),
             )
             for relationship in Model.objects.relationships(mode=mode)
         },
     )
コード例 #10
0
class RelationshipSchema(StructureSchema):
    default_types = force_array(StructureSchema.default_types) + [
        types.BOOLEAN(),
    ]

    def __init__(self, Model, mode=None, **kwargs):
        self.model = Model
        self.mode = mode
        super().__init__(
            **kwargs,
            response=RelationshipResponse,
            children={
                relationship.name: Schema(
                    description='',
                    types=types.BOOLEAN(),
                )
                for relationship in Model.objects.relationships(mode=mode)
            },
        )

    def get_available_errors(self):
        return set.union(
            super().get_available_errors(),
            {
                model_schema_errors.UNIFORM_INCLUSIVE(),
            },
        )

    def passes_pre_response_checks(self, payload):
        if self.active_response.active_type == types.BOOLEAN():
            return True

        values = payload.values()
        if any(values) and not all(values):
            self.active_response.add_error(
                model_schema_errors.UNIFORM_INCLUSIVE())
            return False

        if all(values):
            self.active_response.is_inclusive = True

        return super().passes_pre_response_checks(payload)

    def responds_to_valid_payload(self, payload, context):
        if self.active_response.active_type == types.BOOLEAN():
            self.active_response.should_include_attributes = payload
            return

        super().responds_to_valid_payload(payload, context)
コード例 #11
0
 def __init__(self,
              response=WithPaymentClientResponse,
              children=None,
              **kwargs):
     super().__init__(
         **kwargs,
         response=response,
         children=merge(
             {
                 with_payment_constants.PAYMENT_COMPLETE:
                 Schema(types=types.BOOLEAN()),
                 with_payment_constants.OPEN_PAYMENT_ID:
                 Schema(types=types.UUID()),
             },
             children,
         ),
     )
コード例 #12
0
 def __init__(self, Model):
     self.model = Model
     super().__init__(
         description=(
             'Schema for the Account lock method.'
             ' Once lock is set to true, the account will be unusable'
             ' until lock is set to false by calling this method again.'),
         response=AccountSubscribedLockResponse,
         origin=lock_constants.ORIGIN,
         children={
             lock_constants.LOCK:
             Schema(
                 description=(
                     'Value specifying the desired lock state of the account'
                 ),
                 types=types.BOOLEAN(),
             ),
         },
     )
コード例 #13
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         description=('The schema for the challenge result. Contains the'
                      ' outcome of the evaluation.'),
         children={
             respond_constants.CHALLENGE_ID:
             Schema(
                 description=
                 'The ID of the Challenge that is in the process of being verified',
                 types=types.UUID(),
             ),
             respond_constants.IS_VERIFIED:
             Schema(
                 description=
                 'A flag indicating whether the verification has been successful',
                 types=types.BOOLEAN(),
             ),
         },
     )
コード例 #14
0
 def __init__(self, **kwargs):
   super().__init__(
     **kwargs,
     description=(
       'The schema for the Payment get method.'
       ' It can be filtered by the open status of'
       ' the payment and the payment ID'
     ),
     response=PaymentGetResponse,
     children={
       get_constants.PAYMENT_ID: Schema(
         description='The payment ID',
         types=types.UUID(),
       ),
       payment_fields.IS_OPEN: Schema(
         description='The payment open status',
         types=types.BOOLEAN(),
       ),
     },
   )
コード例 #15
0
 def __init__(self, Model, **kwargs):
     self.model = Model
     super().__init__(
         **kwargs,
         description=('The schema for the FeeReport activate method.'),
         response=FeeReportActivateResponse,
         origin=activate_constants.ORIGIN,
         children={
             activate_constants.FEE_REPORT_ID:
             Schema(
                 description='The ID of the FeeReport is question.',
                 types=types.UUID(),
             ),
             fee_report_fields.IS_ACTIVE:
             Schema(
                 description=('A boolean value that designates whether'
                              ' the report should be active.'),
                 types=types.BOOLEAN(),
             ),
         },
     )
コード例 #16
0
 def __init__(self, Model, **kwargs):
     self.model = Model
     super().__init__(
         **kwargs,
         description=('The schema for the FeeReport get method.'
                      ' Basic filters are available for the ID and'
                      ' active status of the FeeReport.'),
         response=FeeReportGetResponse,
         children={
             get_constants.FEE_REPORT_ID:
             Schema(
                 description='The ID of the FeeReport in question.',
                 types=types.UUID(),
             ),
             fee_report_fields.IS_ACTIVE:
             Schema(
                 description='The active status of the FeeReport.',
                 types=types.BOOLEAN(),
             ),
         },
     )
コード例 #17
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         description=('The schema for the Subscription get method.'
                      ' Filters can be applied for the active status'
                      ' and the ID of the subscription.'),
         response=SubscriptionGetResponse,
         children={
             get_constants.SUBSCRIPTION_ID:
             Schema(
                 description=('The subscription ID'),
                 types=types.UUID(),
             ),
             subscription_fields.IS_ACTIVE:
             Schema(
                 description=
                 ('The subscription active status. If omitted, all subscriptions'
                  ' are returned.'),
                 types=types.BOOLEAN(),
             ),
         },
     )
コード例 #18
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         description=('The schema for the Challenge get method.'
                      ' Returns instances of the Challenge class and'
                      ' includes a simple filter for the open status'
                      ' of each object.'),
         response=ChallengeGetResponse,
         children={
             get_constants.CHALLENGE_ID:
             Schema(
                 description=('The challenge ID'),
                 types=types.UUID(),
             ),
             challenge_fields.IS_OPEN:
             Schema(
                 description=('Filter the list of challenges'
                              ' by their open states.'),
                 types=types.BOOLEAN(),
             ),
         },
     )
コード例 #19
0
 def __init__(self, Model, **kwargs):
     self.model = Model
     super().__init__(
         **kwargs,
         description=('The schema for the FeeReport create method.'),
         response=FeeReportCreateResponse,
         origin=create_constants.ORIGIN,
         children={
             fee_report_fields.BLOCKS_TO_INCLUDE:
             Schema(
                 description=
                 ('The number of blocks over which to calculate the average.'
                  ' Defaults to 1 if omitted.'),
                 types=types.INTEGER(),
             ),
             fee_report_fields.IS_ACTIVE:
             Schema(
                 description=(
                     'Whether or not the report should be initially active.'
                     ' Defaults to true if omitted.'),
                 types=types.BOOLEAN(),
             ),
         },
     )
コード例 #20
0
 def __init__(self, **kwargs):
   super().__init__(
     **kwargs,
     template=TemplateSchema(types=types.BOOLEAN()),
   )
コード例 #21
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         response=GetClientResponse,
         template=TemplateSchema(types=types.BOOLEAN()),
     )
コード例 #22
0
  def responds_to_valid_payload(self, payload, context):
    if self.active_response.active_type == types.BOOLEAN():
      self.active_response.should_include_attributes = payload
      return

    super().responds_to_valid_payload(payload, context)