def __init__(self):
        self.dropped_keys = []
        self.single_keys = ['code', 'name', 'areaType', 'predicted']

        self.params = [
            Params(name='regionCode',
                   dtype=str,
                   required=True,
                   location='query',
                   description="UK region code"),
            Params(name='startDate',
                   dtype=str,
                   required=True,
                   location='query',
                   description="Query start date (format: %Y-%m-%d)"),
            Params(name='offset',
                   dtype=int,
                   required=True,
                   location='query',
                   description="The number of dates from startDate."),
        ]
        self.methods = ['get']

        super(UKService, self).__init__(params=self.params,
                                        methods=self.methods,
                                        dropped_keys=self.dropped_keys,
                                        single_keys=self.single_keys)

        self.schema = UKSchema(self.fields)
Example #2
0
    def __init__(self):
        self.dropped_keys = []
        self.single_keys = []

        self.params = [
            Params(name='lat',
                   dtype=float,
                   required=True,
                   location='query',
                   description="latitude"),
            Params(name='long',
                   dtype=float,
                   required=True,
                   location='query',
                   description="longitude"),
            # Params(name='key', dtype=str, required=True,
            #        location='query', description="Google GeoCoding api key"),
        ]
        self.methods = ['get']

        super(GeoApiSearch_Service,
              self).__init__(params=self.params,
                             methods=self.methods,
                             dropped_keys=self.dropped_keys,
                             single_keys=self.single_keys)
        self.schema = RegionSearch_Schema(self.fields)
    def __init__(self):
        self.dropped_keys = []
        self.single_keys = ['CountryName', 'CountryCode']

        self.params = [
            Params(name='regionCode', dtype=str, required=True,
                   location='query', description="Country code (ISO3)"),
            Params(name='startDate', dtype=str, required=True,
                   location='query', description="Query start date (format: %Y-%m-%d)"),
            Params(name='offset', dtype=int, required=True,
                   location='query', description="The number of dates from startDate."),

            # Params(name='retail_and_recreation', dtype=bool, required=True,
            #        location='header', description="requesting retail and recreation data"),
            # Params(name='grocery_and_pharmacy', dtype=bool, required=True,
            #        location='header', description="requesting grocery and pharmacy data"),
            # Params(name='parks', dtype=bool, required=True,
            #        location='header', description="requesting parks data"),
            # Params(name='transit_stations', dtype=bool, required=True,
            #        location='header', description="requesting transit stations data"),
            # Params(name='workplaces', dtype=bool, required=True,
            #        location='header', description="requesting workplaces data"),
            # Params(name='residential', dtype=bool, required=True,
            #        location='header', description="requesting residential data"),
        ]
        self.methods = ['get']

        super(GoogleMobility_Service, self).__init__(params=self.params, methods=self.methods,
                                                     dropped_keys=self.dropped_keys, single_keys=self.single_keys)
        self.schema = GoogleMobility_Schema(self.fields)
    def __init__(self):
        self.dropped_keys = []
        self.single_keys = [
            'code',
            'continent',
            'population',
            'population_density',
            'median_age',
            'aged_65_older',
            'aged_70_older',
            'gdp_per_capita',
            'extreme_poverty',
            'cardiovasc_death_rate',
            'diabetes_prevalence',
            'female_smokers',
            'male_smokers',
            'hospital_beds_per_thousand',
            'life_expectancy',
            'human_development_index',
            'location',
        ]

        self.params = [
            Params(name='regionCode',
                   dtype=str,
                   required=True,
                   location='query',
                   description="Region code (ISO3)"),
            Params(name='startDate',
                   dtype=str,
                   required=True,
                   location='query',
                   description="Query start date (format: %Y-%m-%d)"),
            Params(name='offset',
                   dtype=int,
                   required=True,
                   location='query',
                   description="The number of dates from startDate."),
        ]
        self.methods = ['get']

        super(OWIDDataService, self).__init__(params=self.params,
                                              methods=self.methods,
                                              dropped_keys=self.dropped_keys,
                                              single_keys=self.single_keys)

        self.schema = OWIDSchema(self.fields)
Example #5
0
def append_fields(schema: ManualSchema, param: Params):
    schema._fields.append(
        coreapi.Field(
            name=param.name,
            required=param.required,
            location=param.location,
            schema=param.get_schema(),
        ),
    )
 def get_manual_fields(self, path, method):
     super().get_manual_fields(path, method)
     custom_fields = []
     if path.lower() == "/api/covid/uk/prediction/":
         predDate_params = Params(
             name='predictedDate',
             dtype=str,
             required=True,
             location='query',
             description="Target predicted date (format: %Y-%m-%d)")
         custom_fields = [
             coreapi.Field(
                 name=predDate_params.name,
                 required=predDate_params.required,
                 location=predDate_params.location,
                 schema=predDate_params.get_schema(),
             ),
         ]
     return self.manual_fields + custom_fields
Example #7
0
    def __init__(self, filterRegion):
        self.dropped_keys = []
        self.single_keys = ['CountryCode', 'ContinentName', 'predicted']

        self.params = [
            Params(name='offset',
                   dtype=int,
                   required=True,
                   location='query',
                   description="The number of dates from startDate."),
            Params(name='startDate',
                   dtype=str,
                   required=True,
                   location='query',
                   description="Query start date (format: %Y-%m-%d)"),
        ]
        self.methods = ['get']

        if filterRegion.lower() == 'country':
            self.params.append(
                Params(name='CountryCode',
                       dtype=str,
                       required=True,
                       location='query',
                       description="Country's ISO code. (ISO3)"), )

        elif filterRegion.lower() == 'continent':
            self.params.append(
                Params(name='ContinentName',
                       dtype=str,
                       required=True,
                       location='query',
                       description="ContinentName"), )

        self.params = self.params[::-1]

        super(CSSEService, self).__init__(params=self.params,
                                          methods=self.methods,
                                          dropped_keys=self.dropped_keys,
                                          single_keys=self.single_keys)
        self.schema = CSSESchema(self.fields)
    def __init__(self):
        self.dropped_keys = []
        self.single_keys = ['location']

        self.params = [
            Params(name='regionCode',
                   dtype=str,
                   required=True,
                   location='query',
                   description="Region code (ISO3)"),
        ]
        self.methods = ['get']

        super(OWIDMetaService, self).__init__(params=self.params,
                                              methods=self.methods,
                                              dropped_keys=self.dropped_keys,
                                              single_keys=self.single_keys)

        self.schema = OWIDSchema(self.fields)
Example #9
0
    def __init__(self):
        self.dropped_keys = []
        self.single_keys = []

        self.params = [
            Params(name='UKRegionName',
                   dtype=str,
                   required=True,
                   location='query',
                   description="searching UK region code by its region name"),
        ]
        self.methods = ['get']

        super(UKRegionSearch_Service,
              self).__init__(params=self.params,
                             methods=self.methods,
                             dropped_keys=self.dropped_keys,
                             single_keys=self.single_keys)
        self.schema = RegionSearch_Schema(self.fields)
Example #10
0
    def get_manual_fields(self, path, method):
        super().get_manual_fields(path, method)
        custom_fields = []
        if path.lower() in [
                "/api/region/global/continent_list/",
                "/api/region/uk/region_list/"
        ]:
            self.manual_fields = []

        elif path.lower() == "/api/region/global/search/":
            self.manual_fields = []
            param = Params(
                name='regionName',
                dtype=str,
                required=True,
                location='query',
                description="searching country ISO3 code by region name")

            custom_fields.append(
                coreapi.Field(
                    name=param.name,
                    required=param.required,
                    location=param.location,
                    schema=param.get_schema(),
                ), )

        elif path.lower() == "/api/region/global/timezone/":
            self.manual_fields = []
            param = Params(name='CountryCode',
                           dtype=str,
                           required=True,
                           location='query',
                           description="Country's ISO code. (ISO3)")

            custom_fields.append(
                coreapi.Field(
                    name=param.name,
                    required=param.required,
                    location=param.location,
                    schema=param.get_schema(),
                ), )

        elif path.lower() == "/api/region/global/country_list/":
            self.manual_fields = []
            continent = Params(name='continent',
                               dtype=str,
                               required=True,
                               location='query',
                               description="continent name")
            custom_fields.append(
                coreapi.Field(
                    name=continent.name,
                    required=continent.required,
                    location=continent.location,
                    schema=continent.get_schema(),
                ), )

        elif path.lower() == "/api/region/uk/search/":
            self.manual_fields = []
            regionName = Params(name='regionName',
                                dtype=str,
                                required=True,
                                location='query',
                                description="uk region name")
            custom_fields.append(
                coreapi.Field(
                    name=regionName.name,
                    required=regionName.required,
                    location=regionName.location,
                    schema=regionName.get_schema(),
                ), )

        return self.manual_fields + custom_fields