@@ -188,9 +188,7 @@ def _get_new_library_config(request_data: Dict) -> Dict:
188188 return {}
189189
190190
191- def _add_new_library_version (
192- library_config : Dict
193- ) -> None :
191+ def _add_new_library_version (library_config : Dict ) -> None :
194192 """Adds the library version to the configuration if it's not present.
195193
196194 Args:
@@ -383,6 +381,24 @@ def _clean_up_files_after_post_processing(output: str, library_id: str):
383381 os .remove (gapic_version_file )
384382
385383
384+ def _determine_release_level (api_path : str ) -> str :
385+ # TODO(https://github.com/googleapis/librarian/issues/2352): Determine if
386+ # this logic can be used to set the release level.
387+ # For now, we set the release_level as "preview" for newly generated clients.
388+ """Determines the release level from the API path.
389+
390+ Args:
391+ api_path (str): The path to the API.
392+
393+ Returns:
394+ str: The release level, which can be 'preview' or 'stable'.
395+ """
396+ version = Path (api_path ).name
397+ if "beta" in version or "alpha" in version :
398+ return "preview"
399+ return "stable"
400+
401+
386402def _create_repo_metadata_from_service_config (
387403 service_config_name : str , api_path : str , source : str , library_id : str
388404) -> Dict :
@@ -398,22 +414,39 @@ def _create_repo_metadata_from_service_config(
398414 Dict: The content of the .repo-metadata.json file.
399415 """
400416 full_service_config_path = f"{ source } /{ api_path } /{ service_config_name } "
417+ with open (full_service_config_path , "r" ) as f :
418+ service_config = yaml .safe_load (f )
419+
420+ api_id = service_config .get ("name" , {})
421+ publishing = service_config .get ("publishing" , {})
422+ name_pretty = service_config .get ("title" , "" )
423+ product_documentation = publishing .get ("documentation_uri" , "" )
424+ api_shortname = service_config .get ("name" , "" ).split ("." )[0 ]
425+ documentation = service_config .get ("documentation" , {})
426+ api_description = documentation .get ("summary" , "" )
427+ issue_tracker = service_config .get (
428+ "new_issue_uri" , "https://github.com/googleapis/google-cloud-python/issues"
429+ )
430+
431+ # TODO(https://github.com/googleapis/librarian/issues/2352): Determine if
432+ # `_determine_release_level` can be used to
433+ # set the release level. For now, we set the release_level as "preview" for
434+ # newly generated clients.
435+ release_level = "preview"
401436
402- # TODO(https://github.com/googleapis/librarian/issues/2332): Read the api
403- # service config to backfill `.repo-metadata.json`.
404437 return {
405- "api_shortname" : "" ,
406- "name_pretty" : "" ,
407- "product_documentation" : "" ,
408- "api_description" : "" ,
409- "client_documentation" : " " ,
410- "issue_tracker" : "" ,
411- "release_level" : "" ,
438+ "api_shortname" : api_shortname ,
439+ "name_pretty" : name_pretty ,
440+ "product_documentation" : product_documentation ,
441+ "api_description" : api_description ,
442+ "client_documentation" : f"https://cloud.google.com/python/docs/reference/ { library_id } /latest " ,
443+ "issue_tracker" : issue_tracker ,
444+ "release_level" : release_level ,
412445 "language" : "python" ,
413446 "library_type" : "GAPIC_AUTO" ,
414447 "repo" : "googleapis/google-cloud-python" ,
415- "distribution_name" : "" ,
416- "api_id" : "" ,
448+ "distribution_name" : library_id ,
449+ "api_id" : api_id ,
417450 }
418451
419452
0 commit comments