|
45 | 45 |
|
46 | 46 | BUILD_REQUEST_FILE = "build-request.json" |
47 | 47 | GENERATE_REQUEST_FILE = "generate-request.json" |
| 48 | +CONFIGURE_REQUEST_FILE = "configure-response.json" |
48 | 49 | RELEASE_INIT_REQUEST_FILE = "release-init-request.json" |
49 | 50 | STATE_YAML_FILE = "state.yaml" |
50 | 51 |
|
@@ -144,7 +145,28 @@ def handle_configure( |
144 | 145 | Raises: |
145 | 146 | ValueError: If configuring a new library fails. |
146 | 147 | """ |
147 | | - # TODO(https://github.com/googleapis/librarian/issues/466): Implement configure command and update docstring. |
| 148 | + try: |
| 149 | + # configure-request.json contains the library definitions. |
| 150 | + request_data = _read_json_file(f"{librarian}/{CONFIGURE_REQUEST_FILE}") |
| 151 | + for library_config in request_data.get("libraries", []): |
| 152 | + is_new_library_or_api = False |
| 153 | + if "apis" in library_config: |
| 154 | + for api in library_config["apis"]: |
| 155 | + if api.get("status") == "new": |
| 156 | + is_new_library_or_api = True |
| 157 | + # Delete the status field since we don't need to include it in `configure-response.json`. |
| 158 | + del api["status"] |
| 159 | + |
| 160 | + if is_new_library_or_api: |
| 161 | + library_id = _get_library_id(library_config) |
| 162 | + # TODO: Add missing information for the configured library. |
| 163 | + request_data[library_id] = library_config |
| 164 | + |
| 165 | + # Write the new library configuration to configure-response.json. |
| 166 | + _write_json_file(f"{librarian}/configure-response.json", request_data[library_id]) |
| 167 | + |
| 168 | + except Exception as e: |
| 169 | + raise ValueError("Configuring a new library failed.") from e |
148 | 170 | logger.info("'configure' command executed.") |
149 | 171 |
|
150 | 172 |
|
|
0 commit comments