Skip to content

Commit

Permalink
try to use empty GapicPackageInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp committed Feb 12, 2024
1 parent 96b357b commit 4bc092a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public class ClientLibraryPackageInfoComposer {
private static final String SERVICE_DESCRIPTION_HEADER_PATTERN = "Service Description: %s";

public static GapicPackageInfo generatePackageInfo(GapicContext context) {
Preconditions.checkState(!context.services().isEmpty(), "No services found to generate");
if (context.services().isEmpty()) {
return GapicPackageInfo.empty();
}

// Pick some service's package, as we assume they are all the same.
String libraryPakkage = context.services().get(0).pakkage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public static GapicPackageInfo with(PackageInfoDefinition packageInfo) {
return builder().setPackageInfo(packageInfo).build();
}

public static GapicPackageInfo empty() {
return builder().setPackageInfo(PackageInfoDefinition.builder().build()).build();
}

static Builder builder() {
return new AutoValue_GapicPackageInfo.Builder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ public static GapicContext parse(CodeGeneratorRequest request) {
transport);

if (services.isEmpty()) {
//throw new NoServicesFoundException();
System.err.println("No services found. Will not generate Gapic clients");
}

// TODO(vam-google): Figure out whether we should keep this allowlist or bring
// back the unused resource names for all APIs.
// Temporary workaround for Ads, who still need these resource names.
if (services.get(0).protoPakkage().startsWith("google.ads.googleads.v")) {
if (!services.isEmpty() && services.get(0).protoPakkage().startsWith("google.ads.googleads.v")) {
Function<ResourceName, String> typeNameFn =
r -> r.resourceTypeString().substring(r.resourceTypeString().indexOf("/") + 1);
Function<Set<ResourceName>, Set<String>> typeStringSetFn =
Expand Down

0 comments on commit 4bc092a

Please sign in to comment.