STATE-WP-0070: identity headers, archive 0069, phase-2 workplan
Add X-StateHub-Component to fix-consistency and other State Hub REST callers for legacy-meter attribution. Archive STATE-WP-0069; open STATE-WP-0070 for meter-gated phase-2 retirement. Task POST bodies use workplan_id only.
This commit is contained in:
parent
2f06751d4f
commit
bb6bec9f10
10 changed files with 198 additions and 17 deletions
|
|
@ -6,11 +6,13 @@ import urllib.error
|
|||
import urllib.request
|
||||
|
||||
API_BASE = os.environ.get("API_BASE", "http://127.0.0.1:8000").rstrip("/")
|
||||
_HEADERS = {"X-StateHub-Component": "state-hub.dashboard.token-summary"}
|
||||
|
||||
|
||||
def fetch(url: str):
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=10) as resp:
|
||||
req = urllib.request.Request(url, headers=_HEADERS)
|
||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||
return json.loads(resp.read())
|
||||
except urllib.error.URLError:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ import urllib.request
|
|||
import urllib.error
|
||||
|
||||
API_BASE = os.environ.get("API_BASE", "http://127.0.0.1:8000").rstrip("/")
|
||||
_HEADERS = {"X-StateHub-Component": "state-hub.dashboard.workstreams-list"}
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(f"{API_BASE}/workplans", timeout=10) as resp:
|
||||
req = urllib.request.Request(f"{API_BASE}/workplans", headers=_HEADERS)
|
||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||
data = json.loads(resp.read())
|
||||
print(json.dumps(data))
|
||||
except urllib.error.URLError as e:
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import urllib.request
|
|||
import urllib.error
|
||||
|
||||
API_BASE = os.environ.get("API_BASE", "http://127.0.0.1:8000").rstrip("/")
|
||||
_HEADERS = {"X-StateHub-Component": "state-hub.dashboard.workplan-detail"}
|
||||
|
||||
ws_id = sys.argv[1] if len(sys.argv) > 1 else ""
|
||||
|
||||
|
|
@ -15,7 +16,8 @@ if not ws_id:
|
|||
sys.exit(1)
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(f"{API_BASE}/workplans/{ws_id}", timeout=10) as resp:
|
||||
req = urllib.request.Request(f"{API_BASE}/workplans/{ws_id}", headers=_HEADERS)
|
||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||
data = json.loads(resp.read())
|
||||
print(json.dumps(data))
|
||||
except urllib.error.HTTPError as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue