Endpoints API
Introduction
The Endpoints API consists of the following endpoints, accessible from the Endpoint
class:
Initialize an Endpoint
object with:
where:
id
is the function/object you want to monitorendpoint
is the designated endpointhits
is the number of hits received by that endpoint
pymetrix.endpoints.Endpoint.hitcount
(Property)
Returns an integer value denoting the number of hits corresponding to the endpoint, including the current hit.
NOTE: Every time you access this property, the hit count for a particular endpoint is increased by one. In case you want to just get the current hits programmatically, use the stats()
method instead.
pymetrix.endpoints.Endpoint.stats()
Returns the number of hits corresponding to the endpoint, including the current hit, WITHOUT increasing the hit count of the endpoint.
Response format:
pymetrix.endpoints.Endpoint.get_endpoint()
Returns a callable
object denoting the endpoint function of the endpoint.
pymetrix.endpoints.Endpoint.set_endpoint(val: callable)
An optional setter method to change the function of the endpoint, should the need arise.
Arguments:
val
: The callable object containing the function you want to set the endpoint name to.
pymetrix.endpoints.Endpoint.serialize
(Property)
This returns the serialized state of the Endpoint
, containing the callable along with the memory segment.
NOTE: The output isn't JSON serializable, although it can be pickled. For JSON serializable output, use the pretty_serialize
property.
Response Format:
pymetrix.endpoints.Endpoint.pretty_serialize
(Property)
This gives the JSON serializable state representation of the Endpoint
object. You can save it in a JSON file, export it as a JSON object, etc.
Response Format: