qontract-reconcile 0.10.1rc790__py3-none-any.whl → 0.10.1rc791__py3-none-any.whl

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.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc790
3
+ Version: 0.10.1rc791
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Home-page: https://github.com/app-sre/qontract-reconcile
6
6
  Author: Red Hat App-SRE Team
@@ -429,7 +429,7 @@ reconcile/skupper_network/models.py,sha256=DNTI7HZv-rqY42GIIxyRuvroHLvdH6rJerjIq
429
429
  reconcile/skupper_network/reconciler.py,sha256=XS-1oKBr_1l3dYUAVqUH6gCHg1G5ZuOfY_7fgGVAiFA,9996
430
430
  reconcile/skupper_network/site_controller.py,sha256=A3K-62BjJ5HiFVydV0ouGoD1NwrO7XhAH15BHAcS9fk,1550
431
431
  reconcile/statuspage/__init__.py,sha256=o9vR6sp3ARDQFZrbCEShelTxjF1XgfLaElK_QVt_248,261
432
- reconcile/statuspage/atlassian.py,sha256=zXsO9qx_pqfk2TDSoa1JSv6UvY2nVsJAp6rRWuEcG24,13258
432
+ reconcile/statuspage/atlassian.py,sha256=IxtGHd4GXYlJ2Qt3k-MfylM-SIYS7DYaCpjtQvPAmbY,13758
433
433
  reconcile/statuspage/integration.py,sha256=---tzyl381RddAkIhXb7n3ySjUhuX7FBBI152SYsRfk,3654
434
434
  reconcile/statuspage/page.py,sha256=cJH2sDA8jiAmSdaDitQqNjkyDq_UP2w3s7eauCi-yt4,3740
435
435
  reconcile/statuspage/state.py,sha256=HD9EOoKm_nEqCMLIwW809En3cq5VhyzKJPUbsh-bae8,1617
@@ -785,8 +785,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
785
785
  tools/test/test_qontract_cli.py,sha256=w2l4BHB09k1d-BGJ1jBUNCqDv7zkqYrMHojQXg-21kQ,4155
786
786
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
787
787
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
788
- qontract_reconcile-0.10.1rc790.dist-info/METADATA,sha256=hGlhrIUEP7Ra-X9cEXOBXPCZA0mMazOKnqwWsMKfd6g,2364
789
- qontract_reconcile-0.10.1rc790.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
790
- qontract_reconcile-0.10.1rc790.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
791
- qontract_reconcile-0.10.1rc790.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
792
- qontract_reconcile-0.10.1rc790.dist-info/RECORD,,
788
+ qontract_reconcile-0.10.1rc791.dist-info/METADATA,sha256=fZl69FcdS3wj97ZwyE1VwTV42kLiyLmoNcZ0yrB7T9Q,2364
789
+ qontract_reconcile-0.10.1rc791.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
790
+ qontract_reconcile-0.10.1rc791.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
791
+ qontract_reconcile-0.10.1rc791.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
792
+ qontract_reconcile-0.10.1rc791.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ import time
2
3
  from typing import (
3
4
  Any,
4
5
  Optional,
@@ -8,6 +9,8 @@ from typing import (
8
9
  import requests
9
10
  import statuspageio # type: ignore
10
11
  from pydantic import BaseModel
12
+ from requests import Response
13
+ from sretoolbox.utils import retry
11
14
 
12
15
  from reconcile.gql_definitions.statuspage.statuspages import StatusPageV1
13
16
  from reconcile.statuspage.page import (
@@ -60,25 +63,35 @@ class LegacyLibAtlassianAPI:
60
63
  self.page_id = page_id
61
64
  self.api_url = api_url
62
65
  self.token = token
66
+ self.auth_headers = {"Authorization": f"OAuth {self.token}"}
63
67
  self._client = statuspageio.Client(
64
68
  api_key=self.token, page_id=self.page_id, organization_id="unset"
65
69
  )
66
70
 
71
+ @retry(max_attempts=10)
72
+ def _do_get(self, url: str, params: dict[str, Any]) -> Response:
73
+ response = requests.get(
74
+ url, params=params, headers=self.auth_headers, timeout=30
75
+ )
76
+ response.raise_for_status()
77
+ return response
78
+
67
79
  def list_components(self) -> list[AtlassianRawComponent]:
68
80
  url = f"{self.api_url}/v1/pages/{self.page_id}/components"
69
- headers = {"Authorization": f"OAuth {self.token}"}
70
81
  all_components: list[AtlassianRawComponent] = []
71
82
  page = 1
72
83
  per_page = 100
73
84
  while True:
74
85
  params = {"page": page, "per_page": per_page}
75
- response = requests.get(url, params=params, headers=headers)
76
- response.raise_for_status()
86
+ response = self._do_get(url, params=params)
77
87
  components = [AtlassianRawComponent(**c) for c in response.json()]
78
88
  all_components += components
79
89
  if len(components) < per_page:
80
90
  break
81
91
  page += 1
92
+ # https://developer.statuspage.io/#section/Rate-Limiting
93
+ # Each API token is limited to 1 request / second as measured on a 60 second rolling window
94
+ time.sleep(1)
82
95
 
83
96
  return all_components
84
97