| 43 | |
| 44 | |
| 45 | def create_mv_option_with_api( |
| 46 | client: APIClient, |
| 47 | project_id: int, |
| 48 | feature_id: str, |
| 49 | default_percentage_allocation: float, |
| 50 | value: str, |
| 51 | key: str | None = None, |
| 52 | ) -> int: |
| 53 | url = reverse( |
| 54 | "api-v1:projects:feature-mv-options-list", |
| 55 | args=[project_id, feature_id], |
| 56 | ) |
| 57 | data: dict[str, typing.Any] = { |
| 58 | "type": STRING, |
| 59 | "feature": feature_id, |
| 60 | "string_value": value, |
| 61 | "default_percentage_allocation": default_percentage_allocation, |
| 62 | } |
| 63 | if key is not None: |
| 64 | data["key"] = key |
| 65 | response = client.post( |
| 66 | url, |
| 67 | data=json.dumps(data), |
| 68 | content_type="application/json", |
| 69 | ) |
| 70 | return response.json()["id"] # type: ignore[no-any-return] |
| 71 | |
| 72 | |
| 73 | def get_env_feature_states_list_with_api(client: APIClient, query_params: dict) -> dict: # type: ignore[type-arg] |