pip_services3_commons.data package

Submodules

Module contents

pip_services3_commons.data.__init__

Abstract, portable data types. For example – anytype, anyvalues, anyarrays, anymaps, stringmaps (on which many serializable objects are based on – configmap, filtermaps, connectionparams – all extend stringvaluemap). Includes standard design patterns for working with data (data paging, filtering, GUIDs).

copyright

Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_commons.data.AnyValue(value: Any = None)

Bases: pip_services3_commons.data.ICloneable.ICloneable

Cross-language implementation of dynamic object what can hold args of any type. The stored args can be converted to different types using variety of accessor methods.

Example:

value1 = AnyValue("123.456")

value1.get_as_integer()   # Result: 123
value1.get_as_string()    # Result: "123.456"
value1.get_as_float()     # Result: 123.456
clone() → Any

Creates a binary clone of this object.

Returns

a clone of this object.

equals(other: Any)bool

Compares this object args to specified specified args. When direct comparison gives negative results it tries to compare values as strings.

Parameters

other – the args to be compared with.

Returns

true when objects are equal and false otherwise.

equals_as_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode, obj: Any)bool

Compares this object args to specified specified args. When direct comparison gives negative results it converts values to type specified by type code and compare them again.

Parameters
  • value_type – the Typecode type that defined the type of the result

  • obj – the args to be compared with.

Returns

true when objects are equal and false otherwise.

get_as_array()pip_services3_commons.data.AnyValueArray.AnyValueArray

Converts object args into an AnyArray or returns empty AnyArray if conversion is not possible.

Returns

AnyArray args or empty AnyArray if conversion is not supported.

get_as_boolean()bool

Converts object args into a boolean or returns false if conversion is not possible.

Returns

string args or false if conversion is not supported.

get_as_boolean_with_default(default_value: bool)bool

Converts object args into a boolean or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

boolean args or default if conversion is not supported.

get_as_datetime()datetime.datetime

Converts object args into a Date or returns current date if conversion is not possible.

Returns

Date args or current date if conversion is not supported.

get_as_datetime_with_default(default_value: datetime.datetime)datetime.datetime

Converts object args into a Date or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

Date args or default if conversion is not supported.

get_as_double()float

Converts object value into a double or returns null if conversion is not possible.

Returns

double value or None if conversion is not supported.

See: DoubleConverter

get_as_double_with_default(default_value: float)float

Converts object value into a double or returns default value if conversion is not possible.

Parameters

default_value – the default value.

Returns

double value or default if conversion is not supported.

See: DoubleConverter

get_as_float()float

Converts object args into a float or returns 0 if conversion is not possible.

Returns

float args or 0 if conversion is not supported.

get_as_float_with_default(default_value: float)float

Converts object args into a float or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

float args or default if conversion is not supported.

get_as_integer()int

Converts object args into an integer or returns 0 if conversion is not possible.

Returns

integer args or 0 if conversion is not supported.

get_as_integer_with_default(default_value: int)int

Converts object args into a integer or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

integer args or default if conversion is not supported.

get_as_long()float
get_as_long_with_default(default_value: float)float
get_as_map()AnyValueMap

Converts object args into AnyMap or returns empty AnyMap if conversion is not possible.

Returns

AnyMap args or empty AnyMap if conversion is not supported.

get_as_nullable_boolean() → Optional[bool, None]

Converts object args into a boolean or returns null if conversion is not possible.

Returns

boolean args or null if conversion is not supported.

get_as_nullable_datetime() → Optional[datetime.datetime, None]

Converts object args into a Date or returns None if conversion is not possible.

Returns

Date args or None if conversion is not supported.

get_as_nullable_double() → Optional[float, None]

Converts object value into a double or returns null if conversion is not possible.

Returns

double args or None if conversion is not supported.

get_as_nullable_float() → Optional[float, None]

Converts object args into a float or returns None if conversion is not possible.

Returns

float args or None if conversion is not supported.

get_as_nullable_integer() → Optional[int, None]

Converts object args into an integer or returns None if conversion is not possible.

Returns

integer args or None if conversion is not supported.

get_as_nullable_long() → Optional[float, None]
get_as_nullable_string()str

Converts object args into a string or returns null if conversion is not possible.

Returns

string args or None if conversion is not supported.

get_as_nullable_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode) → Optional[Any, None]

Converts object args into a args defined by specied typecode. If conversion is not possible it returns None.

Parameters

value_type – the TypeCode that defined the type of the result

Returns

args defined by the typecode or null if conversion is not supported.

get_as_object() → Any

Gets the args stored in this object without any conversions

Returns

the object args.

get_as_string()str

Converts object args into a string or returns “” if conversion is not possible.

Returns

string args or “” if conversion is not supported.

get_as_string_with_default(default_value: str)str

Converts object args into a string or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

string args or default if conversion is not supported.

get_as_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode) → Any

Converts object args into a args defined by specied typecode. If conversion is not possible it returns default args for the specified type.

Parameters

value_type – the TypeCode that defined the type of the result

Returns

args defined by the typecode or type default args if conversion is not supported.

get_as_type_with_default(value_type: pip_services3_commons.convert.TypeCode.TypeCode, default_value: Any) → Any

Converts object args into a args defined by specied typecode. If conversion is not possible it returns default args.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • default_value – the default args

Returns

args defined by the typecode or type default args if conversion is not supported.

get_type_code()pip_services3_commons.convert.TypeCode.TypeCode

Gets type code for the args stored in this object.

Returns

type code of the object args.

set_as_object(value: Any)

Sets a new args for this object

Parameters

value – the new object args.

to_string()str

Gets a string representation of the object.

Returns

a string representation of the object.

class pip_services3_commons.data.AnyValueArray(values: Sequence[Any] = None)

Bases: list, pip_services3_commons.data.ICloneable.ICloneable

Cross-language implementation of dynamic object array what can hold values of any type. The stored values can be converted to different types using variety of accessor methods.

Example:

value1 = AnyValueArray([1, "123.456", "2018-01-01"])
value1.get_as_boolean(0)   # Result: true
value1.get_as_integer(1)   # Result: 123
value1.get_as_float(1)     # Result: 123.456
value1.get_as_datetime(2)  # Result: datetime.datetime(2018,0,1)
appends(elements: List[Any])

Appends new elements to this array.

