Example #1
0
    def __init__(self):
        ResourceUri.__init__(
            self, output_type_serializer=api.EquipmentReportsSerializer)
        ResourceUtc.__init__(self)
        parser_get = self.parsers["get"]
        parser_get.add_argument("depth",
                                type=DepthArgument(),
                                default=1,
                                help="The depth of your object")
        parser_get.add_argument("count",
                                type=default_count_arg_type,
                                default=25,
                                help="Number of objects per page")
        parser_get.add_argument("filter",
                                type=six.text_type,
                                default="",
                                help="Filter your objects")
        parser_get.add_argument("start_page",
                                type=int,
                                default=0,
                                help="The current page")
        parser_get.add_argument(
            "forbidden_uris[]",
            type=six.text_type,
            help="forbidden uris",
            dest="forbidden_uris[]",
            default=[],
            action="append",
            schema_metadata={'format': 'pt-object'},
        )

        self.collection = 'equipment_reports'
        self.get_decorators.insert(0, ManageError())
        self.get_decorators.insert(1, get_obj_serializer(self))
Example #2
0
    def __init__(self, endpoint, *args, **kwargs):
        ResourceUri.__init__(self, *args, **kwargs)
        ResourceUtc.__init__(self)
        self.endpoint = endpoint
        self.parsers["get"] = reqparse.RequestParser(argument_class=ArgumentDoc)
        parser_get = self.parsers["get"]
        parser_get.add_argument("filter", type=six.text_type)
        parser_get.add_argument("from_datetime", type=DateTimeFormat(), default=None,
                                help="The datetime from which you want the schedules")
        parser_get.add_argument("until_datetime", type=DateTimeFormat(), default=None,
                                help="The datetime until which you want the schedules")
        parser_get.add_argument("duration", type=int, default=3600 * 24,
                                help="Maximum duration between datetime and the retrieved stop time")
        parser_get.add_argument("depth", type=depth_argument, default=2)
        parser_get.add_argument("count", type=default_count_arg_type, default=10,
                                help="Number of schedules per page")
        parser_get.add_argument("start_page", type=int, default=0,
                                help="The current page")
        parser_get.add_argument("max_date_times", type=UnsignedInteger(), deprecated=True,
                                help="DEPRECATED, replaced by `items_per_schedule`")
        parser_get.add_argument("forbidden_id[]", type=six.text_type, deprecated=True,
                                help="DEPRECATED, replaced by `forbidden_uris[]`",
                                dest="__temporary_forbidden_id[]",
                                default=[],
                                action='append',
                                schema_metadata={'format': 'pt-object'})
        parser_get.add_argument("forbidden_uris[]", type=six.text_type,
                                help="forbidden uris",
                                dest="forbidden_uris[]",
                                default=[],
                                action='append',
                                schema_metadata={'format': 'pt-object'})
        parser_get.add_argument("calendar", type=six.text_type,
                                help="Id of the calendar")
        parser_get.add_argument("distance", type=int, default=200,
                                help="Distance range of the query. Used only if a coord is in the query")
        parser_get.add_argument("show_codes", type=BooleanType(), default=False,
                                help="show more identification codes")
        #Note: no default param for data freshness, the default depends on the API
        parser_get.add_argument("data_freshness",
                                help='freshness of the data. '
                                     'base_schedule is the long term planned schedule. '
                                     'adapted_schedule is for planned ahead disruptions (strikes, '
                                     'maintenances, ...). '
                                     'realtime is to have the freshest possible data',
                                type=OptionValue(['base_schedule', 'adapted_schedule', 'realtime']))
        parser_get.add_argument("_current_datetime", type=DateTimeFormat(),
                                schema_metadata={'default': 'now'}, hidden=True,
                                default=datetime.utcnow(),
                                help='The datetime considered as "now". Used for debug, default is '
                                     'the moment of the request. It will mainly change the output '
                                     'of the disruptions.')
        parser_get.add_argument("items_per_schedule", type=UnsignedInteger(), default=10000,
                                help="maximum number of date_times per schedule")
        parser_get.add_argument("disable_geojson", type=BooleanType(), default=False,
                                help="remove geojson from the response")

        self.get_decorators.insert(0, ManageError())
        self.get_decorators.insert(1, get_obj_serializer(self))
        self.get_decorators.append(complete_links(self))
