MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / cd_signer_request

Function cd_signer_request

scripts/build.py:125–148  ·  view source on GitHub ↗

Sends a request to the CD Signer API.

(method: str, path: str, data: str | None = None)

Source from the content-addressed store, hash-verified

123
124
125def cd_signer_request(method: str, path: str, data: str | None = None):
126 """
127 Sends a request to the CD Signer API.
128 """
129 SigV4Auth = import_module("botocore.auth").SigV4Auth
130 AWSRequest = import_module("botocore.awsrequest").AWSRequest
131 requests = import_module("requests")
132
133 url = f"{SIGNING_API_BASE_URL}{path}"
134 headers = {"Content-Type": "application/json"}
135 request = AWSRequest(method=method, url=url, data=data, headers=headers)
136 SigV4Auth(get_creds(), "signer-builder-tools", CD_SIGNER_REGION).add_auth(request)
137
138 for i in range(1, 8):
139 debug(f"Sending request {method} to {url} with data: {data}")
140 response = requests.request(method=method, url=url, headers=dict(request.headers), data=data)
141 info(f"CDSigner Request ({url}): {response.status_code}")
142 if response.status_code == 429:
143 warn(f"Too many requests, backing off for {2**i} seconds")
144 time.sleep(2**i)
145 continue
146 return response
147
148 raise Exception(f"Failed to request {url}")
149
150
151def cd_signer_create_request(manifest: Any) -> str:

Callers 3

cd_signer_create_requestFunction · 0.85
cd_signer_start_requestFunction · 0.85
cd_signer_status_requestFunction · 0.85

Calls 4

debugFunction · 0.90
infoFunction · 0.90
warnFunction · 0.90
get_credsFunction · 0.85

Tested by

no test coverage detected