Parameters

elements – a list of elements to be added.

clear()

Clears this array by removing all its elements.

clone() → Any

Creates a binary clone of this object.

Returns

a clone of this object.

contains(value: Any)bool

Checks if this array contains a args. The check uses direct comparison between elements and the specified args.

Parameters

value – a args to be checked

Returns

true if this array contains the args or false otherwise.

contains_as_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode, value: Any)bool

Checks if this array contains a args. The check before comparison converts elements and the args to type specified by type code.

Parameters
  • value_type – a type code that defines a type to convert values before comparison

  • value – a args to be checked

Returns

true if this array contains the args or false otherwise.

static from_string(values: str, separator: str, remove_duplicates: bool = False)pip_services3_commons.data.AnyValueArray.AnyValueArray

Splits specified string into elements using a separator and assigns the elements to a newly created AnyValueArray.

Parameters
  • values – a string args to be split and assigned to AnyValueArray

  • separator – a separator to split the string

  • remove_duplicates – (optional) true to remove duplicated elements

Returns

a newly created AnyValueArray.

static from_value(value: Any)pip_services3_commons.data.AnyValueArray.AnyValueArray

Converts specified args into AnyValueArray.

Parameters

value – args to be converted

Returns

a newly created AnyValueArray.

static from_values(*values: Any)pip_services3_commons.data.AnyValueArray.AnyValueArray

Creates a new AnyValueArray from a list of values

Parameters

values – a list of values to initialize the created AnyValueArray

Returns

a newly created AnyValueArray.

get(index: int) → Any

Gets an array element specified by its index.

Parameters

index – an index of the element to get.

Returns

the value of the array element.

get_as_array(index: int)pip_services3_commons.data.AnyValueArray.AnyValueArray

Converts array element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.

Parameters

index – an index of element to get.

Returns

AnyValueArray args of the element or empty AnyValueArray if conversion is not supported.

get_as_array_with_default(index: int, default_value: pip_services3_commons.data.AnyValueArray.AnyValueArray)pip_services3_commons.data.AnyValueArray.AnyValueArray

Converts array element into an AnyValueArray or returns default value if conversion is not possible.

Parameters
  • index – an index of element to get.

  • default_value – the default value

Returns

AnyValueArray value of the element or default value if conversion is not supported.

get_as_boolean(index: int)bool

Converts array element into a boolean or returns false if conversion is not possible.

Parameters

index – an index of element to get.

Returns

boolean args ot the element or false if conversion is not supported.

get_as_boolean_with_default(index: int, default_value: bool)bool

Converts array element into a boolean or returns default args if conversion is not possible.

Parameters
  • index – an index of element to get.

  • default_value – the default args

Returns

boolean args ot the element or default args if conversion is not supported.

get_as_datetime(index: int)datetime.datetime

Converts array element into a Date or returns the current date if conversion is not possible.

Parameters

index – an index of element to get.

Returns

Date args ot the element or the current date if conversion is not supported.

get_as_datetime_with_default(index: int, default_value: datetime.datetime)datetime.datetime

Converts array element into a Date or returns default args if conversion is not possible.

Parameters
  • index – an index of element to get.

  • default_value – the default args

Returns

Date args ot the element or default args if conversion is not supported.

get_as_double(index: int)float

Converts array element into a double or returns 0 if conversion is not possible.

Parameters

index – an index of element to get.

Returns

double value ot the element or 0 if conversion is not supported.

get_as_double_with_default(index: int, default_value: float)float

Converts array element into a double or returns default value if conversion is not possible.

Parameters
  • index – an index of element to get.

  • default_value – the default value

Returns

double value ot the element or default value if conversion is not supported.

get_as_float(index: int)float

Converts array element into a float or returns 0 if conversion is not possible.

Parameters

index – an index of element to get.

Returns

float args ot the element or 0 if conversion is not supported.

get_as_float_with_default(index: int, default_value: float)float

Converts array element into a float or returns default args if conversion is not possible.

Parameters
  • index – an index of element to get.

  • default_value – the default args

Returns

float args ot the element or default args if conversion is not supported.

get_as_integer(index)int

Converts array element into an integer or returns 0 if conversion is not possible.

Parameters

index – an index of element to get.

Returns

integer args ot the element or 0 if conversion is not supported.

get_as_integer_with_default(index: int, default_value: int)int

Converts array element into an integer or returns default args if conversion is not possible.

Parameters
  • index – an index of element to get.

  • default_value – the default args

Returns

integer args ot the element or default args if conversion is not supported.

get_as_long(index: int)float
get_as_long_with_default(index: int, default_value: float)float
get_as_map(index: int)pip_services3_commons.data.AnyValueMap.AnyValueMap

Converts array element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.

Parameters

index – an index of element to get.

Returns

AnyValueMap args of the element or empty AnyValueMap if conversion is not supported.

get_as_map_with_default(index: int, default_value: pip_services3_commons.data.AnyValueMap.AnyValueMap)pip_services3_commons.data.AnyValueMap.AnyValueMap

Converts array element into an AnyValueMap or returns default value if conversion is not possible.

Parameters
  • index – an index of element to get.

  • default_value – the default value

Returns

AnyValueMap value of the element or default value if conversion is not supported.

get_as_nullable_array(index: int) → Optional[pip_services3_commons.data.AnyValueArray.AnyValueArray, None]

Converts array element into an AnyValueArray or returns null if conversion is not possible.

Parameters

index – an index of element to get.

Returns

AnyValueArray value of the element or null if conversion is not supported.

get_as_nullable_boolean(index: int) → Optional[bool, None]

Converts array element into a boolean or returns None if conversion is not possible

Parameters

index – an index of element to get.

Returns

boolean args of the element or None if conversion is not supported.

get_as_nullable_datetime(index: int) → Optional[datetime.datetime, None]

Converts array element into a Date or returns None if conversion is not possible.

Parameters

index – an index of element to get.

Returns

Date args of the element or None if conversion is not supported.

get_as_nullable_double(index: int)float

Converts array element into a double or returns null if conversion is not possible.

Parameters

index – an index of element to get.

Returns

double value of the element or null if conversion is not supported.

get_as_nullable_float(index: int) → Optional[float, None]

Converts array element into a float or returns None if conversion is not possible.

Parameters

index – an index of element to get.

Returns

float args of the element or None if conversion is not supported.

get_as_nullable_integer(index: int) → Optional[int, None]

Converts array element into an integer or returns None if conversion is not possible.

Parameters

index – an index of element to get.

Returns

integer args of the element or None if conversion is not supported.

get_as_nullable_long(index: int)float
get_as_nullable_map(index: int) → Optional[pip_services3_commons.data.AnyValueMap.AnyValueMap, None]

Converts array element into an AnyValueMap or returns null if conversion is not possible.

Parameters

index – an index of element to get.

Returns

AnyValueMap value of the element or null if conversion is not supported.

get_as_nullable_string(index: int) → Optional[str, None]

Converts array element into a string or returns None if conversion is not possible.

Parameters

index – an index of element to get.

Returns

string args of the element or None if conversion is not supported.

get_as_nullable_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode, index: int) → Any

Converts array element into a args defined by specied typecode. If conversion is not possible it returns None.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • index – an index of element to get.

Returns

element args defined by the typecode or None if conversion is not supported.

get_as_object(index: int = None) → Any

Gets the args stored in array element without any conversions. When element index is not defined it returns the entire array args.

Parameters

index – (optional) an index of the element to get

Returns

the element args or args of the array when index is not defined.

get_as_string(index: int)str

Converts array element into a string or returns “” if conversion is not possible.

Parameters

index – an index of element to get.

Returns

string args ot the element or “” if conversion is not supported.

get_as_string_with_default(index: int, default_value: str)str

Converts array element into a string or returns default args if conversion is not possible.

Parameters
  • index – an index of element to get.

  • default_value – the default args

Returns

string args ot the element or default args if conversion is not supported.

get_as_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode, index: int) → Any

Converts array element into a args defined by specied typecode. If conversion is not possible it returns default args for the specified type.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • index – an index of element to get.

Returns

element args defined by the typecode or default if conversion is not supported.

get_as_type_with_default(value_type: pip_services3_commons.convert.TypeCode.TypeCode, index: int, default_value: Any) → Any

Converts array element into a args defined by specied typecode. If conversion is not possible it returns default args.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • index – an index of element to get.

  • default_value – the default args

Returns

element args defined by the typecode or default args if conversion is not supported.

get_as_value(index: int)AnyValue

Converts array element into an AnyValue or returns an empty AnyValue if conversion is not possible.

Parameters

index – an index of element to get.

Returns

AnyValue args of the element or empty AnyValue if conversion is not supported.

put(index: int, value: Any)

Puts a new value into array element specified by its index.

Parameters
  • index – a new value for array element.

  • value – an index of the element to put.

Returns

the value of the array element.

remove(index: int)

Removes an array element specified by its index

Parameters

index – an index of the element to remove.

set_as_array(values: List[Any])

Sets a new values to array element

Parameters

values – values to set

set_as_object(index: int = None, value: Any = None)

Sets a new args to array element specified by its index. When the index is not defined, it resets the entire array args. This method has double purpose because method overrides are not supported in JavaScript.

Parameters
  • index – (optional) an index of the element to set

  • value – a new element or array args.

to_string()str

Gets a string representation of the object. The result is a comma-separated list of string representations of individual elements as “value1,value2,value3”

Returns

a string representation of the object.

class pip_services3_commons.data.AnyValueMap(map: Any = None)

Bases: dict, pip_services3_commons.data.ICloneable.ICloneable

Cross-language implementation of dynamic object map (dictionary) what can hold values of any type. The stored values can be converted to different types using variety of accessor methods.

Example:

value1 = new AnyValueMap({ key1: 1, key2: "123.456", key3: "2018-01-01" })

value1.get_as_boolean("key1")   # Result: true
value1.get_as_integer("key2")   # Result: 123
value1.get_as_float("key2")     # Result: 123.456
value1.get_as_datetime("key3")  # Result: new Date(2018,0,1)
append(map: Any)

Appends new elements to this map.

Parameters

map – a map with elements to be added.

clear()

Clears this map by removing all its elements.

clone() → Any

Creates a binary clone of this object.

Returns

a clone of this object.

contains_key(key)
static from_maps(*maps: dict)pip_services3_commons.data.AnyValueMap.AnyValueMap

Creates a new AnyValueMap by merging two or more maps. Maps defined later in the list override values from previously defined maps.

Parameters

maps – an array of maps to be merged

Returns

a newly created AnyValueMap.

static from_tuples(*tuples: Any)pip_services3_commons.data.AnyValueMap.AnyValueMap

Creates a new AnyValueMap from a list of key-args pairs called tuples.

Parameters

tuples – a list of values where odd elements are keys and the following even elements are values

Returns

a newly created AnyValueMap.

static from_tuples_array(tuples: Sequence[Any])pip_services3_commons.data.AnyValueMap.AnyValueMap

Creates a new AnyValueMap from a list of key-args pairs called tuples. The method is similar to from_tuples() but tuples are passed as array instead of parameters.

Parameters

tuples – a list of values where odd elements are keys and the following even elements are values

Returns

a newly created AnyValueArray.

static from_value(value: Any)pip_services3_commons.data.AnyValueMap.AnyValueMap

Converts specified args into AnyValueMap.

Parameters

value – args to be converted

Returns

a newly created AnyValueMap.

get(key: str) → Any

Gets a map element specified by its key.

Parameters

key – a key of the element to get.

Returns

the args of the map element.

get_as_array(key: str)AnyValueArray

Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.

Parameters

key – an index of element to get.

Returns

AnyValueMap args of the element or empty AnyValueMap if conversion is not supported.

get_as_boolean(key: str)bool

Converts map element into a boolean or returns false if conversion is not possible.

Parameters

key – an index of element to get.

Returns

boolean args ot the element or false if conversion is not supported.

get_as_boolean_with_default(key: str, default_value: bool)bool

Converts map element into a boolean or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

boolean args ot the element or default args if conversion is not supported.

get_as_datetime(key: str)datetime.datetime

Converts map element into a Date or returns the current date if conversion is not possible.

Parameters

key – an index of element to get.

Returns

Date args ot the element or the current date if conversion is not supported.

get_as_datetime_with_default(key: str, default_value: datetime.datetime)datetime.datetime

Converts map element into a Date or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

Date args ot the element or default args if conversion is not supported.

get_as_double(key: str)float

Converts map element into a float or returns 0 if conversion is not possible.

Parameters

key – an index of element to get.

Returns

float args ot the element or 0 if conversion is not supported.

get_as_double_with_default(key: str, default_value: float)float

Converts map element into a float or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

float args ot the element or default args if conversion is not supported.

get_as_float(key: str)float

Converts map element into a float or returns 0 if conversion is not possible.

Parameters

key – an index of element to get.

Returns

float args ot the element or 0 if conversion is not supported.

get_as_float_with_default(key: str, default_value: float)float

Converts map element into a float or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

float args ot the element or default args if conversion is not supported.

get_as_integer(key: str)int

Converts map element into an integer or returns 0 if conversion is not possible.

Parameters

key – an index of element to get.

Returns

integer args ot the element or 0 if conversion is not supported.

get_as_integer_with_default(key: str, default_value: int)int

Converts map element into an integer or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

integer args ot the element or default args if conversion is not supported.

get_as_long(key: str)float
get_as_long_with_default(key: str, default_value: float)float
get_as_map(key: str)pip_services3_commons.data.AnyValueMap.AnyValueMap

Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.

Parameters

key – a key of element to get.

Returns

AnyValueMap args of the element or empty AnyValueMap if conversion is not supported.

get_as_map_with_default(key: str, default_value: pip_services3_commons.data.AnyValueMap.AnyValueMap)pip_services3_commons.data.AnyValueMap.AnyValueMap

Converts map element into an AnyValueMap or returns default args if conversion is not possible.

Parameters
  • key – a key of element to get.

  • default_value – the default args

Returns

AnyValueMap args of the element or default args if conversion is not supported.

get_as_nullable_boolean(key: str) → Optional[bool, None]

Converts map element into a boolean or returns None if conversion is not possible

Parameters

key – an index of element to get.

Returns

boolean args of the element or None if conversion is not supported.

get_as_nullable_datetime(key: str) → Optional[datetime.datetime, None]

Converts map element into a Date or returns None if conversion is not possible.

Parameters

key – an index of element to get.

Returns

Date args of the element or None if conversion is not supported.

get_as_nullable_double(key: str) → Optional[float, None]

Converts map element into a float or returns None if conversion is not possible.

Parameters

key – an index of element to get.

Returns

float args of the element or None if conversion is not supported.

get_as_nullable_float(key: str) → Optional[float, None]

Converts map element into a float or returns None if conversion is not possible.

Parameters

key – an index of element to get.

Returns

float args of the element or None if conversion is not supported.

get_as_nullable_integer(key: str) → Optional[int, None]

Converts map element into an integer or returns None if conversion is not possible.

Parameters

key – an index of element to get.

Returns

integer args of the element or None if conversion is not supported.

get_as_nullable_long(key: str) → Optional[float, None]
get_as_nullable_map(key: str) → Optional[pip_services3_commons.data.AnyValueMap.AnyValueMap, None]

Converts map element into an AnyValueMap or returns None if conversion is not possible.

Parameters

key – a key of element to get.

Returns

AnyValueMap args of the element or None if conversion is not supported.

get_as_nullable_string(key: str)str

Converts map element into a string or returns None if conversion is not possible.

Parameters

key – an index of element to get.

Returns

string args of the element or None if conversion is not supported.

get_as_nullable_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode, key: str) → Any

Converts map element into a args defined by specied typecode. If conversion is not possible it returns None.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • key – an index of element to get.

Returns

element args defined by the typecode or None if conversion is not supported.

get_as_object(key: str = None) → Any

Gets the args stored in map element without any conversions. When element key is not defined it returns the entire map args.

Parameters

key – (optional) a key of the element to get

Returns

the element args or args of the map when index is not defined.

get_as_string(key: str)str

Converts map element into a string or returns “” if conversion is not possible.

Parameters

key – an index of element to get.

Returns

string args ot the element or “” if conversion is not supported.

get_as_string_with_default(key: str, default_value: str)str

Converts map element into a string or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

string args ot the element or default args if conversion is not supported.

get_as_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode, key: str) → Any

Converts map element into a args defined by specied typecode. If conversion is not possible it returns default args for the specified type.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • key – an index of element to get.

Returns

element args defined by the typecode or default if conversion is not supported.

get_as_type_with_default(value_type: pip_services3_commons.convert.TypeCode.TypeCode, key: str, default_value: Any) → Any

Converts map element into a args defined by specied typecode. If conversion is not possible it returns default args.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • key – an index of element to get.

  • default_value – the default args

Returns

element args defined by the typecode or default args if conversion is not supported.

get_as_value(key: str)AnyValue

Converts map element into an AnyValue or returns an empty AnyValue if conversion is not possible.

Parameters

key – a key of element to get.

Returns

AnyValue value of the element or empty AnyValue if conversion is not supported.

get_keys() → List[str]

Gets keys of all elements stored in this map.

Returns

a list with all map keys.

length()int

Gets a number of elements stored in this map.

Returns

the number of elements in this map.

put(key: str, value: Any) → Any

Puts a new args into map element specified by its key.

Parameters
  • key – a key of the element to put.

  • value – a new args for map element.

remove(key: str)

Removes a map element specified by its key

Parameters

key – a key of the element to remove.

set_as_map(values)

Sets values to map

Parameters

values – values to set

set_as_object(key: Any, value: Any = None)

Sets a new args to map element specified by its index. When the index is not defined, it resets the entire map args. This method has double purpose because method overrides are not supported in JavaScript.

Parameters
  • key – (optional) a key of the element to set

  • value – a new element or map args.

to_string()str

Gets a string representation of the object. The result is a semicolon-separated list of key-args pairs as “key1=value1;key2=value2;key=value3”

Returns

a string representation of the object.

class pip_services3_commons.data.DataPage(data: List[Any] = (), total: int = None)

Bases: object

Data transfer object that is used to pass results of paginated queries. It contains items of retrieved page and optional total number of items.

Most often this object type is used to send responses to paginated queries. Pagination parameters are defined by PagingParams object. The skip() parameter in the PagingParams there means how many items to skip. The takes() parameter sets number of items to return in the page. And the optional total() parameter tells to return total number of items in the query.

Remember: not all implementations support the total() parameter because its generation may lead to severe performance implications.

Example:

my_data_client.get_data_by_filter("123",
                                FilterParams.from_tuples("completed", true),
                                PagingParams(0, 100, true),
                                page)
for item in page.get_data():
    print (item)
static from_json(value)
to_json()
class pip_services3_commons.data.FilterParams(map: Any = None)

Bases: pip_services3_commons.data.StringValueMap.StringValueMap

Data transfer object used to pass filter parameters as simple key-args pairs.

Example:

filter = FilterParams.from_tuples("type", "Type1",
"from_create_time", datetime.datetime(2000, 0, 1),
"to_create_time", datetime.datetime.now(),
"completed", True)
paging = PagingParams(0, 100)

myDataClient.get_data_by_filter(filter, paging)
static from_string(line: str)pip_services3_commons.data.FilterParams.FilterParams

Parses semicolon-separated key-args pairs and returns them as a FilterParams.

Parameters

line – semicolon-separated key-args list to initialize FilterParams.

Returns

a newly created FilterParams.

static from_tuples(*tuples: Any)pip_services3_commons.data.FilterParams.FilterParams

Creates a new FilterParams from a list of key-args pairs called tuples.

Parameters

tuples – a list of values where odd elements are keys and the following even elements are values

Returns

a newly created FilterParams.

static from_value(value: Any)pip_services3_commons.data.FilterParams.FilterParams

Converts specified args into FilterParams.

Parameters

value – args to be converted

Returns

a newly created FilterParams.

class pip_services3_commons.data.IChangeable

Bases: abc.ABC

Interface for data objects that contain their latest change time.

Example:

class MyData(IStringIdentifiable, IChangeable):
    id: str = '1234567'
    field1: str = 'field1'
    field2: int = 123
    change_time: datetime = datetime.now()
change_time: datetime.datetime = None
class pip_services3_commons.data.ICloneable

Bases: object

Interface for data objects that are able to create their full binary copy.

Example:

class MyClass(IMyClass, ICloneable):
    def __init__():


    def clone(self):
        clone_obj = self.__init__()


        return clone_obj
clone() → Any

Creates a binary clone of this object.

Returns

a clone of this object.

class pip_services3_commons.data.IIdentifiable

Bases: abc.ABC

Generic interface for data objects that can be uniquely identified by an id.

The type specified in the interface defines the type of id field.

Example:

class MyData(IIdentifiable):
    id = None
id: Any
class pip_services3_commons.data.INamed

Bases: object

Interface for data objects that have human-readable names.

Example:

class MyData(IIdentifiable, INamed):
    id = None
    name = None
name: str = None
class pip_services3_commons.data.IStringIdentifiable

Bases: pip_services3_commons.data.IIdentifiable.IIdentifiable

Interface for data objects that can be uniquely identifed by a string id.

The interface extends IIdentifiable to hardcode id type to string.

It is a common pattern to use a string GUID as the id, generated by IdGenerator.

Example:

class MyData(IStringIdentifiable):
    id = None
id: str = None
class pip_services3_commons.data.ITrackable

Bases: pip_services3_commons.data.IChangeable.IChangeable

Interface for data objects that can track their changes, including logical deletion.

Example:

class MyData(IStringIdentifiable, ITrackable):
    id = None
    ...

    change_time = None
    create_time = None
    deleted = None
change_time: datetime.datetime = None
create_time: datetime.datetime = None
deleted: bool = None
class pip_services3_commons.data.IVersioned

Bases: abc.ABC

Interface for data objects that can be versioned.

Versioning is often used as optimistic concurrency mechanism.

The version doesn’t have to be a number, but it is recommended to use sequential values to determine if one object has newer or older version than another one.

It is a common pattern to use the time of change as the object version

Example:

class MyData(IStringIdentifiable, IVersioned):
    id = None
    version = None

    # do something

    def update_data(item):

        # do something

        if item.version < old_item.version:
            raise ConcurrencyException(None, "VERSION_CONFLICT", "The change has older version stored args")

    # do something
version: str = None
class pip_services3_commons.data.IdGenerator

Bases: object

Helper class to generate unique object IDs. It supports two types of IDs: long and short.

Long IDs are string GUIDs. They are globally unique and 32-character long. ShortIDs are just 9-digit random numbers. They are not guaranteed be unique.

Example:

IdGenerator.next_long()      # Possible result: "234ab342c56a2b49c2ab42bf23ff991ac"
IdGenerator.next_short()     # Possible result: "23495247"
static next_long()str

Generates a globally unique 32-digit object ID. The args is a string representation of a GUID args.

Returns

a generated 32-digit object ID

static next_short()str

Generates a random 9-digit random ID (code). Remember: The returned args is not guaranteed to be unique.

Returns

a generated random 9-digit code

class pip_services3_commons.data.MultiString(map: Any = None)

Bases: dict

Creates a new MultiString object and initializes it with values.

append(map: Any)

Appends a map with language-translation pairs.

Parameters

map – the map with language-translation pairs.

clear() → Any

Clears all translations from this MultiString object.

static from_tuples(*tuples: Any)pip_services3_commons.data.MultiString.MultiString

Creates a new MultiString object from language-translation pairs (tuples).

Parameters

tuples – an array that contains language-translation tuples.

Returns

a MultiString Object.

:see from_tuples_array

static from_tuples_array(tuples: Sequence[Any])pip_services3_commons.data.MultiString.MultiString

Creates a new MultiString object from language-translation pairs (tuples) specified as array.

Parameters

tuples – an array that contains language-translation tuples.

Returns

a MultiString Object.

static from_value(value: Any)pip_services3_commons.data.MultiString.MultiString

Creates a new MultiString object from a args that contains language-translation pairs.

Parameters

value – the args to initialize MultiString.

Returns

a MultiString object.

See StringValueMap

get(language: str)str

Gets a string translation by specified language. When language is not found it defaults to English (‘en’). When English is not found it takes the first args.

Parameters

language – a language two-symbol code.

Returns

a translation for the specified language or default translation.

get_languages() → List[str]

Gets all languages stored in this MultiString object,

Returns

a list with language codes.

length()int

Returns the number of translations stored in this MultiString object.

Returns

the number of translations.

put(language: str, value: Any)

Puts a new translation for the specified language.

Parameters
  • language – a language two-symbol code.

  • value – a new translation for the specified language.

remove(language: str)

Removes translation for the specified language.

Parameters

language – a language two-symbol code.

class pip_services3_commons.data.PagingParams(skip: int = None, take: int = None, total: bool = False)

Bases: object

Data transfer object to pass paging parameters for queries.

The page is defined by two parameters: - the skip() parameter defines number of items to skip. - the take() parameter sets how many items to return in a page. - additionally, the optional total() parameter tells to return total number of items in the query.

Remember: not all implementations support the total() parameter because its generation may lead to severe performance implications.

Example:

filter = FilterParams.fromTuples("type", "Type1")
paging = PagingParams(0, 100)

myDataClient.get_data_by_filter(filter, paging)
static from_json(value: Any)pip_services3_commons.data.PagingParams.PagingParams
static from_map(map: Any)pip_services3_commons.data.PagingParams.PagingParams

Creates a new PagingParams and sets it parameters from the specified map

Parameters

map – a AnyValueMap or StringValueMap to initialize this PagingParams

Returns

a newly created PagingParams.

static from_tuples(*tuples: Any)pip_services3_commons.data.PagingParams.PagingParams

Creates a new PagingParams from a list of key-args pairs called tuples.

Parameters

tuples – a list of values where odd elements are keys and the following even elements are values

Returns

a newly created PagingParams.

static from_value(value: Any)pip_services3_commons.data.PagingParams.PagingParams

Converts specified args into PagingParams.

Parameters

value – args to be converted

Returns

a newly created PagingParams.

get_skip(min_skip: int)int

Gets the number of items to skip.

Parameters

min_skip – the minimum number of items to skip.

Returns

the number of items to skip.

get_take(max_take: int)int

Gets the number of items to return in a page.

Parameters

max_take – the maximum number of items to return.

Returns

the number of items to return.

has_total()
to_json() → Dict[str, Any]
class pip_services3_commons.data.ProjectionParams(values: Sequence[Any] = None)

Bases: list

Defines projection parameters with list if fields to include into query results.

The parameters support two formats: dot format and nested format.

The dot format is the standard way to define included fields and subfields using dot object notation: “field1,field2.field21,field2.field22.field221”.

As alternative the nested format offers a more compact representation: “field1,field2(field21,field22(field221))”.

Example:

filter = FilterParams.fromTuples("type", "Type1")
paging = PagingParams(0, 100)
projection = ProjectionParams.from_value(["field1","field2(field21,field22)"])
   or projection = ProjectionParams.from_string("field1,field2(field21,field22)")

myDataClient.get_data_by_filter(filter, paging, projection)
default_delimiter = ','
static from_string(*values: str)pip_services3_commons.data.ProjectionParams.ProjectionParams

Parses comma-separated list of projection fields.

Parameters

values – one or more comma-separated lists of projection fields

Returns

a newly created ProjectionParams.

static from_value(value: Any)pip_services3_commons.data.ProjectionParams.ProjectionParams

Converts specified args into ProjectionParams.

Parameters

value – args to be converted

Returns

a newly created ProjectionParams.

to_string()str

Gets a string representation of the object. The result is a comma-separated list of projection fields “field1,field2.field21,field2.field22.field221”

Returns

a string representation of the object.

class pip_services3_commons.data.SortField(name: str, ascending: bool = True)

Bases: object

Defines a field name and order used to sort query results.

Example:

filter = FilterParams.fromTuples("type", "Type1")
paging = PagingParams(0, 100)
sorting = SortingParams(SortField("create_time", true))

myDataClient.get_data_by_filter(filter, paging, sorting)
class pip_services3_commons.data.SortParams(*fields: pip_services3_commons.data.SortField.SortField)

Bases: list

Defines a field name and order used to sort query results.

Example:

filter = FilterParams.fromTuples("type", "Type1")
paging = PagingParams(0, 100)
sorting = SortingParams(SortField("create_time", true))

myDataClient.get_data_by_filter(filter, paging, sorting)
class pip_services3_commons.data.StringValueMap(map: Any = None)

Bases: dict

Cross-language implementation of a map (dictionary) where all keys and values are strings. The stored values can be converted to different types using variety of accessor methods.

The string map is highly versatile. It can be converted into many formats, stored and sent over the wire.

This class is widely used in Pip.Services as a basis for variety of classes, such as ConfigParams, ConnectionParams, CredentialParams and others.

Example:

value1 = StringValueMap.fromString("key1=1;key2=123.456;key3=2018-01-01")
value1.get_as_boolean("key1")   // Result: true
value1.get_as_integer("key2")   // Result: 123
value1.get_as_float("key2")     // Result: 123.456
value1.get_as_datetime("key3")  // Result: Date 2018,0,1
append(map: Any)

Appends new elements to this map.

Parameters

map – a map with elements to be added.

clear()

Clears this map by removing all its elements.

clone() → Any

Creates a binary clone of this object.

Returns

a clone of this object.

static from_maps(*maps: dict)pip_services3_commons.data.StringValueMap.StringValueMap

Creates a new AnyValueMap by merging two or more maps. Maps defined later in the list override values from previously defined maps.

Parameters

maps – an array of maps to be merged

Returns

a newly created AnyValueMap.

static from_string(line: str)pip_services3_commons.data.StringValueMap.StringValueMap

Parses semicolon-separated key-args pairs and returns them as a StringValueMap.

Parameters

line – semicolon-separated key-args list to initialize StringValueMap.

Returns

a newly created StringValueMap.

static from_tuples(*tuples: Any)pip_services3_commons.data.StringValueMap.StringValueMap

Creates a new StringValueMap from a list of key-args pairs called tuples.

Parameters

tuples – a list of values where odd elements are keys and the following even elements are values

Returns

a newly created StringValueMap.

static from_tuples_array(tuples: Sequence[Any])pip_services3_commons.data.StringValueMap.StringValueMap

Creates a new StringValueMap from a list of key-args pairs called tuples. The method is similar to from_tuples() but tuples are passed as array instead of parameters.

Parameters

tuples – a list of values where odd elements are keys and the following even elements are values

Returns

a newly created StringValueMap.

static from_value(value: Any)pip_services3_commons.data.StringValueMap.StringValueMap

Converts specified args into StringValueMap.

Parameters

value – args to be converted

Returns

a newly created StringValueMap.

get(key: str)str

Gets a map element specified by its key.

