<back to all web services

ReadingsBulk

The following routes are available for this service:
GET/v8/readings-bulk
GET/v8/readings-bulk/{from}
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Generic:
    # @ApiMember(DataType="String", Description="Api-key. Used to provide credentials to the api. Can also be provided through the request headers with key: X-API-KEY", IsRequired=true, Name="ApiKey")
    api_key: Optional[str] = None
    """
    Api-key. Used to provide credentials to the api. Can also be provided through the request headers with key: X-API-KEY
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class P4ReadingDay:
    ean: Optional[str] = None
    meter_id: Optional[str] = None
    query_date: datetime.datetime = datetime.datetime(1, 1, 1)
    measure_unit: Optional[str] = None
    r180: Optional[Decimal] = None
    r181: Optional[Decimal] = None
    r182: Optional[Decimal] = None
    r280: Optional[Decimal] = None
    r281: Optional[Decimal] = None
    r282: Optional[Decimal] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class P4ReadingIntervalItem:
    date_time_offset: datetime.datetime = datetime.datetime(1, 1, 1)
    r180: Decimal = decimal.Decimal(0)
    r280: Optional[Decimal] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class P4ReadingInterval:
    ean: Optional[str] = None
    meter_id: Optional[str] = None
    query_date: datetime.datetime = datetime.datetime(1, 1, 1)
    measure_unit: Optional[str] = None
    items: Optional[List[P4ReadingIntervalItem]] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class P4Rejection:
    ean: Optional[str] = None
    query_date: datetime.datetime = datetime.datetime(1, 1, 1)
    query_reason: Optional[str] = None
    rejection_code: Optional[str] = None
    rejection_text: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class P4ReadingsBulk:
    message: Optional[str] = None
    time_stamp: Optional[str] = None
    day_object_count: Optional[int] = None
    interval_object_count: Optional[int] = None
    rejection_object_count: Optional[int] = None
    day_objects: Optional[List[P4ReadingDay]] = None
    interval_objects: Optional[List[P4ReadingInterval]] = None
    rejection_objects: Optional[List[P4Rejection]] = None


class Filter(str, Enum):
    NONE = 'None'
    HOUR = 'Hour'
    DAY = 'Day'
    LAST_DAY_ONLY = 'LastDayOnly'
    MONTH = 'Month'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ReadingsBulk(Generic, IGet):
    # @ApiMember(DataType="Time stamp with format: yyyyMMdd-HHmmss-ffffff", Description="If not given, the first object is given after the last request, otherwise gives the first ... data objects received from EDSN/Grid operator received after the given time stamp. Keep in mind, the time stamp is related to when SDS received the data from EDSN, not the date of the data itself!", Name="From")
    from_: Optional[str] = field(metadata=config(field_name='from'), default=None)
    """
    If not given, the first object is given after the last request, otherwise gives the first ... data objects received from EDSN/Grid operator received after the given time stamp. Keep in mind, the time stamp is related to when SDS received the data from EDSN, not the date of the data itself!
    """


    # @ApiMember(DataType="Boolean, default: true", Description="Include received interval objects in the result", Name="IncludeIntervalObjects")
    include_interval_objects: bool = False
    """
    Include received interval objects in the result
    """


    # @ApiMember(DataType="Boolean, default: false", Description="Include received day objects in the result", Name="IncludeDayObjects")
    include_day_objects: bool = False
    """
    Include received day objects in the result
    """


    # @ApiMember(DataType="Enum: None, Hour, Day, LastDayOnly, Month", Description="Gives option to filter return objects, for example to get always only hour records or day records", Name="ObjectFilter")
    object_filter: Optional[Filter] = None
    """
    Gives option to filter return objects, for example to get always only hour records or day records
    """

Python ReadingsBulk DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /v8/readings-bulk HTTP/1.1 
Host: p4.smartdatasolutions.eu 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	message: String,
	timeStamp: String,
	dayObjectCount: 0,
	intervalObjectCount: 0,
	rejectionObjectCount: 0,
	dayObjects: 
	[
		{
			ean: String,
			meterId: String,
			queryDate: 0001-01-01,
			measureUnit: String,
			r180: 0,
			r181: 0,
			r182: 0,
			r280: 0,
			r281: 0,
			r282: 0
		}
	],
	intervalObjects: 
	[
		{
			ean: String,
			meterId: String,
			queryDate: 0001-01-01,
			measureUnit: String,
			items: 
			[
				{
					dateTimeOffset: 0001-01-01T00:00:00.0000000+00:00,
					r180: 0,
					r280: 0
				}
			]
		}
	],
	rejectionObjects: 
	[
		{
			ean: String,
			queryDate: 0001-01-01,
			queryReason: String,
			rejectionCode: String,
			rejectionText: String
		}
	]
}