Example #3
0
 def __init__(self):
     ResourceUri.__init__(self,
                          output_type_serializer=api.CalendarsSerializer)
     parser_get = self.parsers["get"]
     parser_get.add_argument("depth",
                             type=depth_argument,
                             default=1,
                             help="The depth of your object")
     parser_get.add_argument("count",
                             type=default_count_arg_type,
                             default=10,
                             help="Number of calendars per page")
     parser_get.add_argument("start_page",
                             type=int,
                             default=0,
                             help="The current page")
     parser_get.add_argument("start_date",
                             type=six.text_type,
                             default="",
                             help="Start date")
     parser_get.add_argument("end_date",
                             type=six.text_type,
                             default="",
                             help="End date")
     parser_get.add_argument(
         "forbidden_id[]",
         type=six.text_type,
         deprecated=True,
         help="DEPRECATED, replaced by `forbidden_uris[]`",
         dest="__temporary_forbidden_id[]",
         default=[],
         action='append',
         schema_metadata={'format': 'pt-object'})
     parser_get.add_argument("forbidden_uris[]",
                             type=six.text_type,
                             help="forbidden uris",
                             dest="forbidden_uris[]",
                             default=[],
                             action="append",
                             schema_metadata={'format': 'pt-object'})
     parser_get.add_argument(
         "distance",
         type=int,
         default=200,
         help=
         "Distance range of the query. Used only if a coord is in the query"
     )
     parser_get.add_argument(
         "_current_datetime",
         type=DateTimeFormat(),
         schema_metadata={'default': 'now'},
         hidden=True,
         default=datetime.utcnow(),
         help='The datetime considered as "now". Used for debug, default is '
         'the moment of the request. It will mainly change the output '
         'of the disruptions.')
     self.collection = 'calendars'
     self.collections = calendars
     self.get_decorators.insert(0, ManageError())
     self.get_decorators.insert(1, get_obj_serializer(self))
Example #4
0
    def __init__(self):
        ResourceUri.__init__(self, output_type_serializer=api.LineReportsSerializer)
        ResourceUtc.__init__(self)
        parser_get = self.parsers["get"]
        parser_get.add_argument("depth", type=int, default=1, help="The depth of your object")
        parser_get.add_argument("count", type=default_count_arg_type, default=25,
                                help="Number of objects per page")
        parser_get.add_argument("start_page", type=int, default=0,
                                help="The current page")
        parser_get.add_argument("_current_datetime", type=DateTimeFormat(),
                                schema_metadata={'default': 'now'}, hidden=True,
                                default=datetime.utcnow(),
                                help='The datetime considered as "now". Used for debug, default is '
                                     'the moment of the request. It will mainly change the output '
                                     'of the disruptions.')
        parser_get.add_argument("forbidden_uris[]", type=six.text_type,
                                help="forbidden uris",
                                dest="forbidden_uris[]",
                                default=[],
                                action="append",
                                schema_metadata={'format': 'pt-object'})
        parser_get.add_argument("disable_geojson", type=BooleanType(), default=False,
                                help="remove geojson from the response")
        parser_get.add_argument("since", type=DateTimeFormat(),
                                help="use disruptions valid after this date")
        parser_get.add_argument("until", type=DateTimeFormat(),
                                help="use disruptions valid before this date")

        self.collection = 'line_reports'
        self.collections = line_reports
        self.get_decorators.insert(0, ManageError())
        self.get_decorators.insert(1, get_obj_serializer(self))
Example #5
0
 def __init__(self):
     ResourceUri.__init__(self, output_type_serializer=api.TrafficReportsSerializer)
     parser_get = self.parsers["get"]
     parser_get.add_argument("depth", type=DepthArgument(), default=1, help="The depth of your object")
     parser_get.add_argument(
         "count", type=default_count_arg_type, default=10, help="Number of objects per page"
     )
     parser_get.add_argument("start_page", type=int, default=0, help="The current page")
     parser_get.add_argument(
         "_current_datetime",
         type=DateTimeFormat(),
         schema_metadata={'default': 'now'},
         hidden=True,
         default=datetime.utcnow(),
         help='The datetime considered as "now". Used for debug, default is '
         'the moment of the request. It will mainly change the output '
         'of the disruptions.',
     )
     parser_get.add_argument(
         "forbidden_id[]",
         type=six.text_type,
         deprecated=True,
         help="DEPRECATED, replaced by `forbidden_uris[]`",
         dest="__temporary_forbidden_id[]",
         default=[],
         action='append',
         schema_metadata={'format': 'pt-object'},
     )
     parser_get.add_argument(
         "forbidden_uris[]",
         type=six.text_type,
         help="forbidden uris",
         dest="forbidden_uris[]",
         default=[],
         action='append',
         schema_metadata={'format': 'pt-object'},
     )
     parser_get.add_argument(
         "distance",
         type=int,
         default=200,
         help="Distance range of the query. Used only if a coord is in the query",
     )
     parser_get.add_argument(
         "disable_geojson", type=BooleanType(), default=False, help="remove geojson from the response"
     )
     parser_get.add_argument(
         "tags[]",
         type=six.text_type,
         action="append",
         help="If filled, will restrain the search within the given disruption tags",
     )
     self.collection = 'traffic_reports'
     self.get_decorators.insert(0, ManageError())
     self.get_decorators.insert(1, get_obj_serializer(self))
Example #6
0
    def __init__(self):
        ResourceUri.__init__(
            self, output_type_serializer=api.VehiclePositionsSerializer)
        ResourceUtc.__init__(self)
        parser_get = self.parsers["get"]
        parser_get.add_argument("depth",
                                type=DepthArgument(),
                                default=1,
                                help="The depth of your object")
        parser_get.add_argument("count",
                                type=default_count_arg_type,
                                default=25,
                                help="Number of objects per page")
        parser_get.add_argument("filter",
                                type=six.text_type,
                                default="",
                                help="Filter your objects")
        parser_get.add_argument("start_page",
                                type=int,
                                default=0,
                                help="The current page")
        parser_get.add_argument(
            "forbidden_uris[]",
            type=six.text_type,
            help="forbidden uris",
            dest="forbidden_uris[]",
            default=[],
            action="append",
            schema_metadata={'format': 'pt-object'},
        )
        parser_get.add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            schema_metadata={'default': 'now'},
            hidden=True,
            default=datetime.utcnow(),
            help='The datetime considered as "now". Used for debug, default is '
            'the moment of the request. It will mainly change the output '
            'of the disruptions.',
        )

        self.collection = 'vehicle_positions'
        self.get_decorators.insert(0, ManageError())
        self.get_decorators.insert(1, get_obj_serializer(self))
Example #7
0
    def __init__(self, is_collection, collection, *args, **kwargs):
        kwargs['authentication'] = False
        ResourceUri.__init__(self, *args, **kwargs)
        ResourceUtc.__init__(self)
        self.parsers = {}
        self.parsers["get"] = reqparse.RequestParser(
            argument_class=ArgumentDoc)
        parser = self.parsers["get"]
        parser.add_argument("start_page",
                            type=int,
                            default=0,
                            description="The page where you want to start")
        parser.add_argument("count",
                            type=default_count_arg_type,
                            default=25,
                            description="Number of objects you want on a page")
        parser.add_argument("depth",
                            type=depth_argument,
                            default=1,
                            description="The depth of your object")
        parser.add_argument(
            "forbidden_id[]",
            type=unicode,
            description="DEPRECATED, replaced by forbidden_uris[]",
            dest="__temporary_forbidden_id[]",
            default=[],
            action="append")
        parser.add_argument("forbidden_uris[]",
                            type=unicode,
                            description="forbidden uris",
                            dest="forbidden_uris[]",
                            default=[],
                            action="append")
        parser.add_argument("external_code",
                            type=unicode,
                            description="An external code to query")
        parser.add_argument("headsign",
                            type=unicode,
                            description="filter vehicle journeys on headsign")
        parser.add_argument("show_codes",
                            type=boolean,
                            default=False,
                            description="show more identification codes")
        parser.add_argument("odt_level",
                            type=option_value(odt_levels),
                            default="all",
                            description="odt level")
        parser.add_argument(
            "_current_datetime",
            type=date_time_format,
            default=datetime.utcnow(),
            description=
            "The datetime used to consider the state of the pt object"
            " Default is the current date and it is used for debug."
            " Note: it will mainly change the disruptions that concern the object"
            " The timezone should be specified in the format,"
            " else we consider it as UTC")
        parser.add_argument(
            "distance",
            type=int,
            default=200,
            description=
            "Distance range of the query. Used only if a coord is in the query"
        )
        parser.add_argument(
            "since",
            type=date_time_format,
            description="filters objects not valid before this date")
        parser.add_argument(
            "until",
            type=date_time_format,
            description="filters objects not valid after this date")

        if is_collection:
            parser.add_argument("filter",
                                type=unicode,
                                default="",
                                description="The filter parameter")
        self.collection = collection
        self.method_decorators.insert(0, ManageError())
