nanoping-api 11.1.0.dev0__tar.gz → 12.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: nanoping-api
3
- Version: 11.1.0.dev0
3
+ Version: 12.0.0
4
4
  Summary: Typed client for the NanoPing REST API
5
5
  Project-URL: Homepage, https://nanoping.com
6
6
  Project-URL: Documentation, https://docs.nanoping.com/api/reference
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nanoping-api"
7
- version = "11.1.0.dev0"
7
+ version = "12.0.0"
8
8
  description = "Typed client for the NanoPing REST API"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -106,6 +106,12 @@ __all__ = [
106
106
  "Int64Metric",
107
107
  "Kind",
108
108
  "Kpi",
109
+ "KpiFieldHistory",
110
+ "KpiHistory",
111
+ "KpiHistoryBucket",
112
+ "KpiHistoryPoint",
113
+ "KpiHistorySpan",
114
+ "KpiHistoryValueCount",
109
115
  "Level",
110
116
  "LogFileChunk",
111
117
  "LogStreamMessages",
@@ -1150,7 +1156,10 @@ class Network:
1150
1156
  Example: `{ "raft_timeout": 9000, "loss_emulation_percentage": 1 }`
1151
1157
  """
1152
1158
  relay_node_id: str = ""
1153
- """The node ID of the relay node. Must be the node that has networks enabled."""
1159
+ """The node ID of the relay node. On a hub of your own it must be the node that
1160
+ keeps the networks. On the cloud hub it can be any node on the hub, and is empty
1161
+ until one is chosen. Once set, it cannot be cleared.
1162
+ """
1154
1163
  nodes: list[NetworksNode] = dataclasses.field(default_factory=list)
1155
1164
  """The nodes in the network, each with its assigned IP address and carriers."""
1156
1165
 
@@ -1613,6 +1622,105 @@ class Kpi:
1613
1622
  """An 8-bit enum value, as its number."""
1614
1623
 
1615
1624
 
1625
+ @dataclasses.dataclass(kw_only=True)
1626
+ class KpiFieldHistory:
1627
+ """The history of one field of a KPI."""
1628
+
1629
+ id: str = ""
1630
+ """ID of the KPI."""
1631
+ field: str = ""
1632
+ """Path of the KPI field, such as `expression`. The history of a Value To Text
1633
+ Conditions KPI has the field `condition`, with the index of the first condition
1634
+ that held, or none when none did.
1635
+ """
1636
+ buckets: list[KpiHistoryBucket] = dataclasses.field(default_factory=list)
1637
+ """The numbers the field was evaluated to, per bucket, oldest first. Buckets without
1638
+ any are left out.
1639
+ """
1640
+ spans: list[KpiHistorySpan] = dataclasses.field(default_factory=list)
1641
+ """The values that are not numbers, such as text, true or false, none and errors,
1642
+ oldest first. The values of a KPI shown as text are all spans, numbers too.
1643
+ """
1644
+
1645
+
1646
+ @dataclasses.dataclass(kw_only=True)
1647
+ class KpiHistory:
1648
+ """The KPI history of a pipeline run, split into buckets of time."""
1649
+
1650
+ bucket_width_ms: int = 0
1651
+ """How long each bucket is, in milliseconds. Buckets start at multiples of it,
1652
+ counted from 1970.
1653
+ """
1654
+ poll_interval_ms: int = 0
1655
+ """How often the KPIs were evaluated, in milliseconds."""
1656
+ fields: list[KpiFieldHistory] = dataclasses.field(default_factory=list)
1657
+ """The history of each KPI field."""
1658
+
1659
+
1660
+ @dataclasses.dataclass(kw_only=True)
1661
+ class KpiHistoryBucket:
1662
+ """The numbers a KPI field was evaluated to within one bucket."""
1663
+
1664
+ start: datetime.datetime | None = None
1665
+ """When the bucket starts."""
1666
+ count: int = 0
1667
+ """How many numbers the bucket holds."""
1668
+ sum: float = 0.0
1669
+ """The sum of the numbers, for their average."""
1670
+ min: KpiHistoryPoint = dataclasses.field(default_factory=lambda: KpiHistoryPoint())
1671
+ """The lowest number."""
1672
+ max: KpiHistoryPoint = dataclasses.field(default_factory=lambda: KpiHistoryPoint())
1673
+ """The highest number."""
1674
+ first: KpiHistoryPoint = dataclasses.field(default_factory=lambda: KpiHistoryPoint())
1675
+ """The first number."""
1676
+ last: KpiHistoryPoint = dataclasses.field(default_factory=lambda: KpiHistoryPoint())
1677
+ """The last number."""
1678
+
1679
+
1680
+ @dataclasses.dataclass(kw_only=True)
1681
+ class KpiHistoryPoint:
1682
+ """A number a KPI field was evaluated to."""
1683
+
1684
+ time: datetime.datetime | None = None
1685
+ """When it was evaluated."""
1686
+ value: float = 0.0
1687
+ """The number."""
1688
+
1689
+
1690
+ @dataclasses.dataclass(kw_only=True)
1691
+ class KpiHistorySpan:
1692
+ """A stretch of time over which a KPI field was evaluated to values other than
1693
+ numbers, or to the values of a KPI shown as text.
1694
+ """
1695
+
1696
+ start: datetime.datetime | None = None
1697
+ """When the span starts."""
1698
+ end: datetime.datetime | None = None
1699
+ """When the last value of the span stopped holding, one poll interval after it was
1700
+ evaluated.
1701
+ """
1702
+ value: Kpi = dataclasses.field(default_factory=lambda: Kpi())
1703
+ """The value over the whole span, when it did not change. Its id and field are left
1704
+ empty.
1705
+ """
1706
+ counts: list[KpiHistoryValueCount] = dataclasses.field(default_factory=list)
1707
+ """When the value changed within the span: how many times each value was evaluated,
1708
+ in the order they first came up.
1709
+ """
1710
+ changes: int = 0
1711
+ """How many times the value changed within the span."""
1712
+
1713
+
1714
+ @dataclasses.dataclass(kw_only=True)
1715
+ class KpiHistoryValueCount:
1716
+ """How many times a KPI field was evaluated to a value within a span."""
1717
+
1718
+ value: Kpi = dataclasses.field(default_factory=lambda: Kpi())
1719
+ """The value. Its id and field are left empty."""
1720
+ count: int = 0
1721
+ """How many times it was evaluated."""
1722
+
1723
+
1616
1724
  @dataclasses.dataclass(kw_only=True)
1617
1725
  class LogStreamMessages:
1618
1726
  """A batch of log messages from a pipeline run."""
@@ -1643,6 +1751,21 @@ class OpenTelemetryStreamRequest:
1643
1751
  """ID of the node that hosts the run."""
1644
1752
  run_id: str = ""
1645
1753
  """ID of the run to stream telemetry from."""
1754
+ include_kpi_history: bool = False
1755
+ """Send the KPIs the node has recorded for the run before the live telemetry, split
1756
+ into buckets of time. The node keeps them for 24 hours by default, or as long as
1757
+ `pipelines.kpiHistoryRetentionMinutes` says. A run that has stopped only has its
1758
+ history sent.
1759
+ """
1760
+ kpi_history_start: datetime.datetime | None = None
1761
+ """From when to send the KPI history. Unset starts with the oldest the node keeps.
1762
+ """
1763
+ kpi_history_end: datetime.datetime | None = None
1764
+ """Until when to send the KPI history. Unset goes on to the latest."""
1765
+ kpi_history_max_buckets: int = 0
1766
+ """The most buckets to split the KPI history into. 0 uses the default of 600, and
1767
+ more than 10000 are not sent.
1768
+ """
1646
1769
 
1647
1770
 
1648
1771
  @dataclasses.dataclass(kw_only=True)
@@ -1831,6 +1954,16 @@ class TelemetrySample:
1831
1954
  """The KPI values of the run."""
1832
1955
  timestamp: datetime.datetime | None = None
1833
1956
  """When the sample was taken."""
1957
+ kpi_history: KpiHistory = dataclasses.field(default_factory=lambda: KpiHistory())
1958
+ """A part of the KPI history of the run, when it was asked for. The history is sent
1959
+ in parts before the live samples, in samples with no metrics, KPIs or timestamp.
1960
+ A field can be split over parts, and its buckets and spans then carry on in the
1961
+ next part. The live samples leave out the KPIs the history already holds.
1962
+ """
1963
+ kpi_history_complete: bool = False
1964
+ """Set on the last part of the KPI history. Live samples follow it. Sent with an
1965
+ empty history when the run has none.
1966
+ """
1834
1967
 
1835
1968
 
1836
1969
  @dataclasses.dataclass(kw_only=True)
@@ -1959,8 +2092,8 @@ class BlueprintsClient:
1959
2092
  node. Every network uses three blueprints: one for the relay node, one the relay
1960
2093
  runs for every client, and one for every client node. The built-in blueprints are
1961
2094
  read-only; create your own to change how networks carry traffic. Blueprints are
1962
- stored on the connected node that has networks enabled, and calls wait until that
1963
- node is connected.
2095
+ kept by the hub's network service, which keeps its networks, and calls wait until
2096
+ it is connected.
1964
2097
  """
1965
2098
 
1966
2099
  def __init__(self, transport: Transport) -> None:
@@ -2534,8 +2667,10 @@ class NetworksClient:
2534
2667
  relay node. When a network is created or changed, the pipelines each node needs
2535
2668
  are generated from the network's blueprints and deployed automatically. Use this
2536
2669
  service to create and change networks and to follow their changes and logs.
2537
- Networks are stored on the connected node that has networks enabled, and calls
2538
- wait until that node is connected.
2670
+ Networks are kept by the hub's network service: on the cloud hub its own, under
2671
+ the node ID `networks`, and on a hub of your own the node that has networks
2672
+ enabled (the one with the lowest ID if several do). Calls wait until it is
2673
+ connected.
2539
2674
  """
2540
2675
 
2541
2676
  def __init__(self, transport: Transport) -> None:
@@ -2977,20 +3112,45 @@ class PipelinesServiceClient:
2977
3112
  *,
2978
3113
  node_id: str = "",
2979
3114
  run_id: str = "",
3115
+ include_kpi_history: bool = False,
3116
+ kpi_history_start: datetime.datetime | None = None,
3117
+ kpi_history_end: datetime.datetime | None = None,
3118
+ kpi_history_max_buckets: int = 0,
2980
3119
  ) -> ServerStream[TelemetrySample]:
2981
3120
  """Streams telemetry samples (metrics and KPI values) of a pipeline run at
2982
- regular intervals while the run is active. The stream ends with an error when
2983
- the run stops, when the run is unknown, or when the node disconnects.
3121
+ regular intervals while the run is active. When the KPI history is asked for,
3122
+ the KPIs the node has recorded for the run are sent first, oldest first, in
3123
+ samples that hold only history, and the last of them is marked complete. The
3124
+ stream ends with an error when the run stops, when the run is unknown, or
3125
+ when the node disconnects.
2984
3126
 
2985
3127
  Args:
2986
3128
  node_id: ID of the node that hosts the run.
2987
3129
  run_id: ID of the run to stream telemetry from.
3130
+ include_kpi_history: Send the KPIs the node has recorded for the run
3131
+ before the live telemetry, split into buckets of time. The node keeps
3132
+ them for 24 hours by default, or as long as
3133
+ `pipelines.kpiHistoryRetentionMinutes` says. A run that has stopped only
3134
+ has its history sent.
3135
+ kpi_history_start: From when to send the KPI history. Unset starts with
3136
+ the oldest the node keeps.
3137
+ kpi_history_end: Until when to send the KPI history. Unset goes on to
3138
+ the latest.
3139
+ kpi_history_max_buckets: The most buckets to split the KPI history into.
3140
+ 0 uses the default of 600, and more than 10000 are not sent.
2988
3141
  """
2989
3142
  return self._transport.server_stream(
2990
3143
  [
2991
3144
  Route("GET", "/v1/streams/nodes/{node_id}/pipeline-runs/{run_id}/telemetry", ""),
2992
3145
  ],
2993
- OpenTelemetryStreamRequest(node_id=node_id, run_id=run_id),
3146
+ OpenTelemetryStreamRequest(
3147
+ node_id=node_id,
3148
+ run_id=run_id,
3149
+ include_kpi_history=include_kpi_history,
3150
+ kpi_history_start=kpi_history_start,
3151
+ kpi_history_end=kpi_history_end,
3152
+ kpi_history_max_buckets=kpi_history_max_buckets,
3153
+ ),
2994
3154
  TelemetrySample,
2995
3155
  )
2996
3156
 
@@ -3050,8 +3210,8 @@ class AsyncBlueprintsClient:
3050
3210
  node. Every network uses three blueprints: one for the relay node, one the relay
3051
3211
  runs for every client, and one for every client node. The built-in blueprints are
3052
3212
  read-only; create your own to change how networks carry traffic. Blueprints are
3053
- stored on the connected node that has networks enabled, and calls wait until that
3054
- node is connected.
3213
+ kept by the hub's network service, which keeps its networks, and calls wait until
3214
+ it is connected.
3055
3215
  """
3056
3216
 
3057
3217
  def __init__(self, transport: AsyncTransport) -> None:
@@ -3627,8 +3787,10 @@ class AsyncNetworksClient:
3627
3787
  relay node. When a network is created or changed, the pipelines each node needs
3628
3788
  are generated from the network's blueprints and deployed automatically. Use this
3629
3789
  service to create and change networks and to follow their changes and logs.
3630
- Networks are stored on the connected node that has networks enabled, and calls
3631
- wait until that node is connected.
3790
+ Networks are kept by the hub's network service: on the cloud hub its own, under
3791
+ the node ID `networks`, and on a hub of your own the node that has networks
3792
+ enabled (the one with the lowest ID if several do). Calls wait until it is
3793
+ connected.
3632
3794
  """
3633
3795
 
3634
3796
  def __init__(self, transport: AsyncTransport) -> None:
@@ -4070,20 +4232,45 @@ class AsyncPipelinesServiceClient:
4070
4232
  *,
4071
4233
  node_id: str = "",
4072
4234
  run_id: str = "",
4235
+ include_kpi_history: bool = False,
4236
+ kpi_history_start: datetime.datetime | None = None,
4237
+ kpi_history_end: datetime.datetime | None = None,
4238
+ kpi_history_max_buckets: int = 0,
4073
4239
  ) -> AsyncServerStream[TelemetrySample]:
4074
4240
  """Streams telemetry samples (metrics and KPI values) of a pipeline run at
4075
- regular intervals while the run is active. The stream ends with an error when
4076
- the run stops, when the run is unknown, or when the node disconnects.
4241
+ regular intervals while the run is active. When the KPI history is asked for,
4242
+ the KPIs the node has recorded for the run are sent first, oldest first, in
4243
+ samples that hold only history, and the last of them is marked complete. The
4244
+ stream ends with an error when the run stops, when the run is unknown, or
4245
+ when the node disconnects.
4077
4246
 
4078
4247
  Args:
4079
4248
  node_id: ID of the node that hosts the run.
4080
4249
  run_id: ID of the run to stream telemetry from.
4250
+ include_kpi_history: Send the KPIs the node has recorded for the run
4251
+ before the live telemetry, split into buckets of time. The node keeps
4252
+ them for 24 hours by default, or as long as
4253
+ `pipelines.kpiHistoryRetentionMinutes` says. A run that has stopped only
4254
+ has its history sent.
4255
+ kpi_history_start: From when to send the KPI history. Unset starts with
4256
+ the oldest the node keeps.
4257
+ kpi_history_end: Until when to send the KPI history. Unset goes on to
4258
+ the latest.
4259
+ kpi_history_max_buckets: The most buckets to split the KPI history into.
4260
+ 0 uses the default of 600, and more than 10000 are not sent.
4081
4261
  """
4082
4262
  return self._transport.server_stream(
4083
4263
  [
4084
4264
  Route("GET", "/v1/streams/nodes/{node_id}/pipeline-runs/{run_id}/telemetry", ""),
4085
4265
  ],
4086
- OpenTelemetryStreamRequest(node_id=node_id, run_id=run_id),
4266
+ OpenTelemetryStreamRequest(
4267
+ node_id=node_id,
4268
+ run_id=run_id,
4269
+ include_kpi_history=include_kpi_history,
4270
+ kpi_history_start=kpi_history_start,
4271
+ kpi_history_end=kpi_history_end,
4272
+ kpi_history_max_buckets=kpi_history_max_buckets,
4273
+ ),
4087
4274
  TelemetrySample,
4088
4275
  )
4089
4276