How to use the predicthq.endpoints.schemas.DateTimeType function in predicthq

To help you get started, we’ve selected a few predicthq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github predicthq / sdk-py / tests / endpoints / test_schemas.py View on Github external
def test_datetime_type():

    class SchemaExample(schemas.Model):

        my_datetime = schemas.DateTimeType()

    test_date = datetime(2016, 1, 1, tzinfo=pytz.UTC)
    assert SchemaExample({"my_datetime": "2016-01-01T00:00:00+00:00"}).my_datetime == test_date
    assert SchemaExample({"my_datetime": "2016-01-01T00:00:00+0000"}).my_datetime == test_date
    assert SchemaExample({"my_datetime": "2016-01-01T00:00:00Z"}).my_datetime == test_date
    assert SchemaExample({"my_datetime": test_date}).my_datetime == test_date
github predicthq / sdk-py / predicthq / endpoints / v1 / events / schemas.py View on Github external
# `local_rank`, `aviation_rank`, and `phq_attendance` are paid features.
    # They will only show up in your response body if you
    # have subscribed to them.
    local_rank = IntType()
    aviation_rank = IntType()
    phq_attendance = IntType()

    entities = ListType(ModelType(Entities))
    location = GeoJSONPointType()
    place_hierarchies = ListType(ListType(StringType()))
    scope = StringType()
    relevance = FloatType()
    state = StringType()
    first_seen = DateTimeType()
    updated = DateTimeType()
    deleted_reason = StringType()
    duplicate_of_id = StringType()


class EventResultSet(ResultSet):

    overflow = BooleanType()

    results = ResultType(Event)


class CountResultSet(Model):

    count = IntType()
    top_rank = FloatType()
    rank_levels = DictType(IntType)
github predicthq / sdk-py / predicthq / endpoints / schemas.py View on Github external
serialize_when_none = False

    origin = StringType(regex='(-?\d+(\.\d+)?),(-?\d+(\.\d+)?)', required=True)
    offset = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
    scale = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
    decay = FloatType()


class DateTimeRange(Model):

    class Options:
        serialize_when_none = False

    gt = DateTimeType()
    gte = DateTimeType()
    lt = DateTimeType()
    lte = DateTimeType()
    tz = StringType(choices=pytz.all_timezones)


class FloatRange(Model):

    class Options:
        serialize_when_none = False

    gt = FloatType()
    gte = FloatType()
    lt = FloatType()
    lte = FloatType()


class IntRange(Model):
github predicthq / sdk-py / predicthq / endpoints / v1 / signals / schemas.py View on Github external
class Options(Signal.Options):
        pass


class SignalResultSet(ResultSet):

    results = ResultType(SavedSignal)


class DataPoint(Model):

    uid = StringType(required=True)
    date = DateTimeType(required=True)
    latitude = FloatType(min_value=-90, max_value=90, required=True)
    longitude = FloatType(min_value=-180, max_value=180, required=True)
    initiated = DateTimeType()
    completed = DateTimeType()
    # @todo: Support custom dimensions from signal


class SignalDataPoints(Model):

    id = StringType(required=True)
    data_points = ListType(ModelType(DataPoint), required=True)
    chunk_size = IntType(default=1000, max_value=5000, required=True)


class DateDimension(Model):

    type = StringType()
    count = IntType()
    min = DateTimeType()
github predicthq / sdk-py / predicthq / endpoints / v1 / signals / schemas.py View on Github external
pass


class SignalResultSet(ResultSet):

    results = ResultType(SavedSignal)


class DataPoint(Model):

    uid = StringType(required=True)
    date = DateTimeType(required=True)
    latitude = FloatType(min_value=-90, max_value=90, required=True)
    longitude = FloatType(min_value=-180, max_value=180, required=True)
    initiated = DateTimeType()
    completed = DateTimeType()
    # @todo: Support custom dimensions from signal


class SignalDataPoints(Model):

    id = StringType(required=True)
    data_points = ListType(ModelType(DataPoint), required=True)
    chunk_size = IntType(default=1000, max_value=5000, required=True)


class DateDimension(Model):

    type = StringType()
    count = IntType()
    min = DateTimeType()
    max = DateTimeType()
github predicthq / sdk-py / predicthq / endpoints / v1 / accounts / schemas.py View on Github external
from predicthq.endpoints.schemas import Model, StringType, DateTimeType, ModelType


class Industry(Model):

    id = StringType()
    name = StringType()


class Account(Model):

    id = StringType()
    name = StringType()
    description = StringType()
    industry = ModelType(Industry)
    created_at = DateTimeType()
    updated_at = DateTimeType()
github predicthq / sdk-py / predicthq / endpoints / schemas.py View on Github external
origin = StringType(regex='(-?\d+(\.\d+)?),(-?\d+(\.\d+)?)', required=True)
    offset = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
    scale = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
    decay = FloatType()


class DateTimeRange(Model):

    class Options:
        serialize_when_none = False

    gt = DateTimeType()
    gte = DateTimeType()
    lt = DateTimeType()
    lte = DateTimeType()
    tz = StringType(choices=pytz.all_timezones)


class FloatRange(Model):

    class Options:
        serialize_when_none = False

    gt = FloatType()
    gte = FloatType()
    lt = FloatType()
    lte = FloatType()


class IntRange(Model):
github predicthq / sdk-py / predicthq / endpoints / schemas.py View on Github external
class Options:
        serialize_when_none = False

    origin = StringType(regex='(-?\d+(\.\d+)?),(-?\d+(\.\d+)?)', required=True)
    offset = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
    scale = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
    decay = FloatType()


class DateTimeRange(Model):

    class Options:
        serialize_when_none = False

    gt = DateTimeType()
    gte = DateTimeType()
    lt = DateTimeType()
    lte = DateTimeType()
    tz = StringType(choices=pytz.all_timezones)


class FloatRange(Model):

    class Options:
        serialize_when_none = False

    gt = FloatType()
    gte = FloatType()
    lt = FloatType()
    lte = FloatType()
github predicthq / sdk-py / predicthq / endpoints / schemas.py View on Github external
class Options:
        serialize_when_none = False

    scope = ListType(StringType)
    exact = ListType(StringType)


class Signal(Model):

    class Options:
        serialize_when_none = False

    id = StringType(required=True)
    analysis_from = DateTimeType()
    analysis_to = DateTimeType()
    analysis_tz = StringType(choices=pytz.all_timezones)
    significance = FloatType(min_value=0, max_value=100)
    metric = StringType(choices=('demand', 'lead', 'span'))
    explain = DateType()


class DateAround(Model):

    class Options:
        serialize_when_none = False

    origin = DateType(required=True)
    offset = StringType(regex='\d+d')
    scale = StringType(regex='\d+d')
    decay = FloatType()