Exemplo n.º 1
0
Arquivo: defs.py Projeto: ofw/pong
class UpdateItemIn(Model):

    tz_offset = t.IntType(required=True)
    uid = t.StringType(required=True)
    what = t.StringType(required=True, max_length=255)
    when = t.DateTimeType(required=True)
Exemplo n.º 2
0
class Thumbnail(models.Model):
    url = types.URLType(required=True, metadata=dict(description=""))
    width = types.IntType(required=True, metadata=dict(description=""))
    height = types.IntType(required=True, metadata=dict(description=""))
Exemplo n.º 3
0
class Media(models.Model):
    """ Wrapper for Wistia Media results """

    id = types.IntType(
        required=True,
        metadata=dict(
            description="A unique numeric identifier for the media within the system."
        ),
    )
    name = types.StringType(
        required=True, metadata=dict(description="The display name of the media.")
    )
    hashed_id = types.StringType(
        required=True,
        metadata=dict(description="A unique alphanumeric identifier for this media."),
    )
    description = types.StringType(
        required=True,
        metadata=dict(
            description=(
                "A description for the media which usually appears near the top of the"
                "sidebar on the media’s page"
            )
        ),
    )
    project = types.ModelType(
        ProjectReference,
        required=False,
        metadata=dict(
            description="Information about the project in which the media resides"
        ),
    )
    type = types.StringType(
        required=True,
        metadata=dict(description="A string representing what type of media this is"),
        choices=[
            "Video",
            "Image",
            "Audio",
            "Swf",
            "MicrosoftOfficeDocument",
            "PdfDocument",
            "UnknownType",
        ],
    )
    status = types.StringType(
        required=True,
        default="ready",
        metadata=dict(description="Post upload processing status"),
        choices=["queued", "processing", "ready", "failed"],
    )
    progress = types.FloatType(
        required=False,
        default=1.0,
        metadata=dict(
            description=(
                "(optional) After a file has been uploaded to Wistia, it needs to be"
                "processed before it is available for online viewing. This field is"
                "a floating point value between 0 and 1 that indicates the progress of"
                "that processing."
            )
        ),
    )
    section = types.StringType(
        required=False,
        serialize_when_none=False,
        metadata=dict(
            description=(
                "(optional) The title of the section in which the media appears."
                "This attribute is omitted if the media is not in a section (default)."
            )
        ),
    )
    thumbnail = types.ModelType(
        Thumbnail,
        required=True,
        metadata=dict(
            description="An object representing the thumbnail for this media"
        ),
    )
    duration = types.FloatType(
        required=False,
        metadata=dict(
            description=(
                "(optional) For Audio or Video files, this field specifies the length"
                "(in seconds). For Document files, this field specifies the number of"
                "pages in the document. For other types of media, or if the duration"
                "is unknown, this field is omitted."
            )
        ),
    )
    created = types.DateTimeType(
        required=True,
        serialized_format=DATETIME_FORMAT,
        metadata=dict(description="The date when the media was originally uploaded."),
    )
    updated = types.DateTimeType(
        required=True,
        serialized_format=DATETIME_FORMAT,
        metadata=dict(description="The date when the media was last changed."),
    )
    assets = types.ListType(
        types.ModelType(Asset),
        required=False,
        metadata=dict(description="An array of the assets available for this media"),
    )
    embed_code = types.StringType(
        serialized_name="embedCode",
        required=False,
        metadata=dict(
            description=r"""
            DEPRECATED
            The HTML code that would be used for embedding the media into a web page.
            Please note that in JSON format, all quotes are escaped with a
            backslash (\) character. In XML, angle brackets (< and >) and
            ampersands (&) are converted to their equivalent XML entities
            ("&lt;", "&gt;", and "&amp;" respectively) to prevent XML parser errors.
            """
        ),
    )
Exemplo n.º 4
0
 class params(Model):
     # Request's GET parameters validation
     sort = types.StringType(default='asc', choices=('asc', 'desc'))
     page = types.IntType(default=1, min_value=1)
Exemplo n.º 5
0
class ProjectReference(models.Model):
    id = types.IntType(required=True, metadata=dict(description=""))
    name = types.StringType(required=True, metadata=dict(description=""))
    hashed_id = types.StringType(required=True, metadata=dict(description=""))
Exemplo n.º 6
0
class Task(models.Model):
    '''
        Task Object Data Structure
    '''
    uuid = types.UUIDType(default=uuid.uuid4)

    title = types.StringType()

    first_name = types.StringType()
    last_name = types.StringType()
    description = types.StringType()
    
    label = types.StringType()
    
    category = types.StringType()

    email = types.StringType()
    
    account = types.StringType()
    accountcode = types.StringType()
    userfield = types.StringType()
    
    assigned = types.BooleanType(default=False)
    checked = types.BooleanType(default=False)

    public = types.BooleanType(default=False)

    source = types.StringType()
    destination = types.StringType()
    
    channel = types.StringType()
    source_channel = types.StringType()
    
    context = types.StringType()
    
    destination_context = types.StringType()

    destination_number = types.StringType()
   
    destination_channel = types.StringType()
    
    start = types.DateTimeType()
    answer = types.DateTimeType()
    end = types.DateTimeType()

    duration = types.IntType()
    billsec = types.IntType()
    billing = types.IntType()
    rate = types.IntType()

    disposition = types.StringType()
    status = types.StringType(choices=['now',
                                       'later',
                                       'done'],
                              default='now',
                              required=True)
    
    priority = types.StringType(choices=['small',
                                       'medium',
                                       'hight'],
                              default='small',
                              required=True)
    
    severity = types.StringType(choices=['info',
                                       'warning',
                                       'error'],
                              default='info',
                              required=True)

    checked = types.BooleanType(default=False)
    checked_by = types.StringType()
    
    created = types.DateTimeType(default=arrow.utcnow().naive)
    created_at = types.DateTimeType(default=arrow.utcnow().naive)

    comments = compound.ModelType(Comment)

    last_modified = types.DateTimeType()
    updated_by = types.StringType()
    updated_at = types.DateTimeType()

    uri = types.StringType()
Exemplo n.º 7
0
class ModelB(optplan.ProblemGraphNode.Schema):
    type = types.StringType(default="ModelB")
    int_field = types.IntType()
Exemplo n.º 8
0
class OutputUser(InputUser):
    user_id = types.IntType()
Exemplo n.º 9
0
class SanicError(Model):
    success: types.BooleanType()
    result: types.StringType()
    code: types.IntType()
Exemplo n.º 10
0
class BotProperty(BaseModel):
    name = types.StringType()
    description = types.StringType(serialize_when_none=False)
    intents = types.ListType(types.ModelType(BotIntentProperty),
                             serialize_when_none=False,
                             default=[])
    """ :type : BotIntentProperty"""
    clarificationPrompt = types.ModelType(PromptProperty,
                                          serialize_when_none=False,
                                          default=PromptProperty())
    """ :type : PromptProperty"""
    abortStatement = types.ModelType(StatmentProperty,
                                     serialize_when_none=False,
                                     default=StatmentProperty())
    """ :type : StatmentProperty"""
    idleSessionTTLInSeconds = types.IntType(serialize_when_none=False)
    voiceId = types.StringType(default='Joanna')
    checksum = types.StringType(serialize_when_none=False)
    version = types.StringType(serialize_when_none=False)
    processBehavior = types.StringType(default="BUILD")
    locale = types.StringType(default='en-US')
    childDirected = types.BooleanType()

    class IntentMeta:
        intents = []
        """ :type: list[IntentProperty] """
        existing_intents = []

    def create_all_intents(self, lambda_arn):
        for intent in self.IntentMeta.intents:
            if intent.is_lambda():
                intent.update_uri(lambda_arn)
            intent.create()

    def add_all_intents(self):
        for intent in self.get_all_intents():
            self.add_intent(intent.name, intent.version)

    def get_all_intents(self):
        all_intents = self.IntentMeta.intents + self.IntentMeta.existing_intents
        return all_intents

    def add_intent(self, name, version):
        intent = BotIntentProperty()
        intent.intentName = name
        intent.intentVersion = version
        self.intents.append(intent)
        return self

    @classmethod
    def wait_for_bot_build(cls, bot_name, version_name):
        build_status = 'BUILDING'
        response = {}
        while build_status == 'BUILDING':
            time.sleep(1)
            response = lex_model.get_bot(name=bot_name,
                                         versionOrAlias=version_name)
            logging.debug("get_bot: {}".format(pformat(response)))
            build_status = response.get('status')

        if build_status == 'FAILED' or build_status == 'NOT_BUILT':
            raise Exception(
                "Couldn't build {}. build_status: {}. failureReason: {}".
                format(bot_name, build_status, response.get('failureReason')))
        return response

    def delete_bot(self):
        raise NotImplementedError()

    @classmethod
    def get_bot_alias_checksum(cls, bot_name, alias_name):
        checksum = None
        try:
            response = lex_model.get_bot_alias(name=alias_name,
                                               botName=bot_name)
            logging.info("get_bot_alias: {}".format(pformat(response)))
            checksum = response.get('checksum')
        except ClientError as e:
            if e.response['Error']['Code'] != 'NotFoundException':
                raise

        return checksum

    @classmethod
    def get_bot_checksum(cls, bot_name, versionOrAlias):
        checksum = None
        try:
            response = lex_model.get_bot(name=bot_name,
                                         versionOrAlias=versionOrAlias)
            logging.info("get_bot: {}".format(pformat(response)))
            checksum = response.get('checksum')
        except ClientError as e:
            if e.response['Error']['Code'] != 'NotFoundException':
                raise
        return checksum

    def create_alias(self, version, alias='prod'):
        checksum = self.get_bot_alias_checksum(self.name, alias)
        kwargs = utils.get_kwargs(checksum)
        response = lex_model.put_bot_alias(name=alias,
                                           botVersion=version,
                                           botName=self.name,
                                           **kwargs)
        logging.info("put_bot_alias: {}".format(pformat(response)))

    def create(self, async=False):
        lambda_arn = self.deploy_cloudformation()
        self.create_all_intents(lambda_arn)
        self.add_all_intents()
        logging.info("Creating bot: {}".format(self.name))
        # Get the old bot checksum if available
        self.checksum = self.get_bot_checksum(self.name, '$LATEST')

        kwargs = self.to_primitive()
        # Build/Update the bot
        response = lex_model.put_bot(**kwargs)
        self.version = response.get('version')
        logging.info("put_bot: {}".format(pformat(response)))
        self.checksum = response.get('checksum')
        try:
            version_response = lex_model.create_bot_version(
                name=self.name, checksum=self.checksum)
            logging.info("create_bot_version: {}".format(pformat(response)))
            self.version = version_response.get('version')
            self.checksum = version_response.get('checksum')
        except ClientError as e:
            logging.warning("Failed to create Bot Version", exc_info=1)

        if not async:
            self.wait_for_bot_build(self.name, self.version)
            self.create_alias('$LATEST', 'dev')
            self.create_alias(self.version, 'prod')
Exemplo n.º 11
0
class InputUser(Model):
    age = types.IntType(min_value=0, max_value=99)
    name = types.StringType(required=True)
    phone = types.StringType()
Exemplo n.º 12
0
class ProjectionSchematic(models.Model):
    system = types.StringType()
    season = types.IntType()
    batting = types.compound.ModelType(ProjectionLine)
    pitching = types.compound.ModelType(ProjectionLine)
Exemplo n.º 13
0
class MutedMember(MongoModel):
    guild_id = types.IntType(required=True)
    user_id = types.IntType(required=True)
    start_time = types.DateTimeType()
    end_time = types.DateTimeType(required=True)
    duration = types.IntType()
Exemplo n.º 14
0
 class headers(Model):
     # Validate and set a default returned header
     x_response = types.IntType(serialized_name='x-response', default=5)
Exemplo n.º 15
0
 class Schema:
     foo = types.StringType(required=True)
     bar = types.StringType(required=True)
     baz = types.StringType(required=True)
     count = types.IntType()
     child = compound.DictType(types.StringType)
Exemplo n.º 16
0
class User(Model):
    user_id = types.IntType()
    age = types.IntType(min_value=0, max_value=99)
    name = types.StringType(required=True)
    phone = types.StringType()