Parameters

key – a key of the element to get.

Returns

the args of the map element.

get_as_array(key: str)pip_services3_commons.data.AnyValueArray.AnyValueArray

Converts map element into an AnyValue or returns an empty AnyValue if conversion is not possible.

Parameters

key – a key of element to get.

Returns

AnyValue value of the element or empty AnyValue if conversion is not supported.

get_as_array_with_default(key: str, default_value: pip_services3_commons.data.AnyValueArray.AnyValueArray)pip_services3_commons.data.AnyValueArray.AnyValueArray

Converts map element into an AnyValueArray or returns default value if conversion is not possible.

Parameters
  • key – a key of element to get.

  • default_value – the default value

Returns

AnyValueArray value of the element or default value if conversion is not supported.

get_as_boolean(key: str)bool

Converts map element into a boolean or returns false if conversion is not possible.

Parameters

key – an index of element to get.

Returns

boolean args ot the element or false if conversion is not supported.

get_as_boolean_with_default(key: str, default_value: bool)bool

Converts map element into a boolean or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

boolean args ot the element or default args if conversion is not supported.

get_as_datetime(key: str)datetime.datetime

Converts map element into a Date or returns the current date if conversion is not possible.

Parameters

key – an index of element to get.

Returns

Date args ot the element or the current date if conversion is not supported.

get_as_datetime_with_default(key: str, default_value: datetime.datetime)datetime.datetime

Converts map element into a Date or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

Date args ot the element or default args if conversion is not supported.

get_as_double(key: str)float

Converts map element into a double or returns 0 if conversion is not possible.

Parameters

key – an index of element to get.

Returns

double value of the element or 0 if conversion is not supported.

get_as_double_with_default(key: str, default_value: float)float

Converts map element into a double or returns default value if conversion is not possible.

Parameters
  • key – a key of element to get.

  • default_value – the default args

Returns

double value of the element or default value if conversion is not supported.

get_as_float(key: str)float

Converts map element into a float or returns 0 if conversion is not possible.

Parameters

key – an index of element to get.

Returns

float args ot the element or 0 if conversion is not supported.

get_as_float_with_default(key: str, default_value: float)float

Converts map element into a float or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

float args ot the element or default args if conversion is not supported.

get_as_integer(key: str)int

Converts map element into an integer or returns 0 if conversion is not possible.

Parameters

key – an index of element to get.

Returns

integer args ot the element or 0 if conversion is not supported.

get_as_integer_with_default(key: str, default_value: int)int

Converts map element into an integer or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

integer args ot the element or default args if conversion is not supported.

get_as_long(key: str)float
get_as_long_with_default(key: str, default_value: float)float
get_as_map(key: Any)pip_services3_commons.data.AnyValueMap.AnyValueMap

Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.

Parameters

key – a key of element to get.

Returns

AnyValueMap args of the element or empty AnyValueMap if conversion is not supported.

get_as_map_with_default(key: str, default_value: pip_services3_commons.data.AnyValueMap.AnyValueMap)pip_services3_commons.data.AnyValueMap.AnyValueMap

Converts map element into an AnyValueMap or returns default args if conversion is not possible.

Parameters
  • key – a key of element to get.

  • default_value – the default args

Returns

AnyValueMap args of the element or default args if conversion is not supported.

get_as_nullable_array(key: str) → Optional[pip_services3_commons.data.AnyValueArray.AnyValueArray, None]

Converts map element into an AnyValueArray or returns null if conversion is not possible.

Parameters

key – a key of element to get.

Returns

AnyValueArray value of the element or null if conversion is not supported.

get_as_nullable_boolean(key: str) → Optional[bool, None]

Converts map element into a boolean or returns None if conversion is not possible

Parameters

key – an index of element to get.

Returns

boolean args of the element or None if conversion is not supported.

get_as_nullable_datetime(key: str) → Optional[datetime.datetime, None]

Converts map element into a Date or returns None if conversion is not possible.

Parameters

key – an index of element to get.

Returns

Date args of the element or None if conversion is not supported.

get_as_nullable_double(key: str) → Optional[float, None]

Converts map element into a double or returns null if conversion is not possible.

Parameters

key – an index of element to get.

Returns

double value of the element or null if conversion is not supported.

get_as_nullable_float(key: str) → Optional[float, None]

Converts map element into a float or returns None if conversion is not possible.

Parameters

key – an index of element to get.

Returns

float args of the element or None if conversion is not supported.

get_as_nullable_integer(key: str) → Optional[int, None]

Converts map element into an integer or returns None if conversion is not possible.

Parameters

key – an index of element to get.

Returns

integer args of the element or None if conversion is not supported.

get_as_nullable_long(key: str) → Optional[float, None]
get_as_nullable_map(key: str)pip_services3_commons.data.AnyValueMap.AnyValueMap

Converts map element into an AnyValueMap or returns None if conversion is not possible.

Parameters

key – a key of element to get.

Returns

AnyValueMap args of the element or None if conversion is not supported.

get_as_nullable_string(key: str) → Optional[str, None]

Converts map element into a string or returns None if conversion is not possible.

Parameters

key – an index of element to get.

Returns

string args of the element or None if conversion is not supported.

get_as_nullable_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode, key: str) → Optional[Any, None]

Converts map element into a args defined by specied typecode. If conversion is not possible it returns None.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • key – an index of element to get.

Returns

element args defined by the typecode or None if conversion is not supported.

get_as_object(key: str = None) → Any

Gets the args stored in map element without any conversions. When element key is not defined it returns the entire map args.

Parameters

key – (optional) a key of the element to get

Returns

the element args or args of the map when index is not defined.

get_as_string(key: str)str

Converts map element into a string or returns “” if conversion is not possible.

Parameters

key – an index of element to get.

Returns

string args ot the element or “” if conversion is not supported.

get_as_string_with_default(key: str, default_value: str)str

Converts map element into a string or returns default args if conversion is not possible.

Parameters
  • key – an index of element to get.

  • default_value – the default args

Returns

string args ot the element or default args if conversion is not supported.

get_as_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode, key: str) → Any

Converts map element into a args defined by specied typecode. If conversion is not possible it returns default args for the specified type.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • key – an index of element to get.

Returns

element args defined by the typecode or default if conversion is not supported.

