MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / create_flagsmith_flag_label

Function create_flagsmith_flag_label

api/integrations/github/client.py:301–326  ·  view source on GitHub ↗
(  # type: ignore[return]
    installation_id: str, owner: str, repo: str
)

Source from the content-addressed store, hash-verified

299
300
301def create_flagsmith_flag_label( # type: ignore[return]
302 installation_id: str, owner: str, repo: str
303) -> dict[str, Any]:
304 # Create "Flagsmith Flag" label in linked repo
305 url = f"{GITHUB_API_URL}repos/{owner}/{repo}/labels"
306 headers = build_request_headers(installation_id)
307 payload = {
308 "name": GITHUB_FLAGSMITH_LABEL,
309 "color": GITHUB_FLAGSMITH_LABEL_COLOR,
310 "description": GITHUB_FLAGSMITH_LABEL_DESCRIPTION,
311 }
312 try:
313 response = requests.post(
314 url, json=payload, headers=headers, timeout=GITHUB_API_CALLS_TIMEOUT
315 )
316 response.raise_for_status()
317 return response.json() # type: ignore[no-any-return]
318
319 except HTTPError:
320 response_content = response.content.decode("utf-8")
321 error_data = json.loads(response_content)
322 if any(
323 error["code"] == "already_exists" for error in error_data.get("errors", [])
324 ):
325 logger.warning("Label already exists")
326 return {"message": "Label already exists"}, 200 # type: ignore[return-value]
327
328
329def label_github_issue_pr(

Callers 2

createMethod · 0.90
updateMethod · 0.90

Calls 6

build_request_headersFunction · 0.85
decodeMethod · 0.80
postMethod · 0.45
raise_for_statusMethod · 0.45
jsonMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…