Example #8
0
    def __init__(self, is_collection, collection, *args, **kwargs):
        kwargs['authentication'] = False
        ResourceUri.__init__(self, *args, **kwargs)
        ResourceUtc.__init__(self)
        parser = self.parsers["get"]
        parser.add_argument("start_page",
                            type=int,
                            default=0,
                            help="The page where you want to start")
        parser.add_argument("count",
                            type=default_count_arg_type,
                            default=25,
                            help="Number of objects you want on a page")
        parser.add_argument("depth",
                            type=depth_argument,
                            schema_type=int,
                            default=1,
                            help="The depth of your object")
        parser.add_argument("forbidden_id[]",
                            type=six.text_type,
                            help="DEPRECATED, replaced by `forbidden_uris[]`",
                            dest="__temporary_forbidden_id[]",
                            default=[],
                            action="append",
                            schema_metadata={'format': 'pt-object'})
        parser.add_argument("forbidden_uris[]",
                            type=six.text_type,
                            help="forbidden uris",
                            dest="forbidden_uris[]",
                            default=[],
                            action="append",
                            schema_metadata={'format': 'pt-object'})
        # for the top level collection apis (/v1/networks, /v1/lines, ...) the external_code is mandatory
        external_code_mandatory = '.external_codes' in self.endpoint
        parser.add_argument("external_code",
                            type=six.text_type,
                            help="An external code to query",
                            required=external_code_mandatory)
        parser.add_argument("headsign",
                            type=six.text_type,
                            help="filter vehicle journeys on headsign")
        parser.add_argument("show_codes",
                            type=BooleanType(),
                            default=False,
                            help="show more identification codes")
        parser.add_argument("odt_level",
                            type=OptionValue(odt_levels),
                            default="all",
                            schema_type=str,
                            schema_metadata={"enum": odt_levels},
                            help="odt level")
        parser.add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            schema_metadata={'default': 'now'},
            hidden=True,
            default=datetime.utcnow(),
            help='The datetime considered as "now". Used for debug, default is '
            'the moment of the request. It will mainly change the output '
            'of the disruptions.')
        parser.add_argument(
            "distance",
            type=int,
            default=200,
            help=
            "Distance range of the query. Used only if a coord is in the query"
        )
        parser.add_argument("since",
                            type=DateTimeFormat(),
                            help="filters objects not valid before this date")
        parser.add_argument("until",
                            type=DateTimeFormat(),
                            help="filters objects not valid after this date")
        parser.add_argument("disable_geojson",
                            type=BooleanType(),
                            default=False,
                            help="remove geojson from the response")

        if is_collection:
            parser.add_argument("filter",
                                type=six.text_type,
                                default="",
                                help="The filter parameter")
        self.collection = collection
        self.get_decorators.insert(0, ManageError())
Example #9
0
    def __init__(self, is_collection, collection, *args, **kwargs):
        kwargs['authentication'] = False
        ResourceUri.__init__(self, *args, **kwargs)
        ResourceUtc.__init__(self)
        parser = self.parsers["get"]
        parser.add_argument("start_page",
                            type=int,
                            default=0,
                            help="The page where you want to start")
        parser.add_argument("count",
                            type=default_count_arg_type,
                            default=25,
                            help="Number of objects you want on a page")
        parser.add_argument("depth",
                            type=DepthArgument(),
                            schema_type=int,
                            default=1,
                            help="The depth of your object")
        parser.add_argument(
            "forbidden_id[]",
            type=six.text_type,
            help="DEPRECATED, replaced by `forbidden_uris[]`",
            dest="__temporary_forbidden_id[]",
            default=[],
            action="append",
            schema_metadata={'format': 'pt-object'},
        )
        parser.add_argument(
            "forbidden_uris[]",
            type=six.text_type,
            help="forbidden uris",
            dest="forbidden_uris[]",
            default=[],
            action="append",
            schema_metadata={'format': 'pt-object'},
        )
        # for the top level collection apis (/v1/networks, /v1/lines, ...) the external_code is mandatory
        external_code_mandatory = '.external_codes' in self.endpoint
        parser.add_argument(
            "external_code",
            type=six.text_type,
            help="An external code to query",
            required=external_code_mandatory,
        )
        parser.add_argument("headsign",
                            type=six.text_type,
                            help="filter vehicle journeys on headsign")
        parser.add_argument("show_codes",
                            type=BooleanType(),
                            default=False,
                            help="show more identification codes")
        parser.add_argument(
            "odt_level",
            type=OptionValue(odt_levels),
            default="all",
            schema_type=str,
            schema_metadata={"enum": odt_levels},
            help="odt level",
        )
        parser.add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            schema_metadata={'default': 'now'},
            hidden=True,
            default=datetime.now(),
            help='The datetime considered as "now". Used for debug, default is '
            'the moment of the request. It will mainly change the output '
            'of the disruptions.',
        )
        parser.add_argument(
            "data_freshness",
            help=
            "Define the freshness of data to use to filter vehicle_journeys "
            "along with parameters &since and/or &until .\n"
            "Provides only the vehicle_journeys valid for the data freshness level requested.\n"
            "Using `&data_freshness=base_schedule` will return all original vehicle_journeys only"
            "whereas using `&data_freshness=realtime` will return vehicle_journeys after applying"
            "modifications by realtime (amended vehicle_journeys, and non-impacted original vehicle_journeys).",
            type=OptionValue(['base_schedule', 'adapted_schedule',
                              'realtime']),
            default='base_schedule',
        )
        parser.add_argument(
            "distance",
            type=int,
            default=200,
            help=
            "Distance range of the query. Used only if a coord is in the query",
        )
        parser.add_argument("since",
                            type=DateTimeFormat(),
                            help="filters objects not valid before this date")
        parser.add_argument("until",
                            type=DateTimeFormat(),
                            help="filters objects not valid after this date")
        parser.add_argument("disable_geojson",
                            type=BooleanType(),
                            default=False,
                            help="remove geojson from the response")
        parser.add_argument("disable_disruption",
                            type=BooleanType(),
                            default=False,
                            help="remove disruptions from the response")

        if is_collection:
            parser.add_argument("filter",
                                type=six.text_type,
                                default="",
                                help="The filter parameter")
        parser.add_argument(
            "tags[]",
            type=six.text_type,
            action="append",
            help=
            "If filled, will restrain the search within the given disruption tags",
        )
        self.collection = collection
        self.get_decorators.insert(0, ManageError())
Example #10
0
    def __init__(self, is_collection, collection, *args, **kwargs):
        kwargs['authentication'] = False
        ResourceUri.__init__(self, *args, **kwargs)
        ResourceUtc.__init__(self)
        parser = self.parsers["get"]
        parser.add_argument("start_page",
                            type=int,
                            default=0,
                            help="The page where you want to start")
        parser.add_argument("count",
                            type=default_count_arg_type,
                            default=25,
                            help="Number of objects you want on a page")
        parser.add_argument("depth",
                            type=depth_argument,
                            schema_type=int,
                            default=1,
                            help="The depth of your object")
        parser.add_argument("forbidden_id[]",
                            type=six.text_type,
                            help="DEPRECATED, replaced by `forbidden_uris[]`",
                            dest="__temporary_forbidden_id[]",
                            default=[],
                            action="append")
        parser.add_argument("forbidden_uris[]",
                            type=six.text_type,
                            help="forbidden uris",
                            dest="forbidden_uris[]",
                            default=[],
                            action="append")
        parser.add_argument("external_code",
                            type=six.text_type,
                            help="An external code to query")
        parser.add_argument("headsign",
                            type=six.text_type,
                            help="filter vehicle journeys on headsign")
        parser.add_argument("show_codes",
                            type=BooleanType(),
                            default=False,
                            help="show more identification codes")
        parser.add_argument("odt_level",
                            type=OptionValue(odt_levels),
                            default="all",
                            schema_type=str,
                            schema_metadata={"enum": odt_levels},
                            help="odt level")
        parser.add_argument(
            "_current_datetime",
            type=DateTimeFormat(),
            default=datetime.utcnow(),
            hidden=True,
            help="The datetime used to consider the state of the pt object"
            " Default is the current date and it is used for debug."
            " Note: it will mainly change the disruptions that concern the object"
            " The timezone should be specified in the format,"
            " else we consider it as UTC")
        parser.add_argument(
            "distance",
            type=int,
            default=200,
            help=
            "Distance range of the query. Used only if a coord is in the query"
        )
        parser.add_argument("since",
                            type=DateTimeFormat(),
                            help="filters objects not valid before this date")
        parser.add_argument("until",
                            type=DateTimeFormat(),
                            help="filters objects not valid after this date")
        parser.add_argument("disable_geojson",
                            type=BooleanType(),
                            default=False,
                            help="remove geojson from the response")

        if is_collection:
            parser.add_argument("filter",
                                type=six.text_type,
                                default="",
                                help="The filter parameter")
        self.collection = collection
        self.get_decorators.insert(0, ManageError())