get_as_type_with_default(value_type: pip_services3_commons.convert.TypeCode.TypeCode, key: str, default_value: Any) → Any

Converts map element into a args defined by specied typecode. If conversion is not possible it returns default args.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • key – an index of element to get.

  • default_value – the default args

Returns

element args defined by the typecode or default args if conversion is not supported.

get_as_value(key: str)pip_services3_commons.data.AnyValue.AnyValue

Converts map element into an AnyValue or returns an empty AnyValue if conversion is not possible.

Parameters

key – a key of element to get.

Returns

AnyValue value of the element or empty AnyValue if conversion is not supported.

get_keys() → List[str]

Gets keys of all elements stored in this map.

Returns

a list with all map keys.

length()int

Gets a number of elements stored in this map.

Returns

the number of elements in this map.

put(key: str, value: Any)

Puts a new args into map element specified by its key.

Parameters
  • key – a key of the element to put.

  • value – a new args for map element.

remove(key: str)

Removes a map element specified by its key

Parameters

key – a key of the element to remove.

set_as_map(values: dict)

Sets values to map

Parameters

values – values to set

set_as_object(key: Any, value: Any = None)

Sets a new args to map element specified by its index. When the index is not defined, it resets the entire map args. This method has double purpose because method overrides are not supported in JavaScript.

Parameters
  • key – (optional) a key of the element to set

  • value – a new element or map value.

to_string()

Gets a string representation of the object. The result is a semicolon-separated list of key-args pairs as “key1=value1;key2=value2;key=value3”

Returns

a string representation of the object.

class pip_services3_commons.data.TagsProcessor

Bases: object

Helper class to extract and process search tags from objects. The search tags can be kept individually or embedded as hash tags inside text like “This text has #hash_tag that can be used for search.”

static compress_tag(tag: str)str

Compress a tag by removing special symbols like spaces, ‘_’ and ‘#’ and converting the tag to lower case. When tags are compressed they can be matched in search queries.

Parameters

tag – the tag to compress.

Returns

a compressed tag.

static compress_tag_list(tag_list: str) → List[str]

Compresses a comma-separated list of tags.

Parameters

tag_list – a comma-separated list of tags to compress.

Returns

a list with compressed tags.

static compress_tags(tags: List[str]) → List[str]

Compresses a comma-separated list of tags.

Parameters

tags – a comma-separated list of tags to compress.

Returns

a list with compressed tags.

static equal_tags(tag1: str, tag2: str)bool

Compares two tags using their compressed form.

Parameters
  • tag1 – the first tag.

  • tag2 – the second tag.

Returns

true if the tags are equal and false otherwise.

static extract_hash_tags(text: str) → List[str]

Extracts hash tags from a text.

Parameters

text – a text that contains hash tags

Returns

a list with extracted and compressed tags.

static extract_hash_tags_from_value(obj: Any, *search_fields: str) → List[str]

Extracts hash tags from selected fields in an object.

Parameters
  • obj – an object which contains hash tags.

  • search_fields – a list of fields in the objects where to extract tags

Returns

a list of extracted and compressed tags.

static normalize_tag(tag: str) → Optional[str, None]

Normalizes a tag by replacing special symbols like ‘_’ and ‘#’ with spaces. When tags are normalized then can be presented to user in similar shape and form.

Parameters

tag – the tag to normalize.

Returns

a normalized tag.

static normalize_tag_list(tag_list: str) → List[str]

Normalizes a comma-separated list of tags.

Parameters

tag_list – a comma-separated list of tags to normalize.

Returns

a list with normalized tags.

static normalize_tags(tags: List[str]) → List[str]

Normalizes a list of tags.

Parameters

tags – the tags to normalize.

Returns

a list with normalized tags.

class pip_services3_commons.data.TokenizedDataPage(data: List[Any], token: str = None, total: int = None)

Bases: object

Data transfer object that is used to pass results of paginated queries. It contains items of retrieved page and optional total number of items.

Most often this object type is used to send responses to paginated queries. Pagination parameters are defined by TokenizedPagingParams object. The token parameter in the TokenizedPagingParams there means where to start the searxh. The takes parameter sets number of items to return in the page. And the optional total parameter tells to return total number of items in the query.

The data page returns a token that shall be passed to the next search as a starting point.

Remember: not all implementations support the total parameter because its generation may lead to severe performance implications.

See PagingParams

Example:

page = my_data_client.get_data_by_filter(
    "123",
    FilterParams.from_tuples("completed", True),
    TokenizedPagingParams(None, 100, True)
)
class pip_services3_commons.data.TokenizedPagingParams(token: str = None, take: int = None, total: bool = None)

Bases: object

Data transfer object to pass tokenized paging parameters for queries. It can be used for complex paging scenarios, like paging across multiple databases where the previous state is encoded in a token. The token is usually retrieved from the previous response. The initial request shall go with token == None

The page is defined by two parameters: - the token token that defines a starting point for the search. - the take parameter sets how many items to return in a page. - additionally, the optional total parameter tells to return total number of items in the query.

Remember: not all implementations support the total parameter because its generation may lead to severe performance implications.

Example:

filter = FilterParams.from_tuples("type", "Type1");
paging = TokenizedPagingParams(None, 100);

result = my_data_client.get_data_by_filter(filter, paging)
static from_map(map: pip_services3_commons.data.AnyValueMap.AnyValueMap)pip_services3_commons.data.TokenizedPagingParams.TokenizedPagingParams

Creates a new TokenizedPagingParams and sets it parameters from the specified map

Parameters

map – a AnyValueMap or StringValueMap to initialize this TokenizedPagingParams

Returns

a newly created PagingParams.

static from_tuple(*tuples: Any)pip_services3_commons.data.TokenizedPagingParams.TokenizedPagingParams

Creates a new TokenizedPagingParams from a list of key-value pairs called tuples.

Parameters

tuples – a list of values where odd elements are keys and the following even elements are values

Returns

a newly created TokenizedPagingParams.

static from_value(value: Any)pip_services3_commons.data.TokenizedPagingParams.TokenizedPagingParams

Converts specified value into TokenizedPagingParams.

Parameters

value – value to be converted

Returns

a newly created PagingParams.

get_take(max_take: int)int

Gets the number of items to return in a page.

Parameters

max_take – the maximum number of items to return.

Returns

the number of items to return.