Return (field_id, triage_option_id) for the Status single-select field.
(
owner: str, number: int, status_field_name: str, triage_option_name: str
)
| 150 | |
| 151 | |
| 152 | def fetch_status_field( |
| 153 | owner: str, number: int, status_field_name: str, triage_option_name: str |
| 154 | ) -> tuple[str, str]: |
| 155 | """Return (field_id, triage_option_id) for the Status single-select field.""" |
| 156 | q = ( |
| 157 | 'query { organization(login: "' |
| 158 | + owner |
| 159 | + '") { projectV2(number: ' |
| 160 | + str(number) |
| 161 | + ') { field(name: "' |
| 162 | + status_field_name |
| 163 | + '") { ... on ProjectV2SingleSelectField { id options { id name } } } } } }' |
| 164 | ) |
| 165 | d = graphql(q) |
| 166 | field = d["data"]["organization"]["projectV2"]["field"] |
| 167 | if not field: |
| 168 | raise RuntimeError(f"Status field '{status_field_name}' not found") |
| 169 | field_id = str(field["id"]) |
| 170 | option_id: str | None = None |
| 171 | for o in field["options"]: |
| 172 | if o["name"] == triage_option_name: |
| 173 | option_id = str(o["id"]) |
| 174 | break |
| 175 | if option_id is None: |
| 176 | raise RuntimeError(f"Option '{triage_option_name}' not found on Status field") |
| 177 | return field_id, option_id |
| 178 | |
| 179 | |
| 180 | def set_status_triage( |