Exemplo n.º 17
0
class CampaignQueue(models.Model):
    '''
        Campaign queue
    '''
    uuid = types.UUIDType(default=uuid.uuid4)
    name = types.StringType(required=True)

    musiconhold = types.StringType(default='default')
    announce = types.StringType()
    context = types.StringType()
    timeout = types.IntType(default=15)

    monitor_join = types.IntType(default=1)
    monitor_format = types.StringType(default='wav')

    queue_youarenext = types.StringType(default='queue-youarenext')
    queue_thereare = types.StringType()
    queue_callswaiting = types.StringType()
    queue_holdtime = types.StringType()
    queue_minutes = types.StringType()
    queue_seconds = types.StringType()
    queue_lessthan = types.StringType(default='queue-less-than')
    queue_thankyou = types.StringType(default='queue-thankyou')
    queue_reporthold = types.StringType(default='queue-reporthold')

    announce_frequency = types.IntType()
    announce_round_seconds = types.IntType(default=10)
    announce_holdtime = types.StringType(default='yes')

    retry = types.IntType(default=5)
    wrapuptime = types.IntType()
    maxlen = types.IntType()
    servicelevel = types.IntType()
    strategy = types.StringType(choices=[
        'ringall', 'leastrecent', 'fewestcalls', 'random', 'rrmemory',
        'linear', 'wrandom'
    ],
                                required=True)

    joinempty = types.StringType(default='yes')
    leavewhenempty = types.StringType()

    eventmemberstatus = types.IntType(default=1)
    eventwhencalled = types.IntType(default=1)
    reportholdtime = types.IntType(default=1)
    memberdelay = types.IntType()
    weight = types.IntType()
    timeoutrestart = types.IntType()

    periodic_announce = types.StringType()
    periodic_announce_frequency = types.IntType()

    ringinuse = types.IntType(default=0)
    setinterfacevar = types.IntType(default=1)
Exemplo n.º 18
0
class ModifyContact(models.Model):
    '''
        Modify contact

        This model is similar to Contact.

        It lacks of require and default values on it's fields.

        The reason of it existence is that we need to validate
        every input data that came from outside the system, with 
        this we prevent users from using PATCH to create fields 
        outside the scope of the resource.
    '''
    uuid = types.UUIDType()
    account = types.StringType()
    tags = compound.ListType(types.StringType())
    number_type = types.IntType()
    first_name = types.StringType()
    last_name = types.StringType()
    phone_number = types.StringType()
    phone = types.StringType()
    cell_phone = types.StringType()
    other_phone = types.StringType()
    number_type = types.IntType()
    description = types.StringType()
    country = types.StringType()
    location = types.StringType()
    timezone = types.StringType()
    comment = types.StringType()
    tags = types.StringType()
    status = types.StringType()
    email = types.EmailType()
    client_email = types.StringType()
    address = types.StringType()
    city = types.StringType()
    state = types.StringType()
    zip_code = types.StringType()
    dog = types.StringType()
    pool = types.StringType()
    date_of_birth = types.StringType()
    checked = types.BooleanType()
    do_not_disturb = types.BooleanType()
    has_directory = types.BooleanType()
    directory_uuid = types.UUIDType()
    # -- godzilla nigthmare start in 3, 2, 1...
    gender = types.StringType()
    auto_priority_code = types.StringType()
    lead_source = types.StringType()
    writing_agent = types.StringType()
    partner = types.StringType()
    healt_writing_agent = types.StringType()
    lead_type = types.StringType()
    healt_lead_status = types.StringType()
    renewal_source_2016 = types.StringType()
    renewal_agent_2016 = types.StringType()
    home_lead_status = types.StringType()
    renewal_submitter_2016 = types.StringType()
    auto_lead_status = types.StringType()
    presold_processor_2016 = types.StringType()
    flood_lead_status = types.StringType()
    scrubber = types.StringType()
    other_policy_sold = types.StringType()
    last_modified_by = types.StringType()
    dental_lead_status = types.StringType()
    federal_do_not_call = types.StringType()
    do_you_own_your_home = types.StringType()
    renew_as_is_email_received = types.StringType()
    language_preference = types.StringType()
    social_security_number = types.StringType()
    us_citizen_or_legal_permanent_resident = types.StringType()
    mailing_address = types.StringType()
    property_address_different = types.StringType()
    county = types.StringType()
    marketplace_email = types.StringType()
    property_address = types.StringType()
    property_city = types.StringType()
    property_state = types.StringType()
    property_zip_code = types.StringType()
    total_individual_income = types.StringType()
    total_household_income = types.StringType()
    primary_applicants_income_source = types.StringType()
    primary_applicants_employers_name = types.StringType()
    applicant_employers_phone_number = types.StringType()
    marital_status = types.StringType()
    number_of_dependent_children_in_house = types.StringType()
    spouse_first_name = types.StringType()
    spouse_last_name = types.StringType()
    spouse_gender = types.StringType()
    spouse_dob = types.StringType()
    do_you_have_a_social_security_number = types.StringType()
    spouse_social = types.StringType()
    spouse_yearly_income = types.StringType()
    spouse_employers_name = types.StringType()
    spouse_employers_phone_number = types.StringType()
    child_1_name = types.StringType()
    child_1_dob = types.StringType()
    child_1_gender = types.StringType()
    child_1_social = types.StringType()
    child_2_name = types.StringType()
    child_2_dob = types.StringType()
    child_2_gender = types.StringType()
    child_2_social = types.StringType()
    child_3_name = types.StringType()
    child_3_dob = types.StringType()
    child_3_gender = types.StringType()
    child_3_social = types.StringType()
    child_4_name = types.StringType()
    child_4_dob = types.StringType()
    child_4_gender = types.StringType()
    child_4_social = types.StringType()
    lead_has_a_marketplace_account = types.StringType()
    current_coverage = types.StringType()
    marketplace_2015_app_id = types.StringType()
    current_premium = types.StringType()
    subsidy_amount = types.StringType()
    current_net_premium = types.StringType()
    effective_2015_date = types.StringType()
    application_id_2015 = types.StringType()
    health_premium_2015 = types.StringType()
    health_carrier_2015 = types.StringType()
    subsidy_2015 = types.StringType()
    adult_on_plan_2015 = types.StringType()
    children_on_plan_2015 = types.StringType()
    income_verification_needed = types.StringType()
    citizenship_documents_needed = types.StringType()
    health_policy = types.StringType()
    agent_code = types.StringType()
    wants_to_renew_same_plan_for_2016 = types.StringType()
    quoted_renewal_gross_premium_2016 = types.StringType()
    quoted_renewal_subsidy_2016 = types.StringType()
    quoted_renewal_net_premium_2016 = types.StringType()
    adults_applying_for_coverage_2016 = types.StringType()
    total_household_size_2016 = types.StringType()
    cloud_gross_premium_2016 = types.StringType()
    children_applying_for_coverage_2016 = types.StringType()
    cloud_subsidy_2016 = types.StringType()
    cloud_premium_after_subsidy_2016 = types.StringType()
    binder_payment_option_2016 = types.StringType()
    payment_charge_request_date = types.StringType()
    credit_card_type_2016 = types.StringType()
    name_on_cc_2016 = types.StringType()
    credit_card_type_2016 = types.StringType()
    name_on_cc_2016 = types.StringType()
    credit_card_number_2016 = types.StringType()
    cc_expiration_date_2016 = types.StringType()
    cc_cvv_2016 = types.StringType()
    bank_account_type_2016 = types.StringType()
    bank_name_2016 = types.StringType()
    bank_routin_number_2016 = types.StringType()
    bank_account_number_2016 = types.StringType()
    application_number_2016 = types.StringType()
    effective_date_2016 = types.StringType()
    marketplace_policy_2016 = types.StringType()
    total_income_used_on_application = types.StringType()
    final_gross_premium_2016 = types.StringType()
    final_subsidy_2016 = types.StringType()
    heatlh_plan_2016 = types.StringType()
    final_premium_after_subsidy_2016 = types.StringType()
    verification_documents_needed_2016 = types.StringType()
    new_purchase = types.StringType()
    home_exp_date_closing_date = types.StringType()
    occupancy_status = types.StringType()
    type_of_dwelling = types.StringType()
    current_home_carrier = types.StringType()
    current_home_premium = types.StringType()
    current_dwelling_coverage = types.StringType()
    year_built = types.StringType()
    square_ft_under_air = types.StringType()
    garage = types.StringType()
    construction_type = types.StringType()
    stories = types.StringType()
    age_roof = types.StringType()
    roof_material = types.StringType()
    bathrooms = types.StringType()
    fence_or_screen_enclosure = types.StringType()
    bankrupcy_or_foreclosure_in_the_past_5_years = types.StringType()
    centrally_monitored_alarm = types.StringType()
    gated_community = types.StringType()
    how_many_claims_in_the_last_5_years = types.StringType()
    realtor_mortgage_broker = types.StringType()
    amount_of_personal_property = types.StringType()
    number_of_stories_in_the_building = types.StringType()
    what_floor_is_condo_on = types.StringType()
    quote_update_request = types.StringType()
    home_policy_effective_date = types.StringType()
    four_point_if_applicable = types.StringType()
    quoted_home_company = types.StringType()
    wind_mit = types.StringType()
    quoted_home_premium = types.StringType()
    quoted_home_number = types.StringType()
    home_payment_option = types.StringType()
    mortgage_clause_new = types.StringType()
    loan_number = types.StringType()
    home_insurance_carrier = types.StringType()
    home_insurance_premium = types.StringType()
    home_insurance_policy_number = types.StringType()
Exemplo n.º 19
0
class ModelA(optplan.ProblemGraphNode.Schema):
    type = types.StringType(default="ModelA")
    int_field = types.IntType()
    string_field = types.StringType()
    ref_field = optplan.ReferenceType(optplan.ProblemGraphNode.Schema)
    ref_field2 = optplan.ReferenceType(optplan.ProblemGraphNode.Schema)
Exemplo n.º 20
0
class Project(models.Model):
    """Wrapper for project results."""

    id = types.IntType(
        required=True,
        metadata=dict(
            description="A unique numeric identifier for the project within the system."
        ),
    )
    name = types.StringType(
        required=True, metadata=dict(description="The project's display name.")
    )
    hashed_id = types.StringType(
        required=True,
        metadata=dict(
            description=(
                "A private hashed id, uniquely identifying the project within the"
                "system. Used for playlists and RSS feeds"
            )
        ),
    )
    media_count = types.IntType(
        required=True,
        default=0,
        serialized_name="mediaCount",
        metadata=dict(
            description="The number of different medias that have been uploaded to the project."
        ),
    )
    created = types.DateTimeType(
        required=True,
        serialized_format=DATETIME_FORMAT,
        metadata=dict(description="The date that the project was originally created."),
    )
    updated = types.DateTimeType(
        required=True,
        serialized_format=DATETIME_FORMAT,
        metadata=dict(description="The date that the project was last updated"),
    )
    anonymous_can_upload = types.BooleanType(
        required=True,
        serialized_name="anonymousCanUpload",
        metadata=dict(
            description=(
                "A boolean indicating whether or not anonymous uploads are enabled for the project"
            )
        ),
    )
    anonymous_can_download = types.BooleanType(
        required=True,
        serialized_name="anonymousCanDownload",
        metadata=dict(
            description=(
                "A boolean indicating whether or not anonymous downloads are enabled for this project"
            )
        ),
    )
    public = types.BooleanType(
        required=True,
        metadata=dict(
            description=(
                "A boolean indicating whether the project is available for public (anonymous) viewing"
            )
        ),
    )
    public_id = types.StringType(
        required=False,
        serialized_name="publicId",
        metadata=dict(
            description=(
                "If the project is public, this field contains a string representing the "
                "ID used for referencing the project in public URLs"
            )
        ),
    )
    medias = types.ListType(
        types.ModelType(Media),
        required=False,  # Not present in lists of Projects
        serialize_when_none=False,
        metadata=dict(description="A list of the media associated with a project"),
    )
Exemplo n.º 21
0
class UserById(Model):
    user_id = types.IntType(required=True)
Exemplo n.º 22
0
 class params(Model):
     t1 = types.IntType()