diff --git a/src/main/java/com/google/api/codegen/CommentPatterns.java b/src/main/java/com/google/api/codegen/CommentPatterns.java index f3bb770b2e..21a4cef26b 100644 --- a/src/main/java/com/google/api/codegen/CommentPatterns.java +++ b/src/main/java/com/google/api/codegen/CommentPatterns.java @@ -24,7 +24,7 @@ public final class CommentPatterns { public static final Pattern BACK_QUOTE_PATTERN = Pattern.compile("(?> defaultCreate( providers.add(messageProvider); } } - if (generatorConfig.enableTestGenerator() && id.equals(RUBY)) { + if (generatorConfig.enableTestGenerator()) { GapicCodePathMapper rubyTestPathMapper = CommonGapicCodePathMapper.newBuilder() .setPrefix("test") diff --git a/src/main/java/com/google/api/codegen/grpcmetadatagen/java/JavaGrpcPackageMetadataTransformer.java b/src/main/java/com/google/api/codegen/grpcmetadatagen/java/JavaGrpcPackageMetadataTransformer.java index e6a3b99e16..0967ee0d0a 100644 --- a/src/main/java/com/google/api/codegen/grpcmetadatagen/java/JavaGrpcPackageMetadataTransformer.java +++ b/src/main/java/com/google/api/codegen/grpcmetadatagen/java/JavaGrpcPackageMetadataTransformer.java @@ -22,7 +22,7 @@ public class JavaGrpcPackageMetadataTransformer extends JavaPackageMetadataTrans private final Map snippetsOutput = ImmutableMap.of( "LICENSE.snip", "LICENSE", - "metadatagen/java/grpc/package.snip", "build.gradle"); + "metadatagen/java/grpc/build.gradle.snip", "build.gradle"); @Override protected Map getSnippetsOutput() { diff --git a/src/main/java/com/google/api/codegen/grpcmetadatagen/java/JavaProtoPackageMetadataTransformer.java b/src/main/java/com/google/api/codegen/grpcmetadatagen/java/JavaProtoPackageMetadataTransformer.java index cde6ace7e2..fb80fd6815 100644 --- a/src/main/java/com/google/api/codegen/grpcmetadatagen/java/JavaProtoPackageMetadataTransformer.java +++ b/src/main/java/com/google/api/codegen/grpcmetadatagen/java/JavaProtoPackageMetadataTransformer.java @@ -23,7 +23,7 @@ public class JavaProtoPackageMetadataTransformer extends JavaPackageMetadataTran private final Map snippetsOutput = ImmutableMap.of( "LICENSE.snip", "LICENSE", - "metadatagen/java/grpc/package.snip", "build.gradle"); + "metadatagen/java/grpc/build.gradle.snip", "build.gradle"); @Override protected Map getSnippetsOutput() { diff --git a/src/main/java/com/google/api/codegen/metacode/FieldSetting.java b/src/main/java/com/google/api/codegen/metacode/FieldSetting.java deleted file mode 100644 index 8eb0eea8f1..0000000000 --- a/src/main/java/com/google/api/codegen/metacode/FieldSetting.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2016 Google Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.api.codegen.metacode; - -import com.google.api.codegen.util.Name; -import com.google.api.tools.framework.model.TypeRef; -import com.google.auto.value.AutoValue; - -/** - * Represents the notion of a field on a structure being set with the value of a previously-declared - * identifier. - */ -@AutoValue -public abstract class FieldSetting { - - public static FieldSetting create( - TypeRef type, Name fieldName, Name identifier, InitValueConfig initValueConfig) { - return new AutoValue_FieldSetting(type, fieldName, identifier, initValueConfig); - } - - /** Returns the type of the field being set. */ - public abstract TypeRef getType(); - - /** Returns the name of the field in the containing structure. */ - public abstract Name getFieldName(); - - /** Returns the name of the identifier being set on the field. */ - public abstract Name getIdentifier(); - - /** Returns the InitValueConfig for the original identifier. */ - public abstract InitValueConfig getInitValueConfig(); -} diff --git a/src/main/java/com/google/api/codegen/metacode/InitCode.java b/src/main/java/com/google/api/codegen/metacode/InitCode.java deleted file mode 100644 index b109c6f738..0000000000 --- a/src/main/java/com/google/api/codegen/metacode/InitCode.java +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2016 Google Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.api.codegen.metacode; - -import com.google.auto.value.AutoValue; -import java.util.List; - -/** InitCode represents the lines of code necessary to compose a structure. */ -@AutoValue -public abstract class InitCode { - public static InitCode create(List lines, List argFields) { - return new AutoValue_InitCode(lines, argFields); - } - - public abstract List getLines(); - - public abstract List getArgFields(); -} diff --git a/src/main/java/com/google/api/codegen/metacode/InitCodeLine.java b/src/main/java/com/google/api/codegen/metacode/InitCodeLine.java deleted file mode 100644 index 17388b591d..0000000000 --- a/src/main/java/com/google/api/codegen/metacode/InitCodeLine.java +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2016 Google Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.api.codegen.metacode; - -import com.google.api.codegen.util.Name; - -/** InitCodeLine represents the creation of a variable with an initialized value. */ -public interface InitCodeLine { - public Name getIdentifier(); - - public InitValueConfig getInitValueConfig(); - - public InitCodeLineType getLineType(); -} diff --git a/src/main/java/com/google/api/codegen/metacode/ListInitCodeLine.java b/src/main/java/com/google/api/codegen/metacode/ListInitCodeLine.java deleted file mode 100644 index f0be7f08ab..0000000000 --- a/src/main/java/com/google/api/codegen/metacode/ListInitCodeLine.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright 2016 Google Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.api.codegen.metacode; - -import com.google.api.codegen.util.Name; -import com.google.api.tools.framework.model.TypeRef; -import com.google.auto.value.AutoValue; -import java.util.List; - -/** - * ListInitCodeLine represents an InitCodeLine that initializes a list with values from other - * variables. - */ -@AutoValue -public abstract class ListInitCodeLine implements InitCodeLine { - - public static ListInitCodeLine create( - TypeRef elementType, Name identifier, List elementIdentifiers) { - return new AutoValue_ListInitCodeLine(elementType, identifier, elementIdentifiers); - } - - public abstract TypeRef getElementType(); - - @Override - public abstract Name getIdentifier(); - - public abstract List getElementIdentifiers(); - - @Override - public InitCodeLineType getLineType() { - return InitCodeLineType.ListInitLine; - } - - @Override - public InitValueConfig getInitValueConfig() { - return InitValueConfig.create(); - } -} diff --git a/src/main/java/com/google/api/codegen/metacode/MapInitCodeLine.java b/src/main/java/com/google/api/codegen/metacode/MapInitCodeLine.java deleted file mode 100644 index 49529d9bc4..0000000000 --- a/src/main/java/com/google/api/codegen/metacode/MapInitCodeLine.java +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright 2016 Google Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.api.codegen.metacode; - -import com.google.api.codegen.util.Name; -import com.google.api.tools.framework.model.TypeRef; -import com.google.auto.value.AutoValue; -import java.util.Map; - -/** - * MapInitCodeLine represents an InitCodeLine that initializes a map with the provided keys, and - * values from other variables. - */ -@AutoValue -public abstract class MapInitCodeLine implements InitCodeLine { - - public static MapInitCodeLine create( - TypeRef keyType, - TypeRef valueType, - TypeRef elementType, - Name identifier, - Map elementIdentifierMap) { - return new AutoValue_MapInitCodeLine( - keyType, valueType, elementType, identifier, elementIdentifierMap); - } - - public abstract TypeRef getKeyType(); - - public abstract TypeRef getValueType(); - - public abstract TypeRef getElementType(); - - @Override - public abstract Name getIdentifier(); - - public abstract Map getElementIdentifierMap(); - - public Iterable getElementIdentifierKeys() { - return getElementIdentifierMap().keySet(); - } - - public Name getElementIdentifierValue(String key) { - return getElementIdentifierMap().get(key); - } - - @Override - public InitCodeLineType getLineType() { - return InitCodeLineType.MapInitLine; - } - - @Override - public InitValueConfig getInitValueConfig() { - return InitValueConfig.create(); - } -} diff --git a/src/main/java/com/google/api/codegen/metacode/SimpleInitCodeLine.java b/src/main/java/com/google/api/codegen/metacode/SimpleInitCodeLine.java deleted file mode 100644 index 91e891b7a0..0000000000 --- a/src/main/java/com/google/api/codegen/metacode/SimpleInitCodeLine.java +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright 2016 Google Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.api.codegen.metacode; - -import com.google.api.codegen.util.Name; -import com.google.api.tools.framework.model.TypeRef; -import com.google.auto.value.AutoValue; - -/** - * SimpleInitCodeLine represents an InitCodeLine that initializes a variable that does not depend on - * other initialized variables. - */ -@AutoValue -public abstract class SimpleInitCodeLine implements InitCodeLine { - - public static SimpleInitCodeLine create( - TypeRef type, Name identifier, InitValueConfig initValueConfig) { - return new AutoValue_SimpleInitCodeLine(type, identifier, initValueConfig); - } - - public abstract TypeRef getType(); - - @Override - public abstract Name getIdentifier(); - - @Override - public abstract InitValueConfig getInitValueConfig(); - - @Override - public InitCodeLineType getLineType() { - return InitCodeLineType.SimpleInitLine; - } -} diff --git a/src/main/java/com/google/api/codegen/metacode/StructureInitCodeLine.java b/src/main/java/com/google/api/codegen/metacode/StructureInitCodeLine.java deleted file mode 100644 index e0f418edab..0000000000 --- a/src/main/java/com/google/api/codegen/metacode/StructureInitCodeLine.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright 2016 Google Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.api.codegen.metacode; - -import com.google.api.codegen.util.Name; -import com.google.api.tools.framework.model.TypeRef; -import com.google.auto.value.AutoValue; -import java.util.List; - -/** - * StructureInitCodeLine represents an InitCodeLine that initializes a structure that depends on - * values from other variables. - */ -@AutoValue -public abstract class StructureInitCodeLine implements InitCodeLine { - - public static StructureInitCodeLine create( - TypeRef type, Name identifier, List fieldSettings) { - return new AutoValue_StructureInitCodeLine(type, identifier, fieldSettings); - } - - public abstract TypeRef getType(); - - @Override - public abstract Name getIdentifier(); - - public abstract List getFieldSettings(); - - @Override - public InitCodeLineType getLineType() { - return InitCodeLineType.StructureInitLine; - } - - @Override - public InitValueConfig getInitValueConfig() { - return InitValueConfig.create(); - } -} diff --git a/src/main/java/com/google/api/codegen/transformer/DynamicLangApiMethodTransformer.java b/src/main/java/com/google/api/codegen/transformer/DynamicLangApiMethodTransformer.java index 94d93667ee..b61603ec45 100644 --- a/src/main/java/com/google/api/codegen/transformer/DynamicLangApiMethodTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/DynamicLangApiMethodTransformer.java @@ -63,6 +63,8 @@ public OptionalArrayMethodView generateMethod(GapicMethodContext context) { apiMethod.type(ClientMethodType.OptionalArrayMethod); } apiMethod.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig())); + apiMethod.fullyQualifiedApiClassName( + namer.getFullyQualifiedApiWrapperClassName(context.getInterfaceConfig())); apiMethod.apiVariableName(namer.getApiWrapperVariableName(context.getInterfaceConfig())); apiMethod.apiModuleName(namer.getApiWrapperModuleName()); InitCodeOutputType initCodeOutputType = diff --git a/src/main/java/com/google/api/codegen/transformer/InitCodeTransformer.java b/src/main/java/com/google/api/codegen/transformer/InitCodeTransformer.java index 1fbc4eb0bb..46c1079879 100644 --- a/src/main/java/com/google/api/codegen/transformer/InitCodeTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/InitCodeTransformer.java @@ -273,6 +273,7 @@ private InitCodeLineView generateStructureInitCodeLine( String typeName = typeTable.getAndSaveNicknameFor(item.getType()); surfaceLine.typeName(typeName); + surfaceLine.fullyQualifiedTypeName(typeTable.getFullNameFor(item.getType())); surfaceLine.typeConstructor(namer.getTypeConstructor(typeName)); surfaceLine.fieldSettings(getFieldSettings(context, item.getChildren().values())); @@ -391,6 +392,8 @@ private InitValueView getInitValue(GapicMethodContext context, InitCodeNode item initValue.apiWrapperName( context.getNamer().getApiWrapperClassName(context.getInterfaceConfig())); + initValue.fullyQualifiedApiWrapperName( + context.getNamer().getFullyQualifiedApiWrapperClassName(context.getInterfaceConfig())); initValue.formatFunctionName( context .getNamer() diff --git a/src/main/java/com/google/api/codegen/transformer/PackageMetadataNamer.java b/src/main/java/com/google/api/codegen/transformer/PackageMetadataNamer.java index a1722e0f15..3bd06d6b1f 100644 --- a/src/main/java/com/google/api/codegen/transformer/PackageMetadataNamer.java +++ b/src/main/java/com/google/api/codegen/transformer/PackageMetadataNamer.java @@ -14,6 +14,8 @@ */ package com.google.api.codegen.transformer; +import com.google.api.codegen.ReleaseLevel; + /** A PackageMetadataNamer provides language-specific strings for metadata views. */ public class PackageMetadataNamer { @@ -36,6 +38,23 @@ public String getOutputFileName() { return getNotImplementedString("PackageMetadataNamer.getOutputFileName"); } + public String getReleaseAnnotation(ReleaseLevel releaseLevel) { + switch (releaseLevel) { + case UNSET_RELEASE_LEVEL: + // fallthrough + case ALPHA: + return "Alpha"; + case BETA: + return "Beta"; + case GA: + return "Production/Stable"; + case DEPRECATED: + return "Inactive"; + default: + throw new IllegalStateException("Invalid development status"); + } + } + /** Returns the unimplemented string message */ public String getNotImplementedString(String feature) { return "$ NOT IMPLEMENTED: " + feature + " $"; diff --git a/src/main/java/com/google/api/codegen/transformer/PackageMetadataTransformer.java b/src/main/java/com/google/api/codegen/transformer/PackageMetadataTransformer.java index a06b1993a1..47d7281015 100644 --- a/src/main/java/com/google/api/codegen/transformer/PackageMetadataTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/PackageMetadataTransformer.java @@ -99,6 +99,7 @@ public PackageMetadataView.Builder generateMetadataView( .licenseName(packageConfig.licenseName()) .fullName(model.getServiceConfig().getTitle()) .discoveryApiName(discoveryApiName) + .apiSummary(model.getServiceConfig().getDocumentation().getSummary()) .hasMultipleServices(false); } } diff --git a/src/main/java/com/google/api/codegen/transformer/TestCaseTransformer.java b/src/main/java/com/google/api/codegen/transformer/TestCaseTransformer.java index e75d8cbcce..ef1d934542 100644 --- a/src/main/java/com/google/api/codegen/transformer/TestCaseTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/TestCaseTransformer.java @@ -106,6 +106,8 @@ public TestCaseView createTestCaseView( .responseTypeName(responseTypeName) .serviceConstructorName( namer.getApiWrapperClassConstructorName(methodContext.getInterface())) + .fullyQualifiedServiceClassName( + namer.getFullyQualifiedApiWrapperClassName(methodContext.getInterfaceConfig())) .clientMethodName(clientMethodName) .mockGrpcStubTypeName(namer.getMockGrpcServiceImplName(methodContext.getTargetInterface())) .createStubFunctionName(namer.getCreateStubFunctionName(methodContext.getTargetInterface())) diff --git a/src/main/java/com/google/api/codegen/transformer/go/GoGapicSurfaceTransformer.java b/src/main/java/com/google/api/codegen/transformer/go/GoGapicSurfaceTransformer.java index a3d382fed7..2f4749c93f 100644 --- a/src/main/java/com/google/api/codegen/transformer/go/GoGapicSurfaceTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/go/GoGapicSurfaceTransformer.java @@ -390,7 +390,9 @@ private enum ImportKind { .put( ImportContext.CLIENT, ImportKind.LRO, - ImmutableList.of("cloud.google.com/go/longrunning;;;")) + ImmutableList.of( + "cloud.google.com/go/longrunning;;;", + "cloud.google.com/go/longrunning/autogen;lroauto;;")) .put( ImportContext.EXAMPLE, ImportKind.SERVER_STREAM, diff --git a/src/main/java/com/google/api/codegen/transformer/go/GoSurfaceNamer.java b/src/main/java/com/google/api/codegen/transformer/go/GoSurfaceNamer.java index 567e23970f..4334dbbbc3 100644 --- a/src/main/java/com/google/api/codegen/transformer/go/GoSurfaceNamer.java +++ b/src/main/java/com/google/api/codegen/transformer/go/GoSurfaceNamer.java @@ -373,6 +373,7 @@ public String getSmokeTestClassName(GapicInterfaceConfig interfaceConfig) { @Override public String injectRandomStringGeneratorCode(String randomString) { - return randomString.replace(InitFieldConfig.RANDOM_TOKEN, "\" + uidSpace.New() + \""); + return randomString.replace( + InitFieldConfig.RANDOM_TOKEN, "\" + strconv.FormatInt(time.Now().UnixNano(), 10) + \""); } } diff --git a/src/main/java/com/google/api/codegen/transformer/java/JavaGapicSurfaceTransformer.java b/src/main/java/com/google/api/codegen/transformer/java/JavaGapicSurfaceTransformer.java index 13133bf135..652c3d4aae 100644 --- a/src/main/java/com/google/api/codegen/transformer/java/JavaGapicSurfaceTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/java/JavaGapicSurfaceTransformer.java @@ -439,15 +439,20 @@ private PackageInfoView generatePackageInfo( private void addApiImports(GapicInterfaceContext context) { ModelTypeTable typeTable = context.getModelTypeTable(); typeTable.saveNicknameFor("com.google.api.core.BetaApi"); + typeTable.saveNicknameFor("com.google.api.gax.core.CredentialsProvider"); typeTable.saveNicknameFor("com.google.api.gax.grpc.ChannelAndExecutor"); + typeTable.saveNicknameFor("com.google.api.gax.grpc.ClientContext"); typeTable.saveNicknameFor("com.google.api.gax.grpc.UnaryCallable"); typeTable.saveNicknameFor("com.google.api.pathtemplate.PathTemplate"); + typeTable.saveNicknameFor("com.google.auth.Credentials"); + typeTable.saveNicknameFor("io.grpc.auth.MoreCallCredentials"); + typeTable.saveNicknameFor("io.grpc.CallCredentials"); typeTable.saveNicknameFor("io.grpc.ManagedChannel"); typeTable.saveNicknameFor("java.io.Closeable"); typeTable.saveNicknameFor("java.io.IOException"); typeTable.saveNicknameFor("java.util.ArrayList"); - typeTable.saveNicknameFor("java.util.List"); typeTable.saveNicknameFor("java.util.concurrent.ScheduledExecutorService"); + typeTable.saveNicknameFor("java.util.List"); typeTable.saveNicknameFor("javax.annotation.Generated"); if (context.getInterfaceConfig().hasLongRunningOperations()) { diff --git a/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSGapicSurfaceTransformer.java b/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSGapicSurfaceTransformer.java index 0d6c156fd7..c28472b0e6 100644 --- a/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSGapicSurfaceTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSGapicSurfaceTransformer.java @@ -28,7 +28,6 @@ import com.google.api.codegen.nodejs.NodeJSUtils; import com.google.api.codegen.transformer.BatchingTransformer; import com.google.api.codegen.transformer.DynamicLangApiMethodTransformer; -import com.google.api.codegen.transformer.FeatureConfig; import com.google.api.codegen.transformer.FileHeaderTransformer; import com.google.api.codegen.transformer.GapicInterfaceContext; import com.google.api.codegen.transformer.GapicMethodContext; @@ -39,6 +38,7 @@ import com.google.api.codegen.transformer.PathTemplateTransformer; import com.google.api.codegen.transformer.ServiceTransformer; import com.google.api.codegen.transformer.SurfaceNamer; +import com.google.api.codegen.util.Name; import com.google.api.codegen.util.js.JSTypeTable; import com.google.api.codegen.viewmodel.ApiMethodView; import com.google.api.codegen.viewmodel.DynamicLangXApiView; @@ -91,25 +91,15 @@ public List getTemplateFileNames() { public List transform(Model model, GapicProductConfig productConfig) { Iterable apiInterfaces = new InterfaceView().getElementIterable(model); ImmutableList.Builder models = ImmutableList.builder(); - NodeJSSurfaceNamer surfaceNamer = - new NodeJSSurfaceNamer(productConfig.getPackageName(), NodeJSUtils.isGcloud(productConfig)); - models.addAll(generateIndexViews(apiInterfaces, surfaceNamer, productConfig)); - models.addAll(generateApiClasses(model, productConfig, surfaceNamer)); + models.addAll(generateIndexViews(apiInterfaces, productConfig)); + models.addAll(generateApiClasses(model, productConfig)); return models.build(); } - private List generateApiClasses( - Model model, GapicProductConfig productConfig, NodeJSSurfaceNamer surfaceNamer) { + private List generateApiClasses(Model model, GapicProductConfig productConfig) { ImmutableList.Builder models = ImmutableList.builder(); - FeatureConfig featureConfig = new NodeJSFeatureConfig(); for (Interface apiInterface : new InterfaceView().getElementIterable(model)) { - ModelTypeTable modelTypeTable = - new ModelTypeTable( - new JSTypeTable(productConfig.getPackageName()), - new NodeJSModelTypeNameConverter(productConfig.getPackageName())); - GapicInterfaceContext context = - GapicInterfaceContext.create( - apiInterface, productConfig, modelTypeTable, surfaceNamer, featureConfig); + GapicInterfaceContext context = createContext(apiInterface, productConfig); models.add(generateApiClass(context)); } return models.build(); @@ -255,24 +245,31 @@ private List createLongRunningDescriptors( } private List generateIndexViews( - Iterable apiInterfaces, - NodeJSSurfaceNamer namer, - GapicProductConfig productConfig) { - FileHeaderTransformer fileHeaderTransformer = - new FileHeaderTransformer(new NodeJSImportSectionTransformer()); + Iterable apiInterfaces, GapicProductConfig productConfig) { ArrayList indexViews = new ArrayList<>(); - + NodeJSSurfaceNamer namer = + new NodeJSSurfaceNamer(productConfig.getPackageName(), NodeJSUtils.isGcloud(productConfig)); + String version = namer.getApiWrapperModuleVersion(); + boolean hasVersion = version != null && !version.isEmpty(); ArrayList requireViews = new ArrayList<>(); for (Interface apiInterface : apiInterfaces) { - requireViews.add( + Name serviceName = namer.getReducedServiceName(apiInterface); + String localName = + hasVersion ? serviceName.join(version).toLowerCamel() : serviceName.toLowerCamel(); + GapicInterfaceContext context = createContext(apiInterface, productConfig); + VersionIndexRequireView require = VersionIndexRequireView.newBuilder() .clientName( namer.getApiWrapperVariableName(productConfig.getInterfaceConfig(apiInterface))) + .serviceName(serviceName.toLowerCamel()) + .localName(localName) + .doc( + serviceTransformer.generateServiceDoc( + context, generateApiMethods(context).get(0))) .fileName(namer.getClientFileName(apiInterface)) - .build()); + .build(); + requireViews.add(require); } - String version = namer.getApiWrapperModuleVersion(); - boolean hasVersion = version != null && !version.isEmpty(); String indexOutputPath = hasVersion ? "src/" + version + "/index.js" : "src/index.js"; VersionIndexView.Builder indexViewbuilder = VersionIndexView.newBuilder() @@ -296,7 +293,8 @@ private List generateIndexViews( VersionIndexView.newBuilder() .templateFileName(VERSION_INDEX_TEMPLATE_FILE) .outputPath(versionIndexOutputPath) - .requireViews(new ArrayList()) + .requireViews(requireViews) + .primaryService(requireViews.get(0)) .apiVersion(version) .packageVersion( packageConfig.generatedPackageVersionBound(TargetLanguage.NODEJS).lower()) @@ -307,4 +305,16 @@ private List generateIndexViews( } return indexViews; } + + private GapicInterfaceContext createContext( + Interface apiInterface, GapicProductConfig productConfig) { + return GapicInterfaceContext.create( + apiInterface, + productConfig, + new ModelTypeTable( + new JSTypeTable(productConfig.getPackageName()), + new NodeJSModelTypeNameConverter(productConfig.getPackageName())), + new NodeJSSurfaceNamer(productConfig.getPackageName(), NodeJSUtils.isGcloud(productConfig)), + new NodeJSFeatureConfig()); + } } diff --git a/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSPackageMetadataTransformer.java b/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSPackageMetadataTransformer.java index a329b5996d..b2f05f53c9 100644 --- a/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSPackageMetadataTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSPackageMetadataTransformer.java @@ -16,24 +16,58 @@ import com.google.api.codegen.InterfaceView; import com.google.api.codegen.TargetLanguage; +import com.google.api.codegen.config.FlatteningConfig; import com.google.api.codegen.config.GapicProductConfig; import com.google.api.codegen.config.PackageMetadataConfig; +import com.google.api.codegen.nodejs.NodeJSUtils; +import com.google.api.codegen.transformer.DynamicLangApiMethodTransformer; +import com.google.api.codegen.transformer.FileHeaderTransformer; +import com.google.api.codegen.transformer.GapicInterfaceContext; +import com.google.api.codegen.transformer.GapicMethodContext; +import com.google.api.codegen.transformer.InitCodeTransformer; import com.google.api.codegen.transformer.ModelToViewTransformer; +import com.google.api.codegen.transformer.ModelTypeTable; import com.google.api.codegen.transformer.PackageMetadataTransformer; +import com.google.api.codegen.transformer.TestCaseTransformer; +import com.google.api.codegen.util.js.JSTypeTable; +import com.google.api.codegen.util.testing.StandardValueProducer; +import com.google.api.codegen.util.testing.ValueProducer; +import com.google.api.codegen.viewmodel.ApiMethodView; +import com.google.api.codegen.viewmodel.ImportSectionView; +import com.google.api.codegen.viewmodel.InitCodeView; +import com.google.api.codegen.viewmodel.OptionalArrayMethodView; import com.google.api.codegen.viewmodel.ViewModel; import com.google.api.tools.framework.model.Interface; +import com.google.api.tools.framework.model.Method; import com.google.api.tools.framework.model.Model; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** Responsible for producing package metadata related views for NodeJS */ public class NodeJSPackageMetadataTransformer implements ModelToViewTransformer { - private static final String PACKAGE_FILE = "nodejs/package.snip"; + private static final String README_FILE = "nodejs/README.md.snip"; + private static final String README_OUTPUT_FILE = "README.md"; + private static final List TOP_LEVEL_FILES = ImmutableList.of("nodejs/package.json.snip"); - PackageMetadataConfig packageConfig; - PackageMetadataTransformer metadataTransformer = new PackageMetadataTransformer(); + private static final String GITHUB_DOC_HOST = + "https://googlecloudplatform.github.io/google-cloud-node"; + private static final String GITHUB_REPO_HOST = + "https://github.com/GoogleCloudPlatform/google-cloud-node"; + private static final String AUTH_DOC_PATH = "/#/docs/google-cloud/master/guides/authentication"; + private static final String LIB_DOC_PATH = "/#/docs/%s"; + private static final String MAIN_README_PATH = "/blob/master/README.md"; + private static final String VERSIONING_DOC_PATH = "#versioning"; + + private static String NODE_PREFIX = "nodejs/"; + + private final FileHeaderTransformer fileHeaderTransformer = + new FileHeaderTransformer(new NodeJSImportSectionTransformer()); + private final PackageMetadataConfig packageConfig; + private final PackageMetadataTransformer metadataTransformer = new PackageMetadataTransformer(); + private final ValueProducer valueProducer = new StandardValueProducer(); + private final TestCaseTransformer testCaseTransformer = new TestCaseTransformer(valueProducer); public NodeJSPackageMetadataTransformer(PackageMetadataConfig packageConfig) { this.packageConfig = packageConfig; @@ -41,28 +75,119 @@ public NodeJSPackageMetadataTransformer(PackageMetadataConfig packageConfig) { @Override public List getTemplateFileNames() { - return Arrays.asList(PACKAGE_FILE); + return ImmutableList.builder().addAll(TOP_LEVEL_FILES).add(README_FILE).build(); } @Override public List transform(Model model, GapicProductConfig productConfig) { - Iterable services = new InterfaceView().getElementIterable(model); - boolean hasMultipleServices = Iterables.size(services) > 1; List models = new ArrayList(); NodeJSPackageMetadataNamer namer = new NodeJSPackageMetadataNamer( productConfig.getPackageName(), productConfig.getDomainLayerLocation()); - models.add(generateMetadataView(model, namer, hasMultipleServices)); + models.addAll(generateMetadataViews(model, namer)); + models.add(generateReadmeView(model, productConfig, namer)); return models; } - private ViewModel generateMetadataView( - Model model, NodeJSPackageMetadataNamer namer, boolean hasMultipleServices) { + private ViewModel generateReadmeView( + Model model, GapicProductConfig productConfig, NodeJSPackageMetadataNamer namer) { + List exampleMethods = generateExampleMethods(model, productConfig); + Iterable services = new InterfaceView().getElementIterable(model); + boolean hasMultipleServices = Iterables.size(services) > 1; return metadataTransformer .generateMetadataView( - packageConfig, model, PACKAGE_FILE, "package.json", TargetLanguage.NODEJS) + packageConfig, model, README_FILE, README_OUTPUT_FILE, TargetLanguage.NODEJS) .identifier(namer.getMetadataIdentifier()) + .fileHeader( + fileHeaderTransformer.generateFileHeader( + productConfig, + ImportSectionView.newBuilder().build(), + new NodeJSSurfaceNamer( + productConfig.getPackageName(), NodeJSUtils.isGcloud(productConfig)))) + .developmentStatusTitle( + namer.getReleaseAnnotation(packageConfig.releaseLevel(TargetLanguage.NODEJS))) + .exampleMethods(exampleMethods) .hasMultipleServices(hasMultipleServices) + .targetLanguage("Node.js") + .mainReadmeLink(GITHUB_REPO_HOST + MAIN_README_PATH) + .libraryDocumentationLink( + GITHUB_DOC_HOST + String.format(LIB_DOC_PATH, packageConfig.shortName())) + .authDocumentationLink(GITHUB_DOC_HOST + AUTH_DOC_PATH) + .versioningDocumentationLink(GITHUB_REPO_HOST + VERSIONING_DOC_PATH) .build(); } + + // Generates methods used as examples for the README.md file. + // Note: This is based on sample gen method calls. In the future, the example + // methods may be configured separately. + private List generateExampleMethods( + Model model, GapicProductConfig productConfig) { + ImmutableList.Builder exampleMethods = ImmutableList.builder(); + for (Interface apiInterface : new InterfaceView().getElementIterable(model)) { + GapicInterfaceContext context = createContext(apiInterface, productConfig); + if (context.getInterfaceConfig().getSmokeTestConfig() != null) { + Method method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); + FlatteningConfig flatteningGroup = + testCaseTransformer.getSmokeTestFlatteningGroup( + context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig()); + GapicMethodContext flattenedMethodContext = + context.asFlattenedMethodContext(method, flatteningGroup); + exampleMethods.add(createExampleApiMethodView(flattenedMethodContext)); + } + } + return exampleMethods.build(); + } + + private OptionalArrayMethodView createExampleApiMethodView(GapicMethodContext context) { + OptionalArrayMethodView initialApiMethodView = + new DynamicLangApiMethodTransformer(new NodeJSApiMethodParamTransformer()) + .generateMethod(context); + + OptionalArrayMethodView.Builder apiMethodView = initialApiMethodView.toBuilder(); + + InitCodeTransformer initCodeTransformer = new InitCodeTransformer(); + InitCodeView initCodeView = + initCodeTransformer.generateInitCode( + context, testCaseTransformer.createSmokeTestInitContext(context)); + apiMethodView.initCode(initCodeView); + + return apiMethodView.build(); + } + + private List generateMetadataViews(Model model, NodeJSPackageMetadataNamer namer) { + ImmutableList.Builder views = ImmutableList.builder(); + for (String template : TOP_LEVEL_FILES) { + views.add(generateMetadataView(model, template, namer)); + } + return views.build(); + } + + private ViewModel generateMetadataView( + Model model, String template, NodeJSPackageMetadataNamer namer) { + String noLeadingNodeDir = + template.startsWith(NODE_PREFIX) ? template.substring(NODE_PREFIX.length()) : template; + int extensionIndex = noLeadingNodeDir.lastIndexOf("."); + String outputPath = noLeadingNodeDir.substring(0, extensionIndex); + + Iterable services = new InterfaceView().getElementIterable(model); + boolean hasMultipleServices = Iterables.size(services) > 1; + + return metadataTransformer + .generateMetadataView(packageConfig, model, template, outputPath, TargetLanguage.NODEJS) + .identifier(namer.getMetadataIdentifier()) + .hasMultipleServices(hasMultipleServices) + .build(); + } + + private GapicInterfaceContext createContext( + Interface apiInterface, GapicProductConfig productConfig) { + return GapicInterfaceContext.create( + apiInterface, + productConfig, + new ModelTypeTable( + new JSTypeTable(productConfig.getPackageName()), + new NodeJSModelTypeNameConverter(productConfig.getPackageName())), + new NodeJSSurfaceNamer(productConfig.getPackageName(), NodeJSUtils.isGcloud(productConfig)), + new NodeJSFeatureConfig()); + } } diff --git a/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSSurfaceNamer.java b/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSSurfaceNamer.java index 4e1231d64f..eb6eeeb63e 100644 --- a/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSSurfaceNamer.java +++ b/src/main/java/com/google/api/codegen/transformer/nodejs/NodeJSSurfaceNamer.java @@ -21,12 +21,14 @@ import com.google.api.codegen.config.GrpcStreamingConfig.GrpcStreamingType; import com.google.api.codegen.config.SingleResourceNameConfig; import com.google.api.codegen.config.VisibilityConfig; +import com.google.api.codegen.metacode.InitFieldConfig; import com.google.api.codegen.transformer.FeatureConfig; import com.google.api.codegen.transformer.GapicInterfaceContext; import com.google.api.codegen.transformer.ModelTypeFormatterImpl; import com.google.api.codegen.transformer.ModelTypeTable; import com.google.api.codegen.transformer.SurfaceNamer; import com.google.api.codegen.transformer.Synchronicity; +import com.google.api.codegen.util.CommonRenderingUtil; import com.google.api.codegen.util.Name; import com.google.api.codegen.util.NamePath; import com.google.api.codegen.util.js.JSCommentReformatter; @@ -40,9 +42,11 @@ import com.google.api.tools.framework.model.Method; import com.google.api.tools.framework.model.ProtoFile; import com.google.api.tools.framework.model.TypeRef; +import com.google.common.base.Joiner; import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -465,4 +469,25 @@ public String getStreamTypeName(GrpcStreamingType type) { "SurfaceNamer.getStreamTypeName(GrpcStreamingType." + type.toString() + ")"); } } + + @Override + public String injectRandomStringGeneratorCode(String randomString) { + String delimiter = ","; + String[] split = + CommonRenderingUtil.stripQuotes(randomString) + .replace( + InitFieldConfig.RANDOM_TOKEN, delimiter + InitFieldConfig.RANDOM_TOKEN + delimiter) + .split(delimiter); + ArrayList stringParts = new ArrayList<>(); + for (String token : split) { + if (token.length() > 0) { + if (token.equals(InitFieldConfig.RANDOM_TOKEN)) { + stringParts.add("Date.now().toString()"); + } else { + stringParts.add("\"" + token + "\""); + } + } + } + return Joiner.on(" + ").join(stringParts); + } } diff --git a/src/main/java/com/google/api/codegen/transformer/php/PhpGapicSurfaceTestTransformer.java b/src/main/java/com/google/api/codegen/transformer/php/PhpGapicSurfaceTestTransformer.java index 371a8718f7..296e8d8d15 100644 --- a/src/main/java/com/google/api/codegen/transformer/php/PhpGapicSurfaceTestTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/php/PhpGapicSurfaceTestTransformer.java @@ -246,6 +246,7 @@ private List createTestCaseViews(GapicInterfaceContext context) { } private void addUnitTestImports(ModelTypeTable typeTable) { + typeTable.saveNicknameFor("\\Google\\GAX\\ApiException"); typeTable.saveNicknameFor("\\Google\\GAX\\GrpcCredentialsHelper"); typeTable.saveNicknameFor("\\Google\\GAX\\LongRunning\\OperationsClient"); typeTable.saveNicknameFor("\\Google\\GAX\\Testing\\MockStubTrait"); @@ -254,5 +255,7 @@ private void addUnitTestImports(ModelTypeTable typeTable) { typeTable.saveNicknameFor("\\google\\protobuf\\Any"); typeTable.saveNicknameFor("\\google\\protobuf\\EmptyC"); typeTable.saveNicknameFor("\\google\\longrunning\\GetOperationRequest"); + typeTable.saveNicknameFor("\\Grpc"); + typeTable.saveNicknameFor("\\stdClass"); } } diff --git a/src/main/java/com/google/api/codegen/transformer/py/PythonPackageMetadataTransformer.java b/src/main/java/com/google/api/codegen/transformer/py/PythonPackageMetadataTransformer.java index 194d5dbff1..1308192c82 100644 --- a/src/main/java/com/google/api/codegen/transformer/py/PythonPackageMetadataTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/py/PythonPackageMetadataTransformer.java @@ -15,19 +15,37 @@ package com.google.api.codegen.transformer.py; import com.google.api.codegen.GapicContext; +import com.google.api.codegen.InterfaceView; import com.google.api.codegen.SnippetSetRunner; import com.google.api.codegen.TargetLanguage; +import com.google.api.codegen.config.FlatteningConfig; import com.google.api.codegen.config.GapicProductConfig; import com.google.api.codegen.config.PackageMetadataConfig; import com.google.api.codegen.gapic.GapicProvider; +import com.google.api.codegen.transformer.DefaultFeatureConfig; +import com.google.api.codegen.transformer.DynamicLangApiMethodTransformer; +import com.google.api.codegen.transformer.GapicInterfaceContext; +import com.google.api.codegen.transformer.GapicMethodContext; +import com.google.api.codegen.transformer.InitCodeTransformer; import com.google.api.codegen.transformer.ModelToViewTransformer; +import com.google.api.codegen.transformer.ModelTypeTable; +import com.google.api.codegen.transformer.PackageMetadataNamer; import com.google.api.codegen.transformer.PackageMetadataTransformer; +import com.google.api.codegen.transformer.TestCaseTransformer; +import com.google.api.codegen.util.py.PythonTypeTable; +import com.google.api.codegen.util.testing.PythonValueProducer; +import com.google.api.codegen.util.testing.ValueProducer; +import com.google.api.codegen.viewmodel.ApiMethodView; +import com.google.api.codegen.viewmodel.OptionalArrayMethodView; import com.google.api.codegen.viewmodel.SimpleViewModel; import com.google.api.codegen.viewmodel.ViewModel; +import com.google.api.tools.framework.model.Interface; +import com.google.api.tools.framework.model.Method; import com.google.api.tools.framework.model.Model; import com.google.api.tools.framework.snippet.Doc; import com.google.common.base.Joiner; import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.io.Files; import java.io.File; @@ -47,8 +65,18 @@ public class PythonPackageMetadataTransformer implements ModelToViewTransformer { private static final String TEST_PREFIX = "test."; + private static final String GITHUB_DOC_HOST = + "https://googlecloudplatform.github.io/google-cloud-python/stable"; + private static final String GITHUB_REPO_HOST = + "https://github.com/GoogleCloudPlatform/google-cloud-python"; + private static final String AUTH_DOC_PATH = "/google-cloud-auth"; + private static final String LIB_DOC_PATH = "/%s-usage"; + private static final String MAIN_README_PATH = "/blob/master/README.rst"; + private final PackageMetadataConfig packageConfig; private final PackageMetadataTransformer metadataTransformer = new PackageMetadataTransformer(); + private final ValueProducer valueProducer = new PythonValueProducer(); + private final TestCaseTransformer testCaseTransformer = new TestCaseTransformer(valueProducer); private final List> gapicProviders; private final PythonSurfaceNamer surfaceNamer; private List apiModules = null; @@ -66,8 +94,9 @@ public List transform(final Model model, final GapicProductConfig pro String version = packageConfig.apiVersion(); List metadata = computeInitFiles(computePackages(productConfig.getPackageName()), version); + PackageMetadataNamer namer = new PackageMetadataNamer(); for (String templateFileName : getTopLevelTemplateFileNames()) { - metadata.add(generateMetadataView(model, productConfig, templateFileName)); + metadata.add(generateMetadataView(model, productConfig, templateFileName, namer)); } return metadata; } @@ -100,23 +129,62 @@ public List getInitTemplateFileNames() { } private ViewModel generateMetadataView( - Model model, GapicProductConfig productConfig, String template) { + Model model, GapicProductConfig productConfig, String template, PackageMetadataNamer namer) { + List exampleMethods = generateExampleMethods(model, productConfig); String noLeadingPyDir = template.startsWith("py/") ? template.substring(3) : template; int extensionIndex = noLeadingPyDir.lastIndexOf("."); String outputPath = noLeadingPyDir.substring(0, extensionIndex); computeModules(gapicProviders); - return metadataTransformer .generateMetadataView(packageConfig, model, template, outputPath, TargetLanguage.PYTHON) .namespacePackages( computeNamespacePackages(productConfig.getPackageName(), packageConfig.apiVersion())) .developmentStatus( surfaceNamer.getReleaseAnnotation(packageConfig.releaseLevel(TargetLanguage.PYTHON))) + .developmentStatusTitle( + namer.getReleaseAnnotation(packageConfig.releaseLevel(TargetLanguage.PYTHON))) .apiModules(apiModules) .typeModules(typeModules) + .exampleMethods(exampleMethods) + .targetLanguage("Python") + .mainReadmeLink(GITHUB_REPO_HOST + MAIN_README_PATH) + .libraryDocumentationLink( + GITHUB_DOC_HOST + String.format(LIB_DOC_PATH, packageConfig.shortName())) + .authDocumentationLink(GITHUB_DOC_HOST + AUTH_DOC_PATH) + .versioningDocumentationLink(GITHUB_REPO_HOST + MAIN_README_PATH) .build(); } + // Generates methods used as examples for the README.md file. + // This currently generates a list of methods that have smoke test configuration. In the future, + // the example methods may be configured separately. + private List generateExampleMethods( + Model model, GapicProductConfig productConfig) { + ImmutableList.Builder exampleMethods = ImmutableList.builder(); + for (Interface apiInterface : new InterfaceView().getElementIterable(model)) { + GapicInterfaceContext context = createContext(apiInterface, productConfig); + if (context.getInterfaceConfig().getSmokeTestConfig() != null) { + Method method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); + FlatteningConfig flatteningGroup = + testCaseTransformer.getSmokeTestFlatteningGroup( + context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig()); + GapicMethodContext flattenedMethodContext = + context.asFlattenedMethodContext(method, flatteningGroup); + exampleMethods.add(createExampleApiMethodView(flattenedMethodContext)); + } + } + return exampleMethods.build(); + } + + private OptionalArrayMethodView createExampleApiMethodView(GapicMethodContext context) { + DynamicLangApiMethodTransformer apiMethodTransformer = + new DynamicLangApiMethodTransformer( + new PythonApiMethodParamTransformer(), + new InitCodeTransformer(new PythonImportSectionTransformer())); + + return apiMethodTransformer.generateMethod(context); + } + /** Determines the Python files generated in the main phase of generation. */ private void computeModules(List> gapicProviders) { // Only run generation once. @@ -197,4 +265,16 @@ private List computeInitFiles(List packages, final String api } return initFiles; } + + private GapicInterfaceContext createContext( + Interface apiInterface, GapicProductConfig productConfig) { + return GapicInterfaceContext.create( + apiInterface, + productConfig, + new ModelTypeTable( + new PythonTypeTable(productConfig.getPackageName()), + new PythonModelTypeNameConverter(productConfig.getPackageName())), + new PythonSurfaceNamer(productConfig.getPackageName()), + new DefaultFeatureConfig()); + } } diff --git a/src/main/java/com/google/api/codegen/transformer/ruby/RubyModelTypeNameConverter.java b/src/main/java/com/google/api/codegen/transformer/ruby/RubyModelTypeNameConverter.java index 29a2b60e18..29a6578a85 100644 --- a/src/main/java/com/google/api/codegen/transformer/ruby/RubyModelTypeNameConverter.java +++ b/src/main/java/com/google/api/codegen/transformer/ruby/RubyModelTypeNameConverter.java @@ -133,7 +133,8 @@ public TypedValue getSnippetZeroValue(TypeRef type) { return TypedValue.create(getTypeName(type), PRIMITIVE_ZERO_VALUE.get(type.getKind())); } if (type.isMessage()) { - return TypedValue.create(getTypeName(type), "%s.new"); + TypeName typeName = getTypeName(type); + return TypedValue.create(typeName, typeName.getFullName() + ".new"); } if (type.isEnum()) { return getEnumValue(type, type.getEnumType().getValues().get(0)); @@ -185,6 +186,6 @@ public TypeName getTypeNameForResourceNameElementType( @Override public TypedValue getEnumValue(TypeRef type, EnumValue value) { - return TypedValue.create(getTypeName(type), "%s::" + value.getSimpleName()); + return TypedValue.create(getTypeName(type), ":" + value.getSimpleName()); } } diff --git a/src/main/java/com/google/api/codegen/transformer/ruby/RubyPackageMetadataTransformer.java b/src/main/java/com/google/api/codegen/transformer/ruby/RubyPackageMetadataTransformer.java index 58d13b7812..dc44880fda 100644 --- a/src/main/java/com/google/api/codegen/transformer/ruby/RubyPackageMetadataTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/ruby/RubyPackageMetadataTransformer.java @@ -16,31 +16,59 @@ import com.google.api.codegen.InterfaceView; import com.google.api.codegen.TargetLanguage; +import com.google.api.codegen.config.FlatteningConfig; import com.google.api.codegen.config.GapicProductConfig; import com.google.api.codegen.config.PackageMetadataConfig; +import com.google.api.codegen.transformer.DynamicLangApiMethodTransformer; import com.google.api.codegen.transformer.FileHeaderTransformer; import com.google.api.codegen.transformer.GapicInterfaceContext; +import com.google.api.codegen.transformer.GapicMethodContext; +import com.google.api.codegen.transformer.InitCodeTransformer; import com.google.api.codegen.transformer.ModelToViewTransformer; import com.google.api.codegen.transformer.ModelTypeTable; import com.google.api.codegen.transformer.PackageMetadataTransformer; +import com.google.api.codegen.transformer.SurfaceNamer; +import com.google.api.codegen.transformer.TestCaseTransformer; import com.google.api.codegen.util.ruby.RubyTypeTable; +import com.google.api.codegen.util.testing.StandardValueProducer; +import com.google.api.codegen.util.testing.ValueProducer; +import com.google.api.codegen.viewmodel.ApiMethodView; import com.google.api.codegen.viewmodel.ImportSectionView; +import com.google.api.codegen.viewmodel.InitCodeView; +import com.google.api.codegen.viewmodel.OptionalArrayMethodView; import com.google.api.codegen.viewmodel.ViewModel; import com.google.api.tools.framework.model.Interface; +import com.google.api.tools.framework.model.Method; import com.google.api.tools.framework.model.Model; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import java.util.List; /** Responsible for producing package metadata related views for Ruby */ public class RubyPackageMetadataTransformer implements ModelToViewTransformer { private static final String GEMSPEC_FILE = "ruby/gemspec.snip"; + private static final String README_FILE = "ruby/README.md.snip"; + private static final String README_OUTPUT_FILE = "README.md"; private static final List TOP_LEVEL_FILES = - ImmutableList.of( - "ruby/Gemfile.snip", "ruby/Rakefile.snip", "ruby/README.md.snip", "LICENSE.snip"); + ImmutableList.of("ruby/Gemfile.snip", "ruby/Rakefile.snip", "LICENSE.snip"); + private static final List TOP_LEVEL_DOT_FILES = + ImmutableList.of("ruby/gitignore.snip", "ruby/rubocop.yml.snip", "ruby/yardopts.snip"); + + private static final String GITHUB_DOC_HOST = + "https://googlecloudplatform.github.io/google-cloud-ruby"; + private static final String GITHUB_REPO_HOST = + "https://github.com/GoogleCloudPlatform/google-cloud-ruby"; + private static final String AUTH_DOC_PATH = "/#/docs/google-cloud/master/guides/authentication"; + private static final String LIB_DOC_PATH = "/#/docs/%s/latest/%s"; + private static final String MAIN_README_PATH = "/blob/master/README.md"; + private static final String VERSIONING_DOC_PATH = "#versioning"; + private final FileHeaderTransformer fileHeaderTransformer = new FileHeaderTransformer(new RubyImportSectionTransformer()); private final PackageMetadataConfig packageConfig; private final PackageMetadataTransformer metadataTransformer = new PackageMetadataTransformer(); + private final ValueProducer valueProducer = new StandardValueProducer(); + private final TestCaseTransformer testCaseTransformer = new TestCaseTransformer(valueProducer); private static final String RUBY_PREFIX = "ruby/"; @@ -50,7 +78,12 @@ public RubyPackageMetadataTransformer(PackageMetadataConfig packageConfig) { @Override public List getTemplateFileNames() { - return ImmutableList.builder().add(GEMSPEC_FILE).addAll(TOP_LEVEL_FILES).build(); + return ImmutableList.builder() + .add(GEMSPEC_FILE) + .add(README_FILE) + .addAll(TOP_LEVEL_FILES) + .addAll(TOP_LEVEL_DOT_FILES) + .build(); } @Override @@ -58,7 +91,9 @@ public List transform(Model model, GapicProductConfig productConfig) RubyPackageMetadataNamer namer = new RubyPackageMetadataNamer(productConfig.getPackageName()); return ImmutableList.builder() .add(generateGemspecView(model, namer)) - .addAll(generateMetadataViews(model, productConfig, namer)) + .add(generateReadmeView(model, productConfig, namer)) + .addAll(generateMetadataViews(model, productConfig, namer, TOP_LEVEL_FILES)) + .addAll(generateMetadataViews(model, productConfig, namer, TOP_LEVEL_DOT_FILES, ".")) .build(); } @@ -70,11 +105,86 @@ private ViewModel generateGemspecView(Model model, RubyPackageMetadataNamer name .build(); } - private List generateMetadataViews( + private ViewModel generateReadmeView( Model model, GapicProductConfig productConfig, RubyPackageMetadataNamer namer) { + List exampleMethods = generateExampleMethods(model, productConfig); + return metadataTransformer + .generateMetadataView( + packageConfig, model, README_FILE, README_OUTPUT_FILE, TargetLanguage.RUBY) + .identifier(namer.getMetadataIdentifier()) + .fileHeader( + fileHeaderTransformer.generateFileHeader( + productConfig, + ImportSectionView.newBuilder().build(), + new RubySurfaceNamer(productConfig.getPackageName()))) + .developmentStatusTitle( + namer.getReleaseAnnotation(packageConfig.releaseLevel(TargetLanguage.RUBY))) + .exampleMethods(exampleMethods) + .targetLanguage("Ruby") + .mainReadmeLink(GITHUB_REPO_HOST + MAIN_README_PATH) + .libraryDocumentationLink( + GITHUB_DOC_HOST + + String.format( + LIB_DOC_PATH, namer.getMetadataIdentifier(), packageConfig.protoPath())) + .authDocumentationLink(GITHUB_DOC_HOST + AUTH_DOC_PATH) + .versioningDocumentationLink(GITHUB_REPO_HOST + VERSIONING_DOC_PATH) + .build(); + } + + // Generates methods used as examples for the README.md file. + // This currently generates a list of methods that have smoke test configuration. In the future, + // the example methods may be configured separately. + private List generateExampleMethods( + Model model, GapicProductConfig productConfig) { + ImmutableList.Builder exampleMethods = ImmutableList.builder(); + for (Interface apiInterface : new InterfaceView().getElementIterable(model)) { + GapicInterfaceContext context = createContext(apiInterface, productConfig); + if (context.getInterfaceConfig().getSmokeTestConfig() != null) { + Method method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); + FlatteningConfig flatteningGroup = + testCaseTransformer.getSmokeTestFlatteningGroup( + context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig()); + GapicMethodContext flattenedMethodContext = + context.asFlattenedMethodContext(method, flatteningGroup); + exampleMethods.add(createExampleApiMethodView(flattenedMethodContext)); + } + } + return exampleMethods.build(); + } + + private OptionalArrayMethodView createExampleApiMethodView(GapicMethodContext context) { + OptionalArrayMethodView initialApiMethodView = + new DynamicLangApiMethodTransformer(new RubyApiMethodParamTransformer()) + .generateMethod(context); + + OptionalArrayMethodView.Builder apiMethodView = initialApiMethodView.toBuilder(); + + InitCodeTransformer initCodeTransformer = new InitCodeTransformer(); + InitCodeView initCodeView = + initCodeTransformer.generateInitCode( + context, testCaseTransformer.createSmokeTestInitContext(context)); + apiMethodView.initCode(initCodeView); + + return apiMethodView.build(); + } + + private List generateMetadataViews( + Model model, + GapicProductConfig productConfig, + RubyPackageMetadataNamer namer, + List snippets) { + return generateMetadataViews(model, productConfig, namer, snippets, null); + } + + private List generateMetadataViews( + Model model, + GapicProductConfig productConfig, + RubyPackageMetadataNamer namer, + List snippets, + String filePrefix) { ImmutableList.Builder views = ImmutableList.builder(); - for (String template : TOP_LEVEL_FILES) { - views.add(generateMetadataView(model, productConfig, template, namer)); + for (String template : snippets) { + views.add(generateMetadataView(model, productConfig, template, namer, filePrefix)); } return views.build(); } @@ -83,9 +193,13 @@ private ViewModel generateMetadataView( Model model, GapicProductConfig productConfig, String template, - RubyPackageMetadataNamer namer) { + RubyPackageMetadataNamer namer, + String filePrefix) { String noLeadingRubyDir = template.startsWith(RUBY_PREFIX) ? template.substring(RUBY_PREFIX.length()) : template; + if (!Strings.isNullOrEmpty(filePrefix)) { + noLeadingRubyDir = filePrefix + noLeadingRubyDir; + } int extensionIndex = noLeadingRubyDir.lastIndexOf("."); String outputPath = noLeadingRubyDir.substring(0, extensionIndex); @@ -98,15 +212,16 @@ private ViewModel generateMetadataView( } } + SurfaceNamer surfaceNamer = new RubySurfaceNamer(productConfig.getPackageName()); + return metadataTransformer .generateMetadataView(packageConfig, model, template, outputPath, TargetLanguage.RUBY) .identifier(namer.getMetadataIdentifier()) .fileHeader( fileHeaderTransformer.generateFileHeader( - productConfig, - ImportSectionView.newBuilder().build(), - new RubySurfaceNamer(productConfig.getPackageName()))) + productConfig, ImportSectionView.newBuilder().build(), surfaceNamer)) .hasSmokeTests(hasSmokeTests) + .versionPath(surfaceNamer.getVersionIndexFileImportName()) .build(); } diff --git a/src/main/java/com/google/api/codegen/util/CommentTransformer.java b/src/main/java/com/google/api/codegen/util/CommentTransformer.java new file mode 100644 index 0000000000..db4c594b43 --- /dev/null +++ b/src/main/java/com/google/api/codegen/util/CommentTransformer.java @@ -0,0 +1,103 @@ +/* Copyright 2017 Google Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.api.codegen.util; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class CommentTransformer { + + public static String CLOUD_URL_PREFIX = "https://cloud.google.com"; + + private ImmutableList transformations; + + private CommentTransformer(ImmutableList transformations) { + this.transformations = transformations; + } + + public String transform(String comment) { + for (Transformation transformation : transformations) { + comment = transformation.apply(comment); + } + return comment; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public static class Builder { + + private ImmutableList.Builder transformations = ImmutableList.builder(); + + private Builder() {} + + public Builder replace(Pattern pattern, final String replacement) { + transformations.add( + new Transformation( + pattern, + new Function() { + @Override + public String apply(String s) { + return replacement; + } + })); + return this; + } + + public Builder scopedReplace(Pattern pattern, final String target, final String replacement) { + return transform( + new Transformation( + pattern, + new Function() { + @Override + public String apply(String matchedString) { + return matchedString.replace(target, replacement); + } + })); + } + + public Builder transform(Transformation transformation) { + transformations.add(transformation); + return this; + } + + public CommentTransformer build() { + return new CommentTransformer(transformations.build()); + } + } + + public static class Transformation { + private Pattern pattern; + private Function replacementFunction; + + public Transformation(Pattern pattern, Function replacementFunction) { + this.pattern = pattern; + this.replacementFunction = replacementFunction; + } + + public String apply(String comment) { + StringBuffer sb = new StringBuffer(); + Matcher m = pattern.matcher(comment); + while (m.find()) { + m.appendReplacement(sb, replacementFunction.apply(m.group())); + } + m.appendTail(sb); + return sb.toString(); + } + } +} diff --git a/src/main/java/com/google/api/codegen/util/LinkPattern.java b/src/main/java/com/google/api/codegen/util/LinkPattern.java new file mode 100644 index 0000000000..019e43c499 --- /dev/null +++ b/src/main/java/com/google/api/codegen/util/LinkPattern.java @@ -0,0 +1,73 @@ +/* Copyright 2017 Google Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.api.codegen.util; + +import com.google.api.codegen.CommentPatterns; +import com.google.api.codegen.util.CommentTransformer.Transformation; +import com.google.common.base.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * An collection of known link patterns found in proto files. The LinkPattern class provides an easy + * way to create Transformation objects for these link patterns into a particular format. + * + *

The format may contain standard Java string format tokens, or the special tokens $TITLE and + * $URL. + * + *

An example creating a Transformation for a relative link would be: + * + *

+ * 
+ * Transformation transformation = LinkPattern.RELATIVE
+ *    .withUrlPrefix("https://cloud.google.com")
+ *    .toFormat("[$TITLE]($URL)"));
+ * 
+ * 
+ */ +public class LinkPattern { + public static LinkPattern ABSOLUTE = new LinkPattern(CommentPatterns.ABSOLUTE_LINK_PATTERN, ""); + public static LinkPattern RELATIVE = new LinkPattern(CommentPatterns.RELATIVE_LINK_PATTERN, ""); + public static LinkPattern PROTO = new LinkPattern(CommentPatterns.PROTO_LINK_PATTERN, ""); + + private Pattern pattern; + private String urlPrefix; + + private LinkPattern(Pattern pattern, String urlPrefix) { + this.pattern = pattern; + this.urlPrefix = urlPrefix; + } + + public LinkPattern withUrlPrefix(String urlPrefix) { + return new LinkPattern(pattern, urlPrefix); + } + + public Transformation toFormat(String linkFormat) { + final String finalLinkFormat = + linkFormat.replaceAll("\\$TITLE", "%1\\$s").replaceAll("\\$URL", "%2\\$s"); + return new Transformation( + pattern, + new Function() { + @Override + public String apply(String matchedString) { + Matcher matcher = pattern.matcher(matchedString); + matcher.find(); + String title = matcher.group(1); + String url = urlPrefix + matcher.group(2); + return Matcher.quoteReplacement(String.format(finalLinkFormat, title, url)); + } + }); + } +} diff --git a/src/main/java/com/google/api/codegen/util/js/JSCommentReformatter.java b/src/main/java/com/google/api/codegen/util/js/JSCommentReformatter.java index ae750d3e80..f1c0c99b08 100644 --- a/src/main/java/com/google/api/codegen/util/js/JSCommentReformatter.java +++ b/src/main/java/com/google/api/codegen/util/js/JSCommentReformatter.java @@ -14,50 +14,27 @@ */ package com.google.api.codegen.util.js; -import com.google.api.codegen.CommentPatterns; import com.google.api.codegen.util.CommentReformatter; +import com.google.api.codegen.util.CommentTransformer; +import com.google.api.codegen.util.LinkPattern; import com.google.api.tools.framework.model.ProtoElement; import com.google.api.tools.framework.model.ProtoFile; import com.google.common.collect.ImmutableSet; -import java.util.regex.Matcher; public class JSCommentReformatter implements CommentReformatter { - @Override - public String reformat(String comment) { - comment = reformatProtoMarkdownLinks(comment); - comment = reformatCloudMarkdownLinks(comment); - return comment.trim(); - } - /** Returns a string with all proto markdown links formatted to JSDoc style. */ - private String reformatProtoMarkdownLinks(String comment) { - StringBuffer sb = new StringBuffer(); - Matcher m = CommentPatterns.PROTO_LINK_PATTERN.matcher(comment); - if (!m.find()) { - return comment; - } - do { - // proto display name may contain '$' which needs to be escaped using Matcher.quoteReplacement - m.appendReplacement(sb, Matcher.quoteReplacement(String.format("{@link %s}", m.group(1)))); - } while (m.find()); - m.appendTail(sb); - return sb.toString(); - } + private CommentTransformer transformer = + CommentTransformer.newBuilder() + .transform(LinkPattern.PROTO.toFormat("{@link $TITLE}")) + .transform( + LinkPattern.RELATIVE + .withUrlPrefix(CommentTransformer.CLOUD_URL_PREFIX) + .toFormat("[$TITLE]($URL)")) + .build(); - /** Returns a string with all cloud markdown links formatted to JSDoc style. */ - private String reformatCloudMarkdownLinks(String comment) { - StringBuffer sb = new StringBuffer(); - Matcher m = CommentPatterns.CLOUD_LINK_PATTERN.matcher(comment); - if (!m.find()) { - return comment; - } - do { - String url = "https://cloud.google.com" + m.group(2); - // cloud markdown links may contain '$' which needs to be escaped using Matcher.quoteReplacement - m.appendReplacement(sb, Matcher.quoteReplacement(String.format("[%s](%s)", m.group(1), url))); - } while (m.find()); - m.appendTail(sb); - return sb.toString(); + @Override + public String reformat(String comment) { + return transformer.transform(comment).trim(); } public String getLinkedElementName(ProtoElement element) { diff --git a/src/main/java/com/google/api/codegen/util/php/PhpCommentReformatter.java b/src/main/java/com/google/api/codegen/util/php/PhpCommentReformatter.java index 72845a1708..8874642f13 100644 --- a/src/main/java/com/google/api/codegen/util/php/PhpCommentReformatter.java +++ b/src/main/java/com/google/api/codegen/util/php/PhpCommentReformatter.java @@ -15,16 +15,26 @@ package com.google.api.codegen.util.php; import com.google.api.codegen.util.CommentReformatter; -import com.google.common.escape.Escaper; -import com.google.common.escape.Escapers; +import com.google.api.codegen.util.CommentTransformer; +import com.google.api.codegen.util.LinkPattern; +import java.util.regex.Pattern; public class PhpCommentReformatter implements CommentReformatter { - /** Escaper for formatting PHP doc strings. */ - private static final Escaper PHP_ESCAPER = - Escapers.builder().addEscape('*', "*").addEscape('@', "@").build(); + public static final Pattern ASTERISK_PATTERN = Pattern.compile("\\*"); + public static final Pattern AMPERSAND_PATTERN = Pattern.compile("@"); + + private CommentTransformer transformer = + CommentTransformer.newBuilder() + .replace(ASTERISK_PATTERN, "*") + .replace(AMPERSAND_PATTERN, "@") + .transform( + LinkPattern.RELATIVE + .withUrlPrefix(CommentTransformer.CLOUD_URL_PREFIX) + .toFormat("[$TITLE]($URL)")) + .build(); @Override public String reformat(String comment) { - return PHP_ESCAPER.escape(comment).trim(); + return transformer.transform(comment).trim(); } } diff --git a/src/main/java/com/google/api/codegen/util/py/PythonCommentReformatter.java b/src/main/java/com/google/api/codegen/util/py/PythonCommentReformatter.java index c89757cc79..56704e9169 100644 --- a/src/main/java/com/google/api/codegen/util/py/PythonCommentReformatter.java +++ b/src/main/java/com/google/api/codegen/util/py/PythonCommentReformatter.java @@ -16,10 +16,23 @@ import com.google.api.codegen.CommentPatterns; import com.google.api.codegen.util.CommentReformatter; +import com.google.api.codegen.util.CommentTransformer; +import com.google.api.codegen.util.LinkPattern; import com.google.common.base.Splitter; -import java.util.regex.Matcher; public class PythonCommentReformatter implements CommentReformatter { + + private CommentTransformer transformer = + CommentTransformer.newBuilder() + .replace(CommentPatterns.BACK_QUOTE_PATTERN, "``") + .transform(LinkPattern.PROTO.toFormat("``$TITLE``")) + .transform(LinkPattern.ABSOLUTE.toFormat("`$TITLE <$URL>`_")) + .transform( + LinkPattern.RELATIVE + .withUrlPrefix(CommentTransformer.CLOUD_URL_PREFIX) + .toFormat("`$TITLE <$URL>`_")) + .build(); + @Override public String reformat(String comment) { boolean inCodeBlock = false; @@ -32,7 +45,7 @@ public String reformat(String comment) { if (!(line.trim().isEmpty() || CommentPatterns.CODE_BLOCK_PATTERN.matcher(line).matches())) { inCodeBlock = false; - line = applyTransformations(line); + line = transformer.transform(line); } } else if (CommentPatterns.CODE_BLOCK_PATTERN.matcher(line).matches()) { @@ -40,7 +53,7 @@ public String reformat(String comment) { line = "::\n\n" + line; } else { - line = applyTransformations(line); + line = transformer.transform(line); } if (!first) { @@ -51,60 +64,4 @@ public String reformat(String comment) { } return sb.toString().trim(); } - - private String applyTransformations(String line) { - line = CommentPatterns.BACK_QUOTE_PATTERN.matcher(line).replaceAll("``"); - line = reformatProtoMarkdownLinks(line); - line = reformatAbsoluteMarkdownLinks(line); - return reformatCloudMarkdownLinks(line); - } - - /** Returns a string with all proto markdown links formatted to Sphinx style. */ - private String reformatProtoMarkdownLinks(String comment) { - StringBuffer sb = new StringBuffer(); - Matcher m = CommentPatterns.PROTO_LINK_PATTERN.matcher(comment); - if (!m.find()) { - return comment; - } - do { - // proto display name may contain '$' which needs to be escaped using Matcher.quoteReplacement - m.appendReplacement(sb, Matcher.quoteReplacement(String.format("``%s``", m.group(1)))); - } while (m.find()); - m.appendTail(sb); - return sb.toString(); - } - - /** Returns a string with all absolute markdown links formatted to Sphinx style. */ - private String reformatAbsoluteMarkdownLinks(String comment) { - StringBuffer sb = new StringBuffer(); - Matcher m = CommentPatterns.ABSOLUTE_LINK_PATTERN.matcher(comment); - if (!m.find()) { - return comment; - } - do { - // absolute markdown links may contain '$' which needs to be escaped using Matcher.quoteReplacement - m.appendReplacement( - sb, Matcher.quoteReplacement(String.format("`%s <%s>`_", m.group(1), m.group(2)))); - } while (m.find()); - m.appendTail(sb); - return sb.toString(); - } - - /** Returns a string with all cloud markdown links formatted to Sphinx style. */ - private String reformatCloudMarkdownLinks(String comment) { - StringBuffer sb = new StringBuffer(); - Matcher m = CommentPatterns.CLOUD_LINK_PATTERN.matcher(comment); - if (!m.find()) { - return comment; - } - do { - // cloud markdown links may contain '$' which needs to be escaped using Matcher.quoteReplacement - m.appendReplacement( - sb, - Matcher.quoteReplacement( - String.format("`%s `_", m.group(1), m.group(2)))); - } while (m.find()); - m.appendTail(sb); - return sb.toString(); - } } diff --git a/src/main/java/com/google/api/codegen/util/py/PythonTypeTable.java b/src/main/java/com/google/api/codegen/util/py/PythonTypeTable.java index a7c73cb5b5..1e7c74e043 100644 --- a/src/main/java/com/google/api/codegen/util/py/PythonTypeTable.java +++ b/src/main/java/com/google/api/codegen/util/py/PythonTypeTable.java @@ -14,31 +14,43 @@ */ package com.google.api.codegen.util.py; -import com.google.api.codegen.util.DynamicLangTypeTable; import com.google.api.codegen.util.NamePath; import com.google.api.codegen.util.TypeAlias; import com.google.api.codegen.util.TypeName; import com.google.api.codegen.util.TypeTable; import com.google.common.base.Joiner; import com.google.common.base.Splitter; +import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Multimap; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.TreeMap; /** The TypeTable for Python. */ public class PythonTypeTable implements TypeTable { - private final DynamicLangTypeTable dynamicTypeTable; + /** A bi-map from short names to file names. Should be kept 1:1 with moduleImports keys. */ + private BiMap usedShortNames = HashBiMap.create(); + + /** + * A multimap from module names to type aliases in the module. Keys should be kept 1:1 with + * usedShortNames. + */ + private Multimap moduleImports = HashMultimap.create(); + + private final String implicitPackageName; public PythonTypeTable(String implicitPackageName) { - dynamicTypeTable = new DynamicLangTypeTable(implicitPackageName, "."); + this.implicitPackageName = implicitPackageName; } @Override public TypeTable cloneEmpty() { - return new PythonTypeTable(dynamicTypeTable.getImplicitPackageName()); + return new PythonTypeTable(implicitPackageName); } @Override @@ -62,7 +74,7 @@ public TypeName getTypeName(String fullName) { @Override public TypeName getTypeNameInImplicitPackage(String shortName) { - return dynamicTypeTable.getTypeNameInImplicitPackage(shortName); + return new TypeName(implicitPackageName + "." + shortName, shortName); } @Override @@ -82,19 +94,88 @@ public String getAndSaveNicknameFor(String fullName) { @Override public String getAndSaveNicknameFor(TypeName typeName) { - return dynamicTypeTable.getAndSaveNicknameFor(typeName); + return typeName.getAndSaveNicknameIn(this); } @Override public String getAndSaveNicknameFor(TypeAlias alias) { - return dynamicTypeTable.getAndSaveNicknameFor(alias); + if (!alias.needsImport()) { + return alias.getNickname(); + } + + String shortName = alias.getNickname().substring(0, alias.getNickname().indexOf(".")); + String className = alias.getNickname().substring(alias.getNickname().indexOf(".") + 1); + String moduleName = + alias.getFullName().substring(0, alias.getFullName().length() - className.length() - 1); + if (usedShortNames.containsKey(shortName)) { + // Short name already there. + String oldModuleName = usedShortNames.get(shortName); + if (moduleName.equals(oldModuleName)) { + // New alias for existing module import, no clash + // Name already in multimap, add alias + moduleImports.put(moduleName, alias); + return alias.getNickname(); + } + + // Short name clashes, disambiguate. + String disambiguatedOldShortName = disambiguate(oldModuleName, shortName); + String disambiguatedNewShortName = disambiguate(moduleName, shortName); + + usedShortNames.remove(shortName); + updateOldImports(disambiguatedOldShortName, moduleImports.removeAll(oldModuleName)); + + return getAndSaveNicknameFor( + TypeAlias.createAliasedImport( + alias.getFullName(), disambiguatedNewShortName + "." + className)); + } + + if (moduleImports.containsKey(moduleName)) { + // Use existing local name for already used module + String newShortName = usedShortNames.inverse().get(moduleName); + return getAndSaveNicknameFor( + TypeAlias.createAliasedImport(alias.getFullName(), newShortName + "." + className)); + } + + usedShortNames.put(shortName, moduleName); + moduleImports.put(moduleName, alias); + return alias.getNickname(); + } + + /* Attempts to disambiguate an import by moving the highest-level single package name not already + * present in the alias into the alias: + * "from foo import bar as baz" ====> "from foo import bar as foo_baz" + * "from foo.bar import baz as bar_baz" ====> "from foo.bar import baz as foo_bar_baz" + */ + private String disambiguate(String moduleName, String localName) { + List nameParts = Splitter.on(".").splitToList(moduleName); + String localNamePackagePrefix = ""; + + for (int i = nameParts.size() - 2; i >= 0; --i) { + localNamePackagePrefix = nameParts.get(i) + "_" + localNamePackagePrefix; + if (!localName.contains(localNamePackagePrefix)) { + return nameParts.get(i) + "_" + localName; + } + } + + throw new IllegalStateException("Can't disambiguate a module (" + moduleName + ") with itself"); + } + + private void updateOldImports(String shortName, Collection aliases) { + for (TypeAlias alias : aliases) { + String className = alias.getNickname().substring(alias.getNickname().indexOf(".") + 1); + getAndSaveNicknameFor( + TypeAlias.createAliasedImport(alias.getFullName(), shortName + "." + className)); + } } @Override public Map getImports() { - TreeMap inverseMap = new TreeMap<>(TypeAlias.getNicknameComparator()); - inverseMap.putAll(dynamicTypeTable.getImportsBimap().inverse()); - return HashBiMap.create(inverseMap).inverse(); + ImmutableMap.Builder imports = ImmutableMap.builder(); + for (Collection aliases : moduleImports.asMap().values()) { + TypeAlias alias = aliases.iterator().next(); + imports.put(alias.getFullName(), alias); + } + return imports.build(); } public boolean hasImports() { @@ -104,6 +185,6 @@ public boolean hasImports() { @Override public String getAndSaveNicknameForInnerType( String containerFullName, String innerTypeShortName) { - return dynamicTypeTable.getAndSaveNicknameForInnerType(containerFullName, innerTypeShortName); + throw new UnsupportedOperationException("getAndSaveNicknameForInnerType not supported"); } } diff --git a/src/main/java/com/google/api/codegen/util/ruby/RubyCommentReformatter.java b/src/main/java/com/google/api/codegen/util/ruby/RubyCommentReformatter.java index a25facc424..167dcb100f 100644 --- a/src/main/java/com/google/api/codegen/util/ruby/RubyCommentReformatter.java +++ b/src/main/java/com/google/api/codegen/util/ruby/RubyCommentReformatter.java @@ -16,6 +16,10 @@ import com.google.api.codegen.CommentPatterns; import com.google.api.codegen.util.CommentReformatter; +import com.google.api.codegen.util.CommentTransformer; +import com.google.api.codegen.util.CommentTransformer.Transformation; +import com.google.api.codegen.util.LinkPattern; +import com.google.common.base.Function; import com.google.common.base.Splitter; import com.google.common.base.Strings; import java.util.regex.Matcher; @@ -23,6 +27,30 @@ public class RubyCommentReformatter implements CommentReformatter { private static final String BULLET = "* "; + private static Transformation PROTO_TO_RUBY_DOC_TRANSFORMATION = + new Transformation( + CommentPatterns.PROTO_LINK_PATTERN, + new Function() { + @Override + public String apply(String matchedString) { + Matcher matcher = CommentPatterns.PROTO_LINK_PATTERN.matcher(matchedString); + matcher.find(); + return Matcher.quoteReplacement(protoToRubyDoc(matcher.group(1))); + } + }); + + private CommentTransformer transformer = + CommentTransformer.newBuilder() + .replace(CommentPatterns.BACK_QUOTE_PATTERN, "+") + .transform(PROTO_TO_RUBY_DOC_TRANSFORMATION) + .transform( + LinkPattern.RELATIVE + .withUrlPrefix(CommentTransformer.CLOUD_URL_PREFIX) + .toFormat("{$TITLE}[$URL]")) + .transform(LinkPattern.ABSOLUTE.toFormat("{$TITLE}[$URL]")) + .scopedReplace(CommentPatterns.HEADLINE_PATTERN, "#", "=") + .build(); + @Override public String reformat(String comment) { StringBuffer sb = new StringBuffer(); @@ -47,39 +75,14 @@ public String reformat(String comment) { line = line.trim(); sb.append(Strings.repeat(" ", listIndent)); } - sb.append(applyTransformations(line)).append("\n"); + sb.append(transformer.transform(line)).append("\n"); followsListItem = matchesList; followsBlankLine = line.isEmpty(); } return sb.toString().trim(); } - private String applyTransformations(String line) { - line = CommentPatterns.BACK_QUOTE_PATTERN.matcher(line).replaceAll("+"); - line = reformatProtoMarkdownLinks(line); - line = reformatCloudMarkdownLinks(line); - line = reformatAbsoluteMarkdownLinks(line); - line = reformatHeadline(line); - return line; - } - - /** Returns a string with all proto markdown links formatted to RDoc style. */ - private String reformatProtoMarkdownLinks(String comment) { - StringBuffer sb = new StringBuffer(); - Matcher m = CommentPatterns.PROTO_LINK_PATTERN.matcher(comment); - if (!m.find()) { - return comment; - } - do { - // proto display name may contain '$' which needs to be escaped using Matcher.quoteReplacement - m.appendReplacement( - sb, Matcher.quoteReplacement(String.format("%s", protoToRubyDoc(m.group(1))))); - } while (m.find()); - m.appendTail(sb); - return sb.toString(); - } - - private String protoToRubyDoc(String comment) { + private static String protoToRubyDoc(String comment) { boolean messageFound = false; boolean isFirstSegment = true; String result = ""; @@ -100,49 +103,4 @@ private String protoToRubyDoc(String comment) { } return result; } - - /** Returns a string with all cloud markdown links formatted to RDoc style. */ - private String reformatCloudMarkdownLinks(String comment) { - StringBuffer sb = new StringBuffer(); - Matcher m = CommentPatterns.CLOUD_LINK_PATTERN.matcher(comment); - if (!m.find()) { - return comment; - } - do { - String url = "https://cloud.google.com" + m.group(2); - // cloud markdown links may contain '$' which needs to be escaped using Matcher.quoteReplacement - m.appendReplacement(sb, Matcher.quoteReplacement(String.format("{%s}[%s]", m.group(1), url))); - } while (m.find()); - m.appendTail(sb); - return sb.toString(); - } - - /** Returns a string with all absolute markdown links formatted to RDoc style. */ - private String reformatAbsoluteMarkdownLinks(String comment) { - StringBuffer sb = new StringBuffer(); - Matcher m = CommentPatterns.ABSOLUTE_LINK_PATTERN.matcher(comment); - if (!m.find()) { - return comment; - } - do { - // absolute markdown links may contain '$' which needs to be escaped using Matcher.quoteReplacement - m.appendReplacement( - sb, Matcher.quoteReplacement(String.format("{%s}[%s]", m.group(1), m.group(2)))); - } while (m.find()); - m.appendTail(sb); - return sb.toString(); - } - - private String reformatHeadline(String comment) { - StringBuffer sb = new StringBuffer(); - Matcher m = CommentPatterns.HEADLINE_PATTERN.matcher(comment); - if (!m.find()) { - return comment; - } - do { - m.appendReplacement(sb, m.group().replace("#", "=")); - } while (m.find()); - m.appendTail(sb); - return sb.toString(); - } } diff --git a/src/main/java/com/google/api/codegen/viewmodel/FormattedInitValueView.java b/src/main/java/com/google/api/codegen/viewmodel/FormattedInitValueView.java index d49c95131c..414eaab0c0 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/FormattedInitValueView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/FormattedInitValueView.java @@ -21,6 +21,8 @@ public abstract class FormattedInitValueView implements InitValueView { public abstract String apiWrapperName(); + public abstract String fullyQualifiedApiWrapperName(); + public abstract String formatFunctionName(); public abstract List formatArgs(); @@ -37,6 +39,8 @@ public static Builder newBuilder() { public abstract static class Builder { public abstract Builder apiWrapperName(String val); + public abstract Builder fullyQualifiedApiWrapperName(String val); + public abstract Builder formatFunctionName(String val); public abstract Builder formatArgs(List val); diff --git a/src/main/java/com/google/api/codegen/viewmodel/OptionalArrayMethodView.java b/src/main/java/com/google/api/codegen/viewmodel/OptionalArrayMethodView.java index 0ace74f134..bb5cb2ed51 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/OptionalArrayMethodView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/OptionalArrayMethodView.java @@ -26,6 +26,8 @@ public abstract class OptionalArrayMethodView implements ApiMethodView { public abstract String apiClassName(); + public abstract String fullyQualifiedApiClassName(); + public abstract String apiVariableName(); public abstract String apiModuleName(); @@ -89,6 +91,8 @@ public abstract static class Builder { public abstract Builder apiClassName(String val); + public abstract Builder fullyQualifiedApiClassName(String val); + public abstract Builder apiVariableName(String val); public abstract Builder apiModuleName(String val); diff --git a/src/main/java/com/google/api/codegen/viewmodel/StaticLangClientFileView.java b/src/main/java/com/google/api/codegen/viewmodel/StaticLangClientFileView.java index e8542dc248..f2675a4c6e 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/StaticLangClientFileView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/StaticLangClientFileView.java @@ -71,6 +71,10 @@ public String resourceRoot() { public abstract List lroDetailViews(); + public boolean hasLongRunningOperations() { + return !lroDetailViews().isEmpty(); + } + public static Builder newBuilder() { return new AutoValue_StaticLangClientFileView.Builder(); } diff --git a/src/main/java/com/google/api/codegen/viewmodel/StructureInitCodeLineView.java b/src/main/java/com/google/api/codegen/viewmodel/StructureInitCodeLineView.java index 2573e2916c..3b3655bc65 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/StructureInitCodeLineView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/StructureInitCodeLineView.java @@ -25,6 +25,8 @@ public abstract class StructureInitCodeLineView implements InitCodeLineView { public abstract String typeName(); + public abstract String fullyQualifiedTypeName(); + public abstract String typeConstructor(); @Override @@ -42,6 +44,8 @@ public abstract static class Builder { public abstract Builder typeName(String val); + public abstract Builder fullyQualifiedTypeName(String val); + public abstract Builder typeConstructor(String val); public abstract Builder identifier(String val); diff --git a/src/main/java/com/google/api/codegen/viewmodel/metadata/PackageMetadataView.java b/src/main/java/com/google/api/codegen/viewmodel/metadata/PackageMetadataView.java index aba218b2df..d08a4cc8eb 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/metadata/PackageMetadataView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/metadata/PackageMetadataView.java @@ -18,6 +18,7 @@ import com.google.api.codegen.config.VersionBound; import com.google.api.codegen.grpcmetadatagen.GenerationLayer; import com.google.api.codegen.grpcmetadatagen.PackageType; +import com.google.api.codegen.viewmodel.ApiMethodView; import com.google.api.codegen.viewmodel.FileHeaderView; import com.google.api.codegen.viewmodel.ViewModel; import com.google.auto.value.AutoValue; @@ -50,6 +51,8 @@ public String resourceRoot() { @Nullable public abstract String identifier(); + public abstract String apiSummary(); + public abstract VersionBound packageVersionBound(); public abstract VersionBound gaxVersionBound(); @@ -84,6 +87,9 @@ public String resourceRoot() { public abstract String protoPath(); + @Nullable + public abstract String versionPath(); + public abstract String author(); public abstract String email(); @@ -95,10 +101,16 @@ public String resourceRoot() { @Nullable public abstract String developmentStatus(); + @Nullable + public abstract String developmentStatusTitle(); + public abstract boolean hasMultipleServices(); public abstract boolean hasSmokeTests(); + @Nullable + public abstract List exampleMethods(); + // TODO(landrito) Currently only Ruby supports using fileHeaderView. Switch all metadata gen to // use this field. @Nullable @@ -114,6 +126,21 @@ public String resourceRoot() { @Nullable public abstract List typeModules(); + @Nullable + public abstract String targetLanguage(); + + @Nullable + public abstract String mainReadmeLink(); + + @Nullable + public abstract String authDocumentationLink(); + + @Nullable + public abstract String libraryDocumentationLink(); + + @Nullable + public abstract String versioningDocumentationLink(); + public static Builder newBuilder() { return new AutoValue_PackageMetadataView.Builder().hasSmokeTests(false); } @@ -148,6 +175,9 @@ public abstract static class Builder { public abstract Builder serviceName(String val); + /** The descriptive summary of the api. */ + public abstract Builder apiSummary(String val); + /** The full name of the API, including branding. E.g., "Stackdriver Logging". */ public abstract Builder fullName(String val); @@ -169,6 +199,8 @@ public abstract static class Builder { /** The path to the API protos in the googleapis repo. */ public abstract Builder protoPath(String val); + public abstract Builder versionPath(String val); + /** The author of the package. */ public abstract Builder author(String val); @@ -184,6 +216,9 @@ public abstract static class Builder { /** The developement status of the package. E.g., "alpha". */ public abstract Builder developmentStatus(String val); + /** The developement status of the package used in titles. E.g., "Alpha". */ + public abstract Builder developmentStatusTitle(String s); + /** Whether the package contains multiple service objects */ public abstract Builder hasMultipleServices(boolean val); @@ -202,6 +237,26 @@ public abstract static class Builder { /** File header information such as copyright lines and license lines */ public abstract Builder fileHeader(FileHeaderView val); + /** Methods to show smoke test examples for in the readme * */ + public abstract Builder exampleMethods(List vals); + + /** + * The language that is being generated; primarily used in titles. First letter is uppercase. + */ + public abstract Builder targetLanguage(String val); + + /** Link to the main README of the metapackage. */ + public abstract Builder mainReadmeLink(String s); + + /** Link to authentication instructions on github.io. */ + public abstract Builder authDocumentationLink(String s); + + /** Link to the client library documentation on github.io. */ + public abstract Builder libraryDocumentationLink(String s); + + /** Link to the semantic versioning information of the metapackage. */ + public abstract Builder versioningDocumentationLink(String s); + public abstract PackageMetadataView build(); } } diff --git a/src/main/java/com/google/api/codegen/viewmodel/metadata/VersionIndexRequireView.java b/src/main/java/com/google/api/codegen/viewmodel/metadata/VersionIndexRequireView.java index d655586833..b8326461eb 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/metadata/VersionIndexRequireView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/metadata/VersionIndexRequireView.java @@ -14,13 +14,24 @@ */ package com.google.api.codegen.viewmodel.metadata; +import com.google.api.codegen.viewmodel.ServiceDocView; import com.google.auto.value.AutoValue; +import javax.annotation.Nullable; @AutoValue public abstract class VersionIndexRequireView { public abstract String clientName(); + @Nullable + public abstract String serviceName(); + + @Nullable + public abstract String localName(); + + @Nullable + public abstract ServiceDocView doc(); + public abstract String fileName(); public static Builder newBuilder() { @@ -31,6 +42,12 @@ public static Builder newBuilder() { public abstract static class Builder { public abstract Builder clientName(String val); + public abstract Builder serviceName(String val); + + public abstract Builder localName(String val); + + public abstract Builder doc(ServiceDocView val); + public abstract Builder fileName(String val); public abstract VersionIndexRequireView build(); diff --git a/src/main/java/com/google/api/codegen/viewmodel/testing/TestCaseView.java b/src/main/java/com/google/api/codegen/viewmodel/testing/TestCaseView.java index cfcd0a3a5c..7eed6a8118 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/testing/TestCaseView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/testing/TestCaseView.java @@ -45,6 +45,8 @@ public abstract class TestCaseView { public abstract String serviceConstructorName(); + public abstract String fullyQualifiedServiceClassName(); + public abstract String mockServiceVarName(); public abstract boolean hasRequestParameters(); @@ -74,6 +76,8 @@ public abstract static class Builder { public abstract Builder serviceConstructorName(String val); + public abstract Builder fullyQualifiedServiceClassName(String val); + public abstract Builder mockServiceVarName(String val); public abstract Builder initCode(InitCodeView val); diff --git a/src/main/resources/com/google/api/codegen/go/doc.snip b/src/main/resources/com/google/api/codegen/go/doc.snip index a9a78ac7de..773e32cbc5 100644 --- a/src/main/resources/com/google/api/codegen/go/doc.snip +++ b/src/main/resources/com/google/api/codegen/go/doc.snip @@ -20,11 +20,11 @@ "google.golang.org/grpc/metadata" ) - func insertXGoog(ctx context.Context, val string) context.Context { - md, _ := metadata.FromContext(ctx) + func insertXGoog(ctx context.Context, val []string) context.Context { + md, _ := metadata.FromOutgoingContext(ctx) md = md.Copy() - md["x-goog-api-client"] = []string{val} - return metadata.NewContext(ctx, md) + md["x-goog-api-client"] = val + return metadata.NewOutgoingContext(ctx, md) } func DefaultAuthScopes() []string { diff --git a/src/main/resources/com/google/api/codegen/go/main.snip b/src/main/resources/com/google/api/codegen/go/main.snip index 7e9d017d69..039aa76a6d 100644 --- a/src/main/resources/com/google/api/codegen/go/main.snip +++ b/src/main/resources/com/google/api/codegen/go/main.snip @@ -66,11 +66,18 @@ {@stub.name} {@stub.grpcClientTypeName} @end + @if view.hasLongRunningOperations + // LROClient is used internally to handle longrunning operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient + @end + // The call options for this service. CallOptions *{@view.callOptionsTypeName} // The metadata to be sent with each request. - xGoogHeader string + xGoogHeader []string } // {@view.clientConstructorName} creates a new {@view.servicePhraseName} client. @@ -93,6 +100,19 @@ @end } c.SetGoogleClientInfo() + @if view.hasLongRunningOperations + + c.LROClient, err = lroauto.NewOperationsClient(ctx, option.WithGRPCConn(conn)) + if err != nil { + // This error "should not happen", since we are just reusing old connection + // and never actually need to dial. + // If this does happen, we could leak conn. However, we cannot close conn: + // If the user invoked the function with option.WithGRPCConn, + // we would close a connection that's still in use. + // TODO(pongad): investigate error conditions. + return nil, err + } + @end return c, nil } @@ -113,7 +133,7 @@ func (c *{@view.clientTypeName}) SetGoogleClientInfo(keyval ...string) { kv := append([]string{"gl-go", version.Go()}, keyval...) kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogHeader = gax.XGoogHeader(kv...) + c.xGoogHeader = []string{gax.XGoogHeader(kv...)} } @join getter : view.pathTemplateGetters @@ -208,8 +228,7 @@ return nil, err } return &{@method.operationMethod.clientReturnTypeName}{ - lro: longrunning.InternalNewOperation(c.Connection(), resp), - xGoogHeader: c.xGoogHeader, + lro: longrunning.InternalNewOperation(c.LROClient, resp), }, nil } @end @@ -328,25 +347,16 @@ @end @private lroWrapper(view, lro) - @if lro.isEmptyOperation - // {@lro.clientReturnTypeName} manages a long-running operation with no result. - @else - // {@lro.clientReturnTypeName} manages a long-running operation from {@lro.methodName}. - @end - + // {@lro.clientReturnTypeName} manages a long-running operation from {@lro.methodName}. type {@lro.clientReturnTypeName} struct { lro *longrunning.Operation - - // The metadata to be sent with each request. - xGoogHeader string } // {@lro.constructorName} returns a new {@lro.clientReturnTypeName} from a given name. // The name must be that of a previously created {@lro.clientReturnTypeName}, possibly from a different process. func (c *{@view.clientTypeName}) {@lro.constructorName}(name string) *{@lro.clientReturnTypeName} { return &{@lro.clientReturnTypeName}{ - lro: longrunning.InternalNewOperation(c.Connection(), &longrunningpb.Operation{Name: name}), - xGoogHeader: c.xGoogHeader, + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), } } @@ -354,9 +364,8 @@ // Wait blocks until the long-running operation is completed, returning any error encountered. // // See documentation of Poll for error-handling information. - func (op *{@lro.clientReturnTypeName}) Wait(ctx context.Context) error { - ctx = insertXGoog(ctx, op.xGoogHeader) - return op.lro.Wait(ctx, nil) + func (op *{@lro.clientReturnTypeName}) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Wait(ctx, nil, opts...) } // Poll fetches the latest state of the long-running operation. @@ -366,18 +375,16 @@ // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and // the operation has completed with failure, the error is returned and op.Done will return true. // If Poll succeeds and the operation has completed successfully, op.Done will return true. - func (op *{@lro.clientReturnTypeName}) Poll(ctx context.Context) error { - ctx = insertXGoog(ctx, op.xGoogHeader) - return op.lro.Poll(ctx, nil) + func (op *{@lro.clientReturnTypeName}) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) } @else // Wait blocks until the long-running operation is completed, returning the response and any errors encountered. // // See documentation of Poll for error-handling information. - func (op *{@lro.clientReturnTypeName}) Wait(ctx context.Context) (*{@lro.operationPayloadTypeName}, error) { + func (op *{@lro.clientReturnTypeName}) Wait(ctx context.Context, opts ...gax.CallOption) (*{@lro.operationPayloadTypeName}, error) { var resp {@lro.operationPayloadTypeName} - ctx = insertXGoog(ctx, op.xGoogHeader) - if err := op.lro.Wait(ctx, &resp); err != nil { + if err := op.lro.Wait(ctx, &resp, opts...); err != nil { return nil, err } return &resp, nil @@ -392,10 +399,9 @@ // If Poll succeeds and the operation has completed successfully, // op.Done will return true, and the response of the operation is returned. // If Poll succeeds and the operation has not completed, the returned response and error are both nil. - func (op *{@lro.clientReturnTypeName}) Poll(ctx context.Context) (*{@lro.operationPayloadTypeName}, error) { + func (op *{@lro.clientReturnTypeName}) Poll(ctx context.Context, opts ...gax.CallOption) (*{@lro.operationPayloadTypeName}, error) { var resp {@lro.operationPayloadTypeName} - ctx = insertXGoog(ctx, op.xGoogHeader) - if err := op.lro.Poll(ctx, &resp); err != nil { + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { return nil, err } if !op.Done() { @@ -436,9 +442,8 @@ // Clients can use Poll or other methods to check whether the cancellation succeeded or whether the operation // completed despite cancellation. On successful cancellation, the operation is not deleted; // instead, op.Poll returns an error with code Canceled. - func (op *{@lro.clientReturnTypeName}) Cancel(ctx context.Context) error { - ctx = insertXGoog(ctx, op.xGoogHeader) - return op.lro.Cancel(ctx) + func (op *{@lro.clientReturnTypeName}) Cancel(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Cancel(ctx, opts...) } @end @@ -446,9 +451,8 @@ // Delete deletes a long-running operation. // This method indicates that the client is no longer interested in the operation result. // It does not cancel the operation. - func (op *{@lro.clientReturnTypeName}) Delete(ctx context.Context) error { - ctx = insertXGoog(ctx, op.xGoogHeader) - return op.lro.Delete(ctx) + func (op *{@lro.clientReturnTypeName}) Delete(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Delete(ctx, opts...) } @end @end diff --git a/src/main/resources/com/google/api/codegen/go/mock.snip b/src/main/resources/com/google/api/codegen/go/mock.snip index 9910fd6a62..bfa9007d56 100644 --- a/src/main/resources/com/google/api/codegen/go/mock.snip +++ b/src/main/resources/com/google/api/codegen/go/mock.snip @@ -12,10 +12,12 @@ import ( "flag" + "fmt" "io" "log" "net" "os" + "strings" "testing" "github.com/golang/protobuf/proto" @@ -25,6 +27,7 @@ status "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/grpc" "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" ) var _ = io.EOF @@ -104,7 +107,11 @@ @end @private simpleMethod(impl, method) - func (s *{@impl.name}) {@method.name}(_ context.Context, req {@method.requestTypeName}) ({@method.responseTypeName}, error) { + func (s *{@impl.name}) {@method.name}(ctx context.Context, req {@method.requestTypeName}) ({@method.responseTypeName}, error) { + md, _ := metadata.FromIncomingContext(ctx) + if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { + return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) + } s.reqs = append(s.reqs, req) if s.err != nil { return nil, s.err @@ -113,8 +120,16 @@ } @end +@private streamAssertXGoog() + md, _ := metadata.FromIncomingContext(stream.Context()) + if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { + return fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) + } +@end + @private serverStreamMethod(impl, method) func (s *{@impl.name}) {@method.name}(req {@method.requestTypeName}, stream {@method.streamHandleTypeName}) error { + {@streamAssertXGoog()} s.reqs = append(s.reqs, req) if s.err != nil { return s.err @@ -130,6 +145,7 @@ @private clientStreamMethod(impl, method) func (s *{@impl.name}) {@method.name}(stream {@method.streamHandleTypeName}) error { + {@streamAssertXGoog()} for { if req, err := stream.Recv(); err == io.EOF { break @@ -148,6 +164,7 @@ @private bidiMethod(impl, method) func (s *{@impl.name}) {@method.name}(stream {@method.streamHandleTypeName}) error { + {@streamAssertXGoog()} for { if req, err := stream.Recv(); err == io.EOF { break diff --git a/src/main/resources/com/google/api/codegen/go/sample.snip b/src/main/resources/com/google/api/codegen/go/sample.snip index bd3bed72c4..3c1f84a6e5 100644 --- a/src/main/resources/com/google/api/codegen/go/sample.snip +++ b/src/main/resources/com/google/api/codegen/go/sample.snip @@ -46,12 +46,15 @@ {@class.clientVarName} := &http.Client{} @case "APPLICATION_DEFAULT_CREDENTIALS" {@class.clientVarName}, err := google.DefaultClient({@class.contextVarName}, {@class.servicePackageName}.CloudPlatformScope) + if err != nil { + log.Fatal(err) + } @default {@class.clientVarName}, err := {@class.getClientFuncName}({@class.contextVarName}) + if err != nil { + log.Fatal(err) + } @end - if err != nil { - log.Fatal(err) - } {@class.serviceVarName}, err := {@class.servicePackageName}.New({@class.clientVarName}) if err != nil { diff --git a/src/main/resources/com/google/api/codegen/go/smoke.snip b/src/main/resources/com/google/api/codegen/go/smoke.snip index 57c72295ed..db368b013a 100644 --- a/src/main/resources/com/google/api/codegen/go/smoke.snip +++ b/src/main/resources/com/google/api/codegen/go/smoke.snip @@ -11,7 +11,9 @@ ) import ( + "strconv" "testing" + "time" "cloud.google.com/go/internal/testutil" "golang.org/x/net/context" @@ -20,6 +22,8 @@ ) var _ = iterator.Done + var _ = strconv.FormatUint + var _ = time.Now func {@view.name}(t *testing.T) { if testing.Short() { @@ -32,8 +36,7 @@ } projectId := testutil.ProjID() - uidSpace := testutil.NewUIDSpace("{@view.name}") - _, _ = projectId, uidSpace + _ = projectId c, err := {@view.method.serviceConstructorName}(ctx, option.WithTokenSource(ts)) if err != nil { diff --git a/src/main/resources/com/google/api/codegen/java/main.snip b/src/main/resources/com/google/api/codegen/java/main.snip index 475baefd4f..5c53687a64 100644 --- a/src/main/resources/com/google/api/codegen/java/main.snip +++ b/src/main/resources/com/google/api/codegen/java/main.snip @@ -103,12 +103,10 @@ * *
    * 
-   * InstantiatingChannelProvider channelProvider =
-   *     {@xapiClassDoc.settingsClassName}.defaultChannelProviderBuilder()
+   * {@xapiClassDoc.settingsClassName} {@xapiClassDoc.settingsVarName} =
+   *     {@xapiClassDoc.settingsClassName}.defaultBuilder()
    *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
    *         .build();
-   * {@xapiClassDoc.settingsClassName} {@xapiClassDoc.settingsVarName} =
-   *     {@xapiClassDoc.settingsClassName}.defaultBuilder().setChannelProvider(channelProvider).build();
    * {@xapiClassDoc.apiClassName} {@xapiClassDoc.apiVarName} =
    *     {@xapiClassDoc.apiClassName}.create({@xapiClassDoc.settingsVarName});
    * 
@@ -173,8 +171,6 @@
 
 @private members(xapiClass)
   private final {@xapiClass.settingsClassName} settings;
-  private final ScheduledExecutorService executor;
-  private final ManagedChannel channel;
   @if xapiClass.hasLongRunningOperations
     private final OperationsClient operationsClient;
   @end
@@ -218,9 +214,8 @@
    */
   protected {@xapiClass.name}({@xapiClass.settingsClassName} settings) throws IOException {
     this.settings = settings;
-    ChannelAndExecutor channelAndExecutor = settings.getChannelAndExecutor();
-    this.executor = channelAndExecutor.getExecutor();
-    this.channel = channelAndExecutor.getChannel();
+
+    ClientContext clientContext = ClientContext.create(settings);
 
     @if xapiClass.hasLongRunningOperations
       FixedExecutorProvider executorProvider = FixedExecutorProvider.create(this.executor);
@@ -229,6 +224,7 @@
           OperationsSettings.defaultBuilder()
               .setExecutorProvider(executorProvider)
               .setChannelProvider(channelProvider)
+              .setCredentialsProvider(credentialsProvider)
               .build();
       this.operationsClient = OperationsClient.create(operationsSettings);
     @end
@@ -236,42 +232,25 @@
     @join apiCallable : xapiClass.apiCallableMembers
       @switch apiCallable.type
       @case "SimpleApiCallable"
-        this.{@apiCallable.name} = UnaryCallable.create(settings.{@apiCallable.settingsFunctionName}(), this.channel, this.executor);
+        this.{@apiCallable.name} = UnaryCallable.create(settings.{@apiCallable.settingsFunctionName}(), clientContext);
       @case "PagedApiCallable"
         this.{@apiCallable.name} =
-            UnaryCallable.createPagedVariant(settings.{@apiCallable.settingsFunctionName}(), this.channel, this.executor);
+            UnaryCallable.createPagedVariant(settings.{@apiCallable.settingsFunctionName}(), clientContext);
       @case "BatchingApiCallable"
-        this.{@apiCallable.name} = UnaryCallable.create(settings.{@apiCallable.settingsFunctionName}(), this.channel, this.executor);
+        this.{@apiCallable.name} = UnaryCallable.create(settings.{@apiCallable.settingsFunctionName}(), clientContext);
       @case "StreamingApiCallable"
         this.{@apiCallable.name} = StreamingCallable.create(settings.{@apiCallable.settingsFunctionName}(), this.channel);
       @case "InitialOperationApiCallable"
-        this.{@apiCallable.name} = UnaryCallable.create(settings.{@apiCallable.settingsFunctionName}().getInitialCallSettings(), this.channel, this.executor);
+        this.{@apiCallable.name} = UnaryCallable.create(settings.{@apiCallable.settingsFunctionName}().getInitialCallSettings(), clientContext);
       @case "OperationApiCallable"
         this.{@apiCallable.name} = OperationCallable.create(settings.{@apiCallable.settingsFunctionName}(),\
-            this.channel, this.executor, this.operationsClient);
+            clientContext, this.operationsClient);
       @default
         $unhandledCase: {@apiCallable.type}$
       @end
     @end
 
-    if (settings.getChannelProvider().shouldAutoClose()) {
-      closeables.add(
-        new Closeable() {
-          @@Override
-          public void close() throws IOException {
-            channel.shutdown();
-          }
-        });
-    }
-    if (settings.getExecutorProvider().shouldAutoClose()) {
-      closeables.add(
-        new Closeable() {
-          @@Override
-          public void close() throws IOException {
-            executor.shutdown();
-          }
-        });
-    }
+    closeables.addAll(clientContext.getCloseables());
   }
   {@""}
 @end
diff --git a/src/main/resources/com/google/api/codegen/java/settings.snip b/src/main/resources/com/google/api/codegen/java/settings.snip
index f20dbdc3ea..d5684f5255 100644
--- a/src/main/resources/com/google/api/codegen/java/settings.snip
+++ b/src/main/resources/com/google/api/codegen/java/settings.snip
@@ -152,8 +152,7 @@
         @if xsettingsClass.hasDefaultServiceAddress
             .setEndpoint(getDefaultEndpoint())
         @end
-        .setGeneratorHeader(DEFAULT_GAPIC_NAME, getGapicVersion())
-        .setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+        .setGeneratorHeader(DEFAULT_GAPIC_NAME, getGapicVersion());
   }
 
   private static String getGapicVersion() {
@@ -256,7 +255,8 @@
 @private constructors(xsettingsClass)
   private {@xsettingsClass.name}(Builder settingsBuilder) throws IOException {
     super(settingsBuilder.getExecutorProvider(),
-          settingsBuilder.getChannelProvider());
+          settingsBuilder.getChannelProvider(),
+          settingsBuilder.getCredentialsProvider());
 
     @join settings : xsettingsClass.callSettings
       {@settings.memberName} = settingsBuilder.{@settings.settingsGetFunction}().build();
@@ -508,6 +508,7 @@
   private Builder() {
     @if xsettingsClass.hasDefaultInstance
       super(defaultChannelProviderBuilder().build());
+      setCredentialsProvider(defaultCredentialsProviderBuilder().build());
     @else
       super((InstantiatingChannelProvider) null);
     @end
@@ -612,6 +613,12 @@
     return this;
   }
 
+  @@Override
+  public Builder setCredentialsProvider(CredentialsProvider credentialsProvider) {
+    super.setCredentialsProvider(credentialsProvider);
+    return this;
+  }
+
   /**
    * Applies the given settings to all of the unary API methods in this service. Only
    * values that are non-null will be applied, so this method is not capable
diff --git a/src/main/resources/com/google/api/codegen/metadatagen/java/grpc/package.snip b/src/main/resources/com/google/api/codegen/metadatagen/java/grpc/build.gradle.snip
similarity index 95%
rename from src/main/resources/com/google/api/codegen/metadatagen/java/grpc/package.snip
rename to src/main/resources/com/google/api/codegen/metadatagen/java/grpc/build.gradle.snip
index 8a9967f28c..861f0960a1 100644
--- a/src/main/resources/com/google/api/codegen/metadatagen/java/grpc/package.snip
+++ b/src/main/resources/com/google/api/codegen/metadatagen/java/grpc/build.gradle.snip
@@ -105,7 +105,7 @@
     tasks.uploadArchives.dependsOn(failUploadArchives)
   }
 
-  task checkOutGhPages {
+  task checkOutGhPages << {
     if (!new File('tmp_gh-pages').exists()) {
       exec {
         commandLine 'git', 'clone', '--branch', 'gh-pages',
@@ -152,6 +152,7 @@
   task updateDocsWithCurrentVersion {
     dependsOn 'createApiDocsRedirect'
   }
+
 @end
 
 @private dependencies(metadata)
@@ -161,12 +162,12 @@
       compile "com.google.protobuf:protobuf-java:{@metadata.protoVersionBound.lower}"
       compile "com.google.api:api-common:{@metadata.apiCommonVersionBound.lower}"
       @join dependency : metadata.protoPackageDependencies
-        compile "com.google.api.grpc:{@dependency.name}:{@dependency.versionBound.lower}"
+        compile project(":{@dependency.name}")
       @end
     @case "GRPC"
       compile "io.grpc:grpc-stub:{@metadata.grpcVersionBound.lower}"
       compile "io.grpc:grpc-protobuf:{@metadata.grpcVersionBound.lower}"
-      compile "com.google.api.grpc:{@metadata.protoPackageName}:{@metadata.packageVersionBound.lower}"
+      compile project(":{@metadata.protoPackageName}")
     @default
       $unhandledCase: {@metadata.generationLayer}$
     @end
diff --git a/src/main/resources/com/google/api/codegen/nodejs/README.md.snip b/src/main/resources/com/google/api/codegen/nodejs/README.md.snip
new file mode 100644
index 0000000000..0b55c1325d
--- /dev/null
+++ b/src/main/resources/com/google/api/codegen/nodejs/README.md.snip
@@ -0,0 +1,23 @@
+@extends "nodejs/method_sample.snip"
+@extends "readme.snip"
+
+@snippet generate(metadata)
+  {@readme(metadata, exampleMethods(metadata.exampleMethods, metadata), installationLines(metadata))}
+@end
+
+@private exampleMethods(methods, metadata)
+  @join method : methods on BREAK
+    @#### {@method.apiClassName}
+    ```js
+     var {@method.apiModuleName} = require('{@metadata.identifier}').{@metadata.majorVersion}({
+       // optional auth parameters.
+     });
+
+     {@decorateSampleCode(method, sampleCode(method))}
+    ```
+  @end
+@end
+
+@private installationLines(metadata)
+  $ npm install --save {@metadata.identifier}
+@end
diff --git a/src/main/resources/com/google/api/codegen/nodejs/common.snip b/src/main/resources/com/google/api/codegen/nodejs/common.snip
index 3e0ef8dc1b..a832c1706f 100644
--- a/src/main/resources/com/google/api/codegen/nodejs/common.snip
+++ b/src/main/resources/com/google/api/codegen/nodejs/common.snip
@@ -5,19 +5,3 @@
     * {@comment}
   @end
 @end
-
-@snippet copyright()
-  * Copyright 2016 Google Inc. All rights reserved.
-  *
-  * Licensed under the Apache License, Version 2.0 (the "License");
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-  *
-  * http://www.apache.org/licenses/LICENSE-2.0
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an "AS IS" BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-@end
diff --git a/src/main/resources/com/google/api/codegen/nodejs/index.snip b/src/main/resources/com/google/api/codegen/nodejs/index.snip
index ba09716a17..bd0c3425f9 100644
--- a/src/main/resources/com/google/api/codegen/nodejs/index.snip
+++ b/src/main/resources/com/google/api/codegen/nodejs/index.snip
@@ -2,7 +2,9 @@
 
 @snippet generate(index)
   /*
-   {@copyright()}
+   {@comments(index.fileHeader.copyrightLines)}
+   *
+   {@comments(index.fileHeader.licenseLines)}
    */
   'use strict';
 
@@ -44,5 +46,4 @@
   @end
 
   module.exports = {@index.apiVersion};
-
 @end
diff --git a/src/main/resources/com/google/api/codegen/nodejs/package.snip b/src/main/resources/com/google/api/codegen/nodejs/package.json.snip
similarity index 54%
rename from src/main/resources/com/google/api/codegen/nodejs/package.snip
rename to src/main/resources/com/google/api/codegen/nodejs/package.json.snip
index 87c99463be..2b38ffad42 100644
--- a/src/main/resources/com/google/api/codegen/nodejs/package.snip
+++ b/src/main/resources/com/google/api/codegen/nodejs/package.json.snip
@@ -1,13 +1,29 @@
 @snippet generate(metadata)
   {
-    "url": "{@metadata.homepage}",
+    "repository": "GoogleCloudPlatform/google-cloud-node",
     "name": "{@metadata.identifier}",
     "version": "{@metadata.packageVersionBound.lower}",
     "author": "{@metadata.author}",
     "description": "{@metadata.fullName} client for Node.js",
     "main": "src/index.js",
     "files": [
-      "src"
+      "src",
+      "AUTHORS",
+      "CONTRIBUTING",
+      "COPYING"
+    ],
+    "keywords": [
+      "google apis client",
+      "google api client",
+      "google apis",
+      "google api",
+      "google",
+      "google cloud platform",
+      "google cloud",
+      "cloud",
+      "google {@metadata.shortName}",
+      "{@metadata.shortName}",
+      "{@metadata.fullName}"
     ],
     "dependencies": {
       @join packageDep : metadata.protoPackageDependencies
@@ -20,15 +36,16 @@
       "extend": "^3.0.0"
     },
     "devDependencies": {
-      "mocha": "3.2.0",
-      "through2": "2.0.3"
+      "mocha": "^3.2.0",
+      "through2": "^2.0.3"
+    },
+    "scripts": {
+      "test": "mocha",
+      "publish-module": "node ../../scripts/publish.js {@metadata.shortName}"
     },
     "license": "{@metadata.licenseName}",
     "engines": {
-      "node": ">=0.12.0"
-    },
-    "scripts": {
-      "test": "mocha"
+      "node": ">=4.0.0"
     }
   }
 
diff --git a/src/main/resources/com/google/api/codegen/nodejs/sample.snip b/src/main/resources/com/google/api/codegen/nodejs/sample.snip
index 7635ec55d1..bb4be40e74 100644
--- a/src/main/resources/com/google/api/codegen/nodejs/sample.snip
+++ b/src/main/resources/com/google/api/codegen/nodejs/sample.snip
@@ -83,7 +83,7 @@
         // TODO: Add desired media content for upload. See
         // https://github.com/google/google-api-nodejs-client#media-uploads
         mimeType: '',  // See https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
-        body: {},
+        body: '',
       },
 
     @end
diff --git a/src/main/resources/com/google/api/codegen/nodejs/test.snip b/src/main/resources/com/google/api/codegen/nodejs/test.snip
index 28c5c4e11a..ee65b6e306 100644
--- a/src/main/resources/com/google/api/codegen/nodejs/test.snip
+++ b/src/main/resources/com/google/api/codegen/nodejs/test.snip
@@ -3,7 +3,9 @@
 
 @snippet generate(apiTest)
   /*
-   {@copyright()}
+   {@comments(apiTest.fileHeader.copyrightLines)}
+   *
+   {@comments(apiTest.fileHeader.licenseLines)}
    */
 
   {@header(apiTest)}
@@ -24,7 +26,7 @@
 @private header(apiTest)
   var assert = require('assert');
   @if apiTest.fileHeader.hasVersion
-    var {@apiTest.apiWrapperModuleName} = require('../src/').{@apiTest.fileHeader.version}();
+    var {@apiTest.apiWrapperModuleName} = require('../src/{@apiTest.fileHeader.version}')();
   @else
     var {@apiTest.apiWrapperModuleName} = require('../src/')();
   @end
diff --git a/src/main/resources/com/google/api/codegen/nodejs/version_index.snip b/src/main/resources/com/google/api/codegen/nodejs/version_index.snip
index d8dabec31f..0c88d8d51a 100644
--- a/src/main/resources/com/google/api/codegen/nodejs/version_index.snip
+++ b/src/main/resources/com/google/api/codegen/nodejs/version_index.snip
@@ -1,11 +1,88 @@
 @extends "nodejs/common.snip"
 
 @snippet generate(index)
+  {@header(index.fileHeader)}
+
+  {@imports(index)}
+
+  {@constants()}
+
+  {@clients(index)}
+
+  {@exports(index)}
+@end
+
+@private header(fileHeader)
   /*
-   {@copyright()}
+   {@comments(fileHeader.copyrightLines)}
+   *
+   {@comments(fileHeader.licenseLines)}
    */
   'use strict';
+@end
+
+@private imports(index)
+  var extend = require('extend');
+  var gapic = {
+    {@index.apiVersion}: require('./{@index.apiVersion}')
+  };
+@end
+
+@private constants()
+   const VERSION = require('../package.json').version;
+ @end
 
-  module.exports.{@index.apiVersion} = require('./{@index.apiVersion}');
+@private clients(index)
+  @join service : index.requireViews on BREAK.add(BREAK)
+    {@client(service, index.apiVersion)}
+  @end
+@end
+
+@private client(service, version)
+   /**
+    * Create an {@service.clientName} with additional helpers for common
+    * tasks.
+    *
+    {@comments(@service.doc.lines)}
+    *
+    * @@param {object=} options - [Configuration object](#/docs).
+    * @@param {number=} options.port - The port on which to connect to
+    *     the remote host.
+    * @@param {string=} options.servicePath - The domain name of the
+    *     API remote host.
+    */
+   function {@service.localName}(options) {
+     // Define the header options.
+     options = extend({}, options, {
+       libName: 'gccl',
+       libVersion: VERSION
+     });
+
+     // Create the image annotator client with the provided options.
+     var client = gapic.{@version}(options).{@service.clientName}(options);
+     return client;
+   }
+@end
+
+@private exports(index)
+  @if index.hasMultipleServices
+    {@multipleServicesExports(index.requireViews, index.apiVersion)}
+  @else
+    {@singleServiceExport(index.primaryService, index.apiVersion)}
+  @end
+@end
+
+@private multipleServicesExports(services, version)
+  @join service : services
+    module.exports.{@service.serviceName} = {@service.localName};
+  @end
+
+  @join service : services
+    module.exports.{@version}.{@service.serviceName} = {@service.localName};
+  @end
+@end
 
+@private singleServiceExport(service, version)
+  module.exports = {@service.localName};
+  module.exports.{@version} = {@service.localName};
 @end
diff --git a/src/main/resources/com/google/api/codegen/php/main.snip b/src/main/resources/com/google/api/codegen/php/main.snip
index 95f795442c..63d6587141 100644
--- a/src/main/resources/com/google/api/codegen/php/main.snip
+++ b/src/main/resources/com/google/api/codegen/php/main.snip
@@ -391,12 +391,10 @@
             if (array_key_exists('operationsClient', $options)) {
                 $this->operationsClient = $options['operationsClient'];
             } else {
-                $this->operationsClient = new OperationsClient([
-                    'serviceAddress' => $options['serviceAddress'],
-                    'scopes' => $options['scopes'],
-                    'libName' => $options['libName'],
-                    'libVersion' => $options['libVersion'],
-                ]);
+                $operationsClientOptions = $options;
+                unset($operationsClientOptions['timeoutMillis']);
+                unset($operationsClientOptions['retryingOverride']);
+                $this->operationsClient = new OperationsClient($operationsClientOptions);
             }
         @end
 
diff --git a/src/main/resources/com/google/api/codegen/php/test.snip b/src/main/resources/com/google/api/codegen/php/test.snip
index a918e4b01b..fed9dc2d4f 100644
--- a/src/main/resources/com/google/api/codegen/php/test.snip
+++ b/src/main/resources/com/google/api/codegen/php/test.snip
@@ -67,128 +67,220 @@
 @end
 
 @private nonStreamingOptionalArrayTestCase(test)
+    @switch test.clientMethodType
+    @case "OptionalArrayMethod"
+        {@simpleTestCase(test)}
+        {@simpleExceptionTestCase(test)}
+    @case "PagedOptionalArrayMethod"
+        {@pageStreamingTestCase(test)}
+        {@simpleExceptionTestCase(test)}
+    @case "OperationOptionalArrayMethod"
+        {@lroTestCase(test)}
+        {@lroExceptionTestCase(test)}
+    @default
+        $unhandled case: {@test.clientMethodType}$
+    @end
+@end
+
+@private simpleTestCase(test)
     /**
      * @@test
      */
     public function {@test.name}()
     {
-        @switch test.clientMethodType
-        @case "OptionalArrayMethod"
-            {@simpleTestCase(test)}
-        @case "PagedOptionalArrayMethod"
-            {@pageStreamingTestCase(test)}
-        @case "OperationOptionalArrayMethod"
-            {@lroTestCase(test)}
-        @default
-            $unhandled case: {@test.clientMethodType}$
+        {@singleCallTestSetup(test)}
+        @if test.hasReturnValue
+            $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)});
+            $this->assertEquals($expectedResponse, $response);
+        @else
+            $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)});
         @end
+        {@singleCallSuccessAsserts(test)}
+
+        $this->assertTrue($grpcStub->isExhausted());
     }
 @end
 
-@private simpleTestCase(test)
-    {@singleCallTestSetup(test)}
-    @if test.hasReturnValue
+@private pageStreamingTestCase(test)
+    /**
+     * @@test
+     */
+    public function {@test.name}()
+    {
+        {@singleCallTestSetup(test)}
         $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)});
-        $this->assertEquals($expectedResponse, $response);
-    @else
-        $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)});
-    @end
-    {@singleCallSuccessAsserts(test)}
+        $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
+        @join pageStreamingResponseView : test.pageStreamingResponseViews
+            ${@pageStreamingResponseView.resourcesVarName} = iterator_to_array($response->{@pageStreamingResponseView.resourcesIterateMethod}());
+            $this->assertSame(1, count(${@pageStreamingResponseView.resourcesVarName}));
+            $this->assertEquals($expectedResponse->{@pageStreamingResponseView.resourcesFieldGetterName}()[0], ${@pageStreamingResponseView.resourcesVarName}[0]);
+        @end
 
-    $this->assertTrue($grpcStub->isExhausted());
+        {@singleCallSuccessAsserts(test)}
+        $this->assertTrue($grpcStub->isExhausted());
+    }
 @end
 
-@private pageStreamingTestCase(test)
-    {@singleCallTestSetup(test)}
-    $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)});
-    $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject());
-    @join pageStreamingResponseView : test.pageStreamingResponseViews
-        ${@pageStreamingResponseView.resourcesVarName} = iterator_to_array($response->{@pageStreamingResponseView.resourcesIterateMethod}());
-        $this->assertSame(1, count(${@pageStreamingResponseView.resourcesVarName}));
-        $this->assertEquals($expectedResponse->{@pageStreamingResponseView.resourcesFieldGetterName}()[0], ${@pageStreamingResponseView.resourcesVarName}[0]);
-    @end
+@private simpleExceptionTestCase(test)
 
-    {@singleCallSuccessAsserts(test)}
-    $this->assertTrue($grpcStub->isExhausted());
-@end
+    /**
+     * @@test
+     */
+    public function {@test.nameWithException}()
+    {
+        $grpcStub = $this->createStub([$this, 'create{@test.mockGrpcStubTypeName}']);
+        $client = $this->createClient('{@test.createStubFunctionName}', $grpcStub);
 
-@private lroTestCase(test)
-    $operationsStub = $this->createStub([$this, 'createMockOperationsStub']);
-    $operationsClient = new OperationsClient([
-        'serviceAddress' => '',
-        'scopes' => [],
-        'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) {
-            return $operationsStub;
-        }
-    ]);
-    $grpcStub = $this->createStub([$this, 'create{@test.mockGrpcStubTypeName}']);
-    $client = $this->createClient('{@test.createStubFunctionName}', $grpcStub, [
-        'operationsClient' => $operationsClient
-    ]);
+        $this->assertTrue($grpcStub->isExhausted());
 
-    $this->assertTrue($grpcStub->isExhausted());
-    $this->assertTrue($operationsStub->isExhausted());
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
 
-    // Mock response
-    $incompleteOperation = new Operation();
-    $incompleteOperation->setName('operations/{@test.name}')->setDone(false);
-    $grpcStub->addResponse($incompleteOperation);
-    @if test.hasReturnValue
-        {@initCode(test.mockResponse.initCode)}
-    @else
-        $expectedResponse = new EmptyC();
-    @end
-    $anyResponse = new Any();
-    $anyResponse->setValue($expectedResponse->serialize());
-    $completeOperation = new Operation();
-    $completeOperation->setName('operations/{@test.name}')->setDone(true)->setResponse($anyResponse);
-    $operationsStub->addResponse($completeOperation);
+        @if test.hasRequestParameters
+          // Mock request
+          {@initCode(test.initCode)}
 
-    @if test.hasRequestParameters
-      // Mock request
-      {@initCode(test.initCode)}
+        @end
+        try {
+            $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)});
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
 
-    @end
-    $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)});
-    $this->assertFalse($response->isDone());
-    $this->assertNull($response->getResult());
-    $apiRequests = $grpcStub->getReceivedCalls();
-    $this->assertSame(1, count($apiRequests));
-    $operationsRequestsEmpty = $operationsStub->getReceivedCalls();
-    $this->assertSame(0, count($operationsRequestsEmpty));
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+@end
 
-    $actualApiFuncCall = $apiRequests[0]->getFuncCall();
-    $actualApiRequestObject = $apiRequests[0]->getRequestObject();
-    $this->assertSame('{@test.grpcStubCallString}', $actualApiFuncCall);
-    @join assert : test.asserts
-        @if assert.hasExpectedValueTransformFunction
-            $this->assertEquals({@assert.expectedValueTransformFunction}(\
-                ${@assert.expectedValueIdentifier}), \
-                $actualApiRequestObject->{@assert.actualValueGetter}());
+@private lroTestCase(test)
+    /**
+     * @@test
+     */
+    public function {@test.name}()
+    {
+        $operationsStub = $this->createStub([$this, 'createMockOperationsStub']);
+        $operationsClient = new OperationsClient([
+            'serviceAddress' => '',
+            'scopes' => [],
+            'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) {
+                return $operationsStub;
+            }
+        ]);
+        $grpcStub = $this->createStub([$this, 'create{@test.mockGrpcStubTypeName}']);
+        $client = $this->createClient('{@test.createStubFunctionName}', $grpcStub, [
+            'operationsClient' => $operationsClient
+        ]);
+
+        $this->assertTrue($grpcStub->isExhausted());
+        $this->assertTrue($operationsStub->isExhausted());
+
+        // Mock response
+        $incompleteOperation = new Operation();
+        $incompleteOperation->setName('operations/{@test.name}')->setDone(false);
+        $grpcStub->addResponse($incompleteOperation);
+        @if test.hasReturnValue
+            {@initCode(test.mockResponse.initCode)}
         @else
-            $this->assertEquals(${@assert.expectedValueIdentifier}, \
-                $actualApiRequestObject->{@assert.actualValueGetter}());
+            $expectedResponse = new EmptyC();
         @end
-    @end
+        $anyResponse = new Any();
+        $anyResponse->setValue($expectedResponse->serialize());
+        $completeOperation = new Operation();
+        $completeOperation->setName('operations/{@test.name}')->setDone(true)->setResponse($anyResponse);
+        $operationsStub->addResponse($completeOperation);
 
-    $expectedOperationsRequestObject = new GetOperationRequest();
-    $expectedOperationsRequestObject->setName('operations/{@test.name}');
+        @if test.hasRequestParameters
+          // Mock request
+          {@initCode(test.initCode)}
 
-    $response->pollUntilComplete();
-    $this->assertTrue($response->isDone());
-    $this->assertEquals($expectedResponse, $response->getResult());
-    $apiRequestsEmpty = $grpcStub->getReceivedCalls();
-    $this->assertSame(0, count($apiRequestsEmpty));
-    $operationsRequests = $operationsStub->getReceivedCalls();
-    $this->assertSame(1, count($operationsRequests));
+        @end
+        $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)});
+        $this->assertFalse($response->isDone());
+        $this->assertNull($response->getResult());
+        {@lroCallSuccessAsserts(test)}
 
-    $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall();
-    $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject();
-    $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall);
-    $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject);
+        $expectedOperationsRequestObject = new GetOperationRequest();
+        $expectedOperationsRequestObject->setName('operations/{@test.name}');
 
-    $this->assertTrue($grpcStub->isExhausted());
-    $this->assertTrue($operationsStub->isExhausted());
+        $response->pollUntilComplete();
+        $this->assertTrue($response->isDone());
+        $this->assertEquals($expectedResponse, $response->getResult());
+        $apiRequestsEmpty = $grpcStub->getReceivedCalls();
+        $this->assertSame(0, count($apiRequestsEmpty));
+        $operationsRequests = $operationsStub->getReceivedCalls();
+        $this->assertSame(1, count($operationsRequests));
+
+        $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall();
+        $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject();
+        $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall);
+        $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject);
+
+        $this->assertTrue($grpcStub->isExhausted());
+        $this->assertTrue($operationsStub->isExhausted());
+    }
+@end
+
+@private lroExceptionTestCase(test)
+
+    /**
+     * @@test
+     */
+    public function {@test.nameWithException}()
+    {
+        $operationsStub = $this->createStub([$this, 'createMockOperationsStub']);
+        $operationsClient = new OperationsClient([
+            'serviceAddress' => '',
+            'scopes' => [],
+            'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) {
+                return $operationsStub;
+            }
+        ]);
+        $grpcStub = $this->createStub([$this, 'create{@test.mockGrpcStubTypeName}']);
+        $client = $this->createClient('{@test.createStubFunctionName}', $grpcStub, [
+            'operationsClient' => $operationsClient
+        ]);
+
+        $this->assertTrue($grpcStub->isExhausted());
+        $this->assertTrue($operationsStub->isExhausted());
+
+        // Mock response
+        $incompleteOperation = new Operation();
+        $incompleteOperation->setName('operations/{@test.name}')->setDone(false);
+        $grpcStub->addResponse($incompleteOperation);
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $operationsStub->addResponse(null, $status);
+
+        @if test.hasRequestParameters
+          // Mock request
+          {@initCode(test.initCode)}
+
+        @end
+        $response = $client->{@test.clientMethodName}({@sampleMethodCallArgList(test.initCode.fieldSettings)});
+        $this->assertFalse($response->isDone());
+        $this->assertNull($response->getResult());
+
+        $expectedOperationsRequestObject = new GetOperationRequest();
+        $expectedOperationsRequestObject->setName('operations/{@test.name}');
+
+        try {
+            $response->pollUntilComplete();
+            // If the pollUntilComplete() method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+        $this->assertTrue($operationsStub->isExhausted());
+    }
 @end
 
 @private singleCallTestSetup(test)
@@ -197,15 +289,14 @@
 
     $this->assertTrue($grpcStub->isExhausted());
 
+    // Mock response
     @if test.hasReturnValue
-        // Mock response
         {@initCode(test.mockResponse.initCode)}
-        $grpcStub->addResponse($expectedResponse);
-
     @else
-        // Add empty response to the grpc stub
-        $grpcStub->addResponse(new EmptyC());
+        $expectedResponse = new EmptyC();
     @end
+    $grpcStub->addResponse($expectedResponse);
+
     @if test.hasRequestParameters
       // Mock request
       {@initCode(test.initCode)}
@@ -231,3 +322,24 @@
         @end
     @end
 @end
+
+@private lroCallSuccessAsserts(test)
+    $apiRequests = $grpcStub->getReceivedCalls();
+    $this->assertSame(1, count($apiRequests));
+    $operationsRequestsEmpty = $operationsStub->getReceivedCalls();
+    $this->assertSame(0, count($operationsRequestsEmpty));
+
+    $actualApiFuncCall = $apiRequests[0]->getFuncCall();
+    $actualApiRequestObject = $apiRequests[0]->getRequestObject();
+    $this->assertSame('{@test.grpcStubCallString}', $actualApiFuncCall);
+    @join assert : test.asserts
+        @if assert.hasExpectedValueTransformFunction
+            $this->assertEquals({@assert.expectedValueTransformFunction}(\
+                ${@assert.expectedValueIdentifier}), \
+                $actualApiRequestObject->{@assert.actualValueGetter}());
+        @else
+            $this->assertEquals(${@assert.expectedValueIdentifier}, \
+                $actualApiRequestObject->{@assert.actualValueGetter}());
+        @end
+    @end
+@end
diff --git a/src/main/resources/com/google/api/codegen/py/README.rst.snip b/src/main/resources/com/google/api/codegen/py/README.rst.snip
index efdbc48a35..145e0b12a2 100644
--- a/src/main/resources/com/google/api/codegen/py/README.rst.snip
+++ b/src/main/resources/com/google/api/codegen/py/README.rst.snip
@@ -1,81 +1,51 @@
-@snippet generate(metadata)
-  GAPIC library for the {@metadata.fullName}
-  ================================================================================
-
-  {@metadata.gapicPackageName} uses google-gax_ (Google API extensions) to provide an
-  easy-to-use client library for the `{@metadata.fullName}`_ ({@metadata.majorVersion}) defined in the googleapis_ git repository
-
-
-  .. _`googleapis`: https://github.com/googleapis/googleapis/tree/master/{@metadata.protoPath}
-  .. _`google-gax`: https://github.com/googleapis/gax-python
-  .. _`{@metadata.fullName}`: https://developers.google.com/apis-explorer/?hl=en_US#p/{@metadata.discoveryApiName}/{@metadata.majorVersion}/
-
-  Getting started
-  ---------------
-
-  {@metadata.gapicPackageName} will allow you to connect to the
-  {@metadata.fullName} and access all its methods. In order to do this, you need
-  to set up authentication as well as install the library locally.
-
-
-  Setup Authentication
-  ~~~~~~~~~~~~~~~~~~~~
-
-  To authenticate all your API calls, first install and setup the `Google Cloud SDK`_.
-  Once done, you can then run the following command in your terminal:
-
-  .. code-block:: console
+@extends "readme_rst.snip"
+@extends "py/method_sample.snip"
 
-      $ gcloud beta auth application-default login
-
-  or
-
-  .. code-block:: console
-
-      $ gcloud auth login
-
-  Please see `gcloud beta auth application-default login`_ document for the difference between these commands.
-
-  .. _Google Cloud SDK: https://cloud.google.com/sdk/
-  .. _gcloud beta auth application-default login: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login
-
-
-  Installation
-  ~~~~~~~~~~~~
+@snippet generate(metadata)
+  {@readme(metadata, exampleMethods(metadata.exampleMethods), installationLines(metadata))}
+@end
 
-  Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
-  create isolated Python environments. The basic problem it addresses is one of
-  dependencies and versions, and indirectly permissions.
+@private exampleMethods(methods)
+  @join method : methods on BREAK
+    {@method.apiClassName}
+    ^^^^^^^^^^^^^^^^^^^^^^
 
-  With `virtualenv`_, it's possible to install this library without needing system
-  install permissions, and without clashing with the installed system
-  dependencies.
+    .. code:: py
 
-  .. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
+      {@sampleCode_(method)}
+  @end
+@end
 
+@private installationLines(metadata)
+    Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
+    create isolated Python environments. The basic problem it addresses is one of
+    dependencies and versions, and indirectly permissions.
 
-  Mac/Linux
-  ~~~~~~~~~~
+    With `virtualenv`_, it's possible to install this library without needing system
+    install permissions, and without clashing with the installed system
+    dependencies.
 
-  .. code-block:: console
+    .. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
 
-      pip install virtualenv
-      virtualenv 
-      source /bin/activate
-      /bin/pip install {@metadata.gapicPackageName}
 
+    Mac/Linux
+    ^^^^^^^^^
 
-  Windows
-  ~~~~~~~
+    .. code-block:: console
 
-  .. code-block:: console
+        pip install virtualenv
+        virtualenv 
+        source /bin/activate
+        /bin/pip install {@metadata.gapicPackageName}
 
-      pip install virtualenv
-      virtualenv 
-      \Scripts\activate
-      \Scripts\pip.exe install {@metadata.gapicPackageName}
 
+    Windows
+    ^^^^^^^
 
-  At this point you are all set to continue.
+    .. code-block:: console
 
+        pip install virtualenv
+        virtualenv 
+        \Scripts\activate
+        \Scripts\pip.exe install {@metadata.gapicPackageName}
 @end
diff --git a/src/main/resources/com/google/api/codegen/py/method_sample.snip b/src/main/resources/com/google/api/codegen/py/method_sample.snip
index 92725f466b..9bfcc26455 100644
--- a/src/main/resources/com/google/api/codegen/py/method_sample.snip
+++ b/src/main/resources/com/google/api/codegen/py/method_sample.snip
@@ -8,7 +8,7 @@
   @end
 @end
 
-@private sampleCode_(apiMethod)
+@snippet sampleCode_(apiMethod)
   {@importList(apiMethod.initCode.importSection.appImports)}
   client = {@apiMethod.apiVariableName}.{@apiMethod.apiClassName}()
   @if apiMethod.initCode.lines
diff --git a/src/main/resources/com/google/api/codegen/py/sample.snip b/src/main/resources/com/google/api/codegen/py/sample.snip
index bf52ff6818..5957449389 100644
--- a/src/main/resources/com/google/api/codegen/py/sample.snip
+++ b/src/main/resources/com/google/api/codegen/py/sample.snip
@@ -24,6 +24,9 @@
         from pprint import pprint
     @end
 
+    @if class.auth.type == "NONE"
+        import httplib2
+    @end
     from googleapiclient import discovery
     @if class.auth.type == "APPLICATION_DEFAULT_CREDENTIALS"
         from oauth2client.client import GoogleCredentials
diff --git a/src/main/resources/com/google/api/codegen/readme.snip b/src/main/resources/com/google/api/codegen/readme.snip
new file mode 100644
index 0000000000..2b0b718ec2
--- /dev/null
+++ b/src/main/resources/com/google/api/codegen/readme.snip
@@ -0,0 +1,53 @@
+@snippet readme(metadata, samples, installationLines)
+  {@title(metadata)}
+
+  {@quickStart(metadata, samples, installationLines)}
+
+  {@commonLinkDeclarations(metadata)}
+@end
+
+@private title(metadata)
+    @# {@metadata.targetLanguage} Client{@plurality(metadata.hasMultipleServices)} for \
+    {@metadata.fullName} ([{@metadata.developmentStatusTitle}]({@metadata.versioningDocumentationLink}))
+
+    [{@metadata.fullName}][Product Documentation]: {@metadata.apiSummary}
+  - [Client Library Documentation][]
+  - [Product Documentation][]
+@end
+
+@private plurality(isPlural)
+  @if isPlural
+    s
+  @end
+@end
+
+@private quickStart(metadata, samples, installationLines)
+  @## Quick Start
+  In order to use this library, you first need to go through the following steps:
+
+  1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
+  2. [Enable the {@metadata.fullName}.](https://console.cloud.google.com/apis/api/{@metadata.shortName})
+  3. [Setup Authentication.]({@metadata.authDocumentationLink})
+
+  @if installationLines
+    @### Installation
+    ```
+    {@installationLines}
+    ```
+
+  @end
+  @if samples
+    @### Preview
+    {@samples}
+
+  @end
+  @### Next Steps
+  - Read the [Client Library Documentation][] for {@metadata.fullName} to see other available methods on the client.
+  - Read the [{@metadata.fullName} Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
+  - View this [repository's main README]({@metadata.mainReadmeLink}) to see the full list of Cloud APIs that we cover.
+@end
+
+@private commonLinkDeclarations(metadata)
+  [Client Library Documentation]: {@metadata.libraryDocumentationLink}
+  [Product Documentation]: https://cloud.google.com/{@metadata.shortName}
+@end
diff --git a/src/main/resources/com/google/api/codegen/readme_rst.snip b/src/main/resources/com/google/api/codegen/readme_rst.snip
new file mode 100644
index 0000000000..7ca2ab8fdd
--- /dev/null
+++ b/src/main/resources/com/google/api/codegen/readme_rst.snip
@@ -0,0 +1,72 @@
+@snippet readme(metadata, samples, installationLines)
+  {@title(metadata)}
+
+  {@quickStart(metadata, samples, installationLines)}
+@end
+
+@private title(metadata)
+  {@metadata.targetLanguage} Client{@plurality(metadata.hasMultipleServices)} for {@metadata.fullName} (`{@metadata.developmentStatusTitle}`_)
+  ==================================================================================================
+
+  `{@metadata.fullName}`_: {@metadata.apiSummary}
+
+  - `Client Library Documentation`_
+  - `Product Documentation`_
+
+  .. _{@metadata.developmentStatusTitle}: {@metadata.versioningDocumentationLink}
+  .. _{@metadata.fullName}: {@productDocumentation(metadata)}
+  .. _Client Library Documentation: {@metadata.libraryDocumentationLink}
+  .. _Product Documentation:  {@productDocumentation(metadata)}
+@end
+
+@private plurality(isPlural)
+  @if isPlural
+    s
+  @end
+@end
+
+@private quickStart(metadata, samples, installationLines)
+  Quick Start
+  -----------
+
+  In order to use this library, you first need to go through the following steps:
+
+  1. `Select or create a Cloud Platform project.`_
+  2. `Enable the {@metadata.fullName}.`_
+  3. `Setup Authentication.`_
+
+  .. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
+  .. _Enable the {@metadata.fullName}.:  {@productDocumentation(metadata)}
+  .. _Setup Authentication.: {@metadata.authDocumentationLink}
+
+  @if installationLines
+    Installation
+    ~~~~~~~~~~~~
+
+    {@installationLines}
+
+  @end
+  @if samples
+    Preview
+    ~~~~~~~
+
+    {@samples}
+
+  @end
+  Next Steps
+  ~~~~~~~~~~
+
+  -  Read the `Client Library Documentation`_ for {@metadata.fullName}
+     API to see other available methods on the client.
+  -  Read the `{@metadata.fullName} Product documentation`_ to learn
+     more about the product and see How-to Guides.
+  -  View this `repository’s main README`_ to see the full list of Cloud
+     APIs that we cover.
+
+  .. _{@metadata.fullName} Product documentation:  {@productDocumentation(metadata)}
+  .. _repository’s main README: {@metadata.mainReadmeLink}
+@end
+
+@private productDocumentation(metadata)
+  https://cloud.google.com/{@metadata.shortName}
+@end
\ No newline at end of file
diff --git a/src/main/resources/com/google/api/codegen/ruby/Gemfile.snip b/src/main/resources/com/google/api/codegen/ruby/Gemfile.snip
index 65f58d3b90..ae773ad40d 100644
--- a/src/main/resources/com/google/api/codegen/ruby/Gemfile.snip
+++ b/src/main/resources/com/google/api/codegen/ruby/Gemfile.snip
@@ -3,4 +3,12 @@
 
   gemspec
 
+  gem "rake", "~> 11.0"
+  gem "gcloud-jsondoc",
+      git: "https://github.com/GoogleCloudPlatform/google-cloud-ruby.git",
+      branch: "gcloud-jsondoc"
+
+  @# TEMP: rainbow (a dependency of rubocop) version 2.2 seems to have a problem,
+  @# so pinning to 2.1 for now.
+  gem "rainbow", "~> 2.1.0"
 @end
diff --git a/src/main/resources/com/google/api/codegen/ruby/README.md.snip b/src/main/resources/com/google/api/codegen/ruby/README.md.snip
index cf8479b231..f9ee0d829f 100644
--- a/src/main/resources/com/google/api/codegen/ruby/README.md.snip
+++ b/src/main/resources/com/google/api/codegen/ruby/README.md.snip
@@ -1,47 +1,19 @@
-@snippet generate(metadata)
-  {@metadata.fullName} for Ruby
-  =================================================
-
-  {@metadata.fullName} uses [Google API extensions][google-gax] to provide an
-  easy-to-use client library for the [{@metadata.fullName}][] ({@metadata.majorVersion}) defined in the [googleapis][] git repository
-
-
-  [googleapis]: https://github.com/googleapis/googleapis/tree/master/{@metadata.protoPath}
-  [google-gax]: https://github.com/googleapis/gax-ruby
-  [{@metadata.fullName}]: https://developers.google.com/apis-explorer/?hl=en_US#p/{@metadata.discoveryApiName}/{@metadata.majorVersion}/
-
-  Getting started
-  ---------------
-
-  {@metadata.identifier} will allow you to connect to the [{@metadata.fullName}][] and access all its methods.
-
-  In order to achieve so, you need to set up authentication, as well as install the library locally.
-
-
-  Setup Authentication
-  --------------------
-
-  To authenticate all of your API calls, first install and setup the [Google Cloud SDK][].
-  Once done, you can then run the following command in your terminal:
+@extends "readme.snip"
+@extends "ruby/method_sample.snip"
 
-      $ gcloud beta auth application-default login
-
-  or
-
-      $ gcloud auth login
-
-  Please see the [gcloud beta auth application-default login][] to find documentation showing the difference between these commands.
-
-  [Google Cloud SDK]: https://cloud.google.com/sdk/
-  [gcloud beta auth application-default login]: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login
-
-
-  Installation
-  -------------------
-
-  Install this library using gem:
+@snippet generate(metadata)
+  {@readme(metadata, exampleMethods(metadata.exampleMethods), installationLines(metadata))}
+@end
 
-      $ [sudo] gem install {@metadata.identifier}
+@private exampleMethods(methods)
+  @join method : methods on BREAK
+    @#### {@method.apiClassName}
+    ```rb
+    {@sampleCode_(method)}
+    ```
+  @end
+@end
 
-  At this point you are all set to continue.
+@private installationLines(metadata)
+  $ gem install {@metadata.identifier}
 @end
diff --git a/src/main/resources/com/google/api/codegen/ruby/gemspec.snip b/src/main/resources/com/google/api/codegen/ruby/gemspec.snip
index 905e108342..4e1fcd220c 100644
--- a/src/main/resources/com/google/api/codegen/ruby/gemspec.snip
+++ b/src/main/resources/com/google/api/codegen/ruby/gemspec.snip
@@ -2,36 +2,33 @@
   @# -*- ruby -*-
   @# encoding: utf-8
 
-  Gem::Specification.new do |s|
-    s.name          = "{@metadata.identifier}"
-    s.version       = "{@metadata.packageVersionBound.lower}"
-
-    s.authors       = ["{@metadata.author}"]
-    s.description   = "{@metadata.fullName} client for Ruby."
-    s.email         = "{@metadata.email}"
-    s.files         = Dir.glob(File.join("lib", "**", "*.rb"))
-    s.files        += Dir.glob(File.join('lib', '**', '*.json'))
-    s.files        += %w(Rakefile README.md LICENSE)
-    s.homepage      = "{@metadata.homepage}"
-    s.license       = "{@metadata.licenseName}"
-    s.platform      = Gem::Platform::RUBY
-    s.require_paths = ["lib"]
-    s.required_ruby_version = ">= 2.0.0"
-    s.requirements << "libgrpc ~> 1.0 needs to be installed"
-    s.summary       = "GRPC library for {@metadata.fullName}"
-
-    s.add_dependency "grpc", "~> {@metadata.grpcVersionBound.lower}"
-    s.add_dependency "googleauth", "~> {@metadata.authVersionBound.lower}"
-    s.add_dependency "google-gax", "~> {@metadata.gaxVersionBound.lower}"
+  Gem::Specification.new do |gem|
+    gem.name          = "{@metadata.identifier}"
+    gem.version       = "{@metadata.packageVersionBound.lower}"
+
+    gem.authors       = ["{@metadata.author}"]
+    gem.email         = "{@metadata.email}"
+    gem.description   = "{@metadata.identifier} is the official library for {@metadata.fullName}."
+    gem.summary       = "API Client library for {@metadata.fullName}"
+    gem.homepage      = "{@metadata.homepage}"
+    gem.license       = "{@metadata.licenseName}"
+
+    gem.platform      = Gem::Platform::RUBY
+
+    gem.files         = `git ls-files -- lib/*`.split("\n") +
+                        ["README.md", "LICENSE", ".yardopts"]
+    gem.require_paths = ["lib"]
+
+    gem.required_ruby_version = ">= 2.0.0"
+
+    gem.add_dependency "google-gax", "~> {@metadata.gaxVersionBound.lower}"
     @join packageDep : metadata.protoPackageDependencies
-      s.add_dependency "{@packageDep.name}", "~> {@packageDep.versionBound.lower}"
+      gem.add_dependency "{@packageDep.name}", "~> {@packageDep.versionBound.lower}"
     @end
 
-    s.add_development_dependency "bundler", "~> 1.9"
-    s.add_development_dependency "rake", "~> 10.4"
-    s.add_development_dependency "rubocop", "~> 0.32"
-    s.add_development_dependency "simplecov", "~> 0.9"
-    s.add_development_dependency "minitest", "~> 5.10"
+    gem.add_development_dependency "minitest", "~> 5.10"
+    gem.add_development_dependency "rubocop", "<= 0.35.1"
+    gem.add_development_dependency "simplecov", "~> 0.9"
   end
 
 @end
diff --git a/src/main/resources/com/google/api/codegen/ruby/gitignore.snip b/src/main/resources/com/google/api/codegen/ruby/gitignore.snip
new file mode 100644
index 0000000000..2ef918366c
--- /dev/null
+++ b/src/main/resources/com/google/api/codegen/ruby/gitignore.snip
@@ -0,0 +1,15 @@
+@snippet generate(metadata)
+  Gemfile.lock
+  coverage/*
+  doc/*
+  pkg/*
+  html/*
+  jsondoc/*
+
+  @# Ignore YARD stuffs
+  .yardoc
+
+  @# IDE settings
+  .idea
+  *.iml
+@end
diff --git a/src/main/resources/com/google/api/codegen/ruby/initcode.snip b/src/main/resources/com/google/api/codegen/ruby/initcode.snip
index c509db38f1..f21096facb 100644
--- a/src/main/resources/com/google/api/codegen/ruby/initcode.snip
+++ b/src/main/resources/com/google/api/codegen/ruby/initcode.snip
@@ -18,7 +18,7 @@
 @private initLineStructure(line)
   @switch line.fieldSettings.size.toString
   @case "0"
-    {@line.identifier} = {@line.typeName}.new
+    {@line.identifier} = {@line.fullyQualifiedTypeName}.new
   @case "1"
     {@singleLineInitStructure(line)}
   @case "2"
@@ -29,11 +29,11 @@
 @end
 
 @private singleLineInitStructure(line)
-    {@line.identifier} = {@line.typeName}.new({@structureFieldsList(line.fieldSettings)})
+    {@line.identifier} = {@line.fullyQualifiedTypeName}.new({@structureFieldsList(line.fieldSettings)})
 @end
 
 @private multiLineInitStructure(line)
-  {@line.identifier} = {@line.typeName}.new(
+  {@line.identifier} = {@line.fullyQualifiedTypeName}.new(
     {@multilineStructureFieldsList(line.fieldSettings)}
   )
 @end
@@ -79,7 +79,7 @@
   @case "SimpleInitValueView"
     {@initValue.initialValue}
   @case "FormattedInitValueView"
-    {@initValue.apiWrapperName}.{@initValue.formatFunctionName}\
+    {@initValue.fullyQualifiedApiWrapperName}.{@initValue.formatFunctionName}\
       ({@varList(initValue.formatArgs)})
   @default
     $unhandledCase: {@initValue.type}$
diff --git a/src/main/resources/com/google/api/codegen/ruby/method_sample.snip b/src/main/resources/com/google/api/codegen/ruby/method_sample.snip
index 90c4c79e4a..eb92820eeb 100644
--- a/src/main/resources/com/google/api/codegen/ruby/method_sample.snip
+++ b/src/main/resources/com/google/api/codegen/ruby/method_sample.snip
@@ -16,9 +16,7 @@
 @end
 
 @snippet sampleCodeCore(apiMethod)
-  {@aliasSection(apiMethod.initCode.importSection)}
-
-  {@apiMethod.apiVariableName} = {@apiMethod.apiClassName}.new
+  {@apiMethod.apiVariableName} = {@apiMethod.fullyQualifiedApiClassName}.new
   @if apiMethod.initCode.lines
     {@initCode(apiMethod.initCode)}
   @end
@@ -36,15 +34,6 @@
   @end
 @end
 
-@snippet aliasSection(importSection)
-  @join fileImport : importSection.appImports
-    @join alias : fileImport.types
-      {@alias.nickname} = {@alias.fullName}
-    @end
-  @end
-@end
-
-
 @private longRunningMethodSampleCode(apiMethod)
 
   @# Register a callback during the method call.
diff --git a/src/main/resources/com/google/api/codegen/ruby/rubocop.yml.snip b/src/main/resources/com/google/api/codegen/ruby/rubocop.yml.snip
new file mode 100644
index 0000000000..f463a8acf4
--- /dev/null
+++ b/src/main/resources/com/google/api/codegen/ruby/rubocop.yml.snip
@@ -0,0 +1,56 @@
+@snippet generate(metadata)
+  AllCops:
+    Exclude:
+      - "{@metadata.identifier}.gemspec"
+      - "lib/{@metadata.protoPath}/**/*"
+      # This should be removed in the future after we are sanitizing client files.
+      - "lib/{@metadata.versionPath}/**/*"
+      - "Rakefile"
+      - "test/**/*"
+
+  Documentation:
+    Enabled: false
+
+  Style/StringLiterals:
+    EnforcedStyle: double_quotes
+  Style/MethodDefParentheses:
+    EnforcedStyle: require_no_parentheses
+  Style/NumericLiterals:
+    Enabled: false
+  Style/SpaceAroundOperators:
+    Enabled: false
+  Metrics/ClassLength:
+    Enabled: false
+  Style/EmptyLines:
+    Enabled: false
+  Style/EmptyElse:
+    Enabled: false
+  Style/HashSyntax:
+    Exclude:
+      - "lib/{@metadata.versionPath}/**/*"
+  Metrics/LineLength:
+    Exclude:
+      - "lib/{@metadata.versionPath}/**/*"
+  Metrics/CyclomaticComplexity:
+    Max: 10
+  Metrics/PerceivedComplexity:
+    Max: 10
+  Metrics/AbcSize:
+    Max: 25
+    Exclude:
+      - "lib/{@metadata.versionPath}/**/*"
+  Metrics/MethodLength:
+    Max: 20
+    Exclude:
+      - "lib/{@metadata.versionPath}/**/*"
+  Metrics/ParameterLists:
+    Enabled: false
+  Style/RescueModifier:
+    Enabled: false
+  Style/ClassVars:
+    Enabled: false
+  Style/TrivialAccessors:
+    Enabled: false
+  Style/FileName:
+    Enabled: false
+@end
diff --git a/src/main/resources/com/google/api/codegen/ruby/sample.snip b/src/main/resources/com/google/api/codegen/ruby/sample.snip
index b824196b48..7b4a382996 100644
--- a/src/main/resources/com/google/api/codegen/ruby/sample.snip
+++ b/src/main/resources/com/google/api/codegen/ruby/sample.snip
@@ -23,9 +23,6 @@
     require 'googleauth'
   @end
   require '{@class.serviceRequirePath}'
-  @if class.hasResponse
-    require 'json'
-  @end
 
   {@class.serviceVarName} = {@class.serviceTypeNamespace}::{@class.serviceTypeName}.new
 
@@ -116,14 +113,14 @@
     @if class.pageStreaming.isResourceMap
       {@class.pageStreaming.pageVarName}.each do |{@class.pageStreaming.resourceKeyVarName}, {@class.pageStreaming.resourceValueVarName}|
         @# TODO: Change code below to process each ({@class.pageStreaming.resourceKeyVarName}, {@class.pageStreaming.resourceValueVarName}) pair:
-        puts String({@class.pageStreaming.resourceKeyVarName} << " => " << JSON.pretty_generate({@class.pageStreaming.resourceValueVarName})
+        puts String({@class.pageStreaming.resourceKeyVarName} << " => " << {@class.pageStreaming.resourceValueVarName}.to_json
       end
     @else
       # We don't handle non-repeated page streaming resources separately in Ruby
       # because the fetch_all treats them correctly.
       {@class.pageStreaming.pageVarName}.each do |{@class.pageStreaming.resourceVarName}|
         @# TODO: Change code below to process each `{@class.pageStreaming.resourceVarName}` resource:
-        puts JSON.pretty_generate({@class.pageStreaming.resourceVarName})
+        puts {@class.pageStreaming.resourceVarName}.to_json
       end
     @end
   @else
@@ -131,7 +128,7 @@
       {@class.responseVarName} = {@methodCall(class)}({@paramList(class.methodCallFieldVarNames)})
 
       @# TODO: Change code below to process the `{@class.responseVarName}` object:
-      puts JSON.pretty_generate({@class.responseVarName})
+      puts {@class.responseVarName}.to_json
     @else
       {@methodCall(class)}({@paramList(class.methodCallFieldVarNames)})
     @end
diff --git a/src/main/resources/com/google/api/codegen/ruby/test.snip b/src/main/resources/com/google/api/codegen/ruby/test.snip
index ca89978fa5..1b62017ea5 100644
--- a/src/main/resources/com/google/api/codegen/ruby/test.snip
+++ b/src/main/resources/com/google/api/codegen/ruby/test.snip
@@ -58,12 +58,8 @@
     @join test : testClass.testCases
 
       describe '{@test.clientMethodName}' do
-        custom_error = CustomTestError.new "Custom test error for {@test.serviceConstructorName}#{@test.clientMethodName}."
+        custom_error = CustomTestError.new "Custom test error for {@test.fullyQualifiedServiceClassName}#{@test.clientMethodName}."
 
-        @if {@aliasSection(test.initCode.importSection)}
-          {@aliasSection(test.mockResponse.initCode.importSection)}
-
-        @end
         {@testCase(test)}
 
         {@errorTestCase(test)}
@@ -130,7 +126,7 @@
     mock_stub = MockGrpcClientStub.new(:{@test.clientMethodName}, mock_method)
 
     {@test.grpcStubCallString}.stub(:new, mock_stub) do
-      client = {@test.serviceConstructorName}.new
+      client = {@test.fullyQualifiedServiceClassName}.new
 
       @# Call method
       {@methodCallWithResponse(test)}
@@ -160,7 +156,7 @@
     mock_stub = MockGrpcClientStub.new(:{@test.clientMethodName}, mock_method)
 
     {@test.grpcStubCallString}.stub(:new, mock_stub) do
-      client = {@test.serviceConstructorName}.new
+      client = {@test.fullyQualifiedServiceClassName}.new
 
       @# Call method
       {@methodCallWithResponse(test)}
@@ -198,7 +194,7 @@
     mock_stub = MockGrpcClientStub.new(:{@test.clientMethodName}, mock_method)
 
     {@test.grpcStubCallString}.stub(:new, mock_stub) do
-      client = {@test.serviceConstructorName}.new
+      client = {@test.fullyQualifiedServiceClassName}.new
 
       @# Call method
       {@methodCallWithResponse(test)}
@@ -216,7 +212,7 @@
     @end
     @# Create expected grpc response
     operation_error = Google::Rpc::Status.new(
-      message: 'Operation error for {@test.serviceConstructorName}#{@test.clientMethodName}.'
+      message: 'Operation error for {@test.fullyQualifiedServiceClassName}#{@test.clientMethodName}.'
     )
     operation = Google::Longrunning::Operation.new(
       name: 'operations/{@test.name}',
@@ -229,7 +225,7 @@
     mock_stub = MockGrpcClientStub.new(:{@test.clientMethodName}, mock_method)
 
     {@test.grpcStubCallString}.stub(:new, mock_stub) do
-      client = {@test.serviceConstructorName}.new
+      client = {@test.fullyQualifiedServiceClassName}.new
 
       @# Call method
       {@methodCallWithResponse(test)}
@@ -256,7 +252,7 @@
     mock_stub = MockGrpcClientStub.new(:{@test.clientMethodName}, mock_method)
 
     {@test.grpcStubCallString}.stub(:new, mock_stub) do
-      client = {@test.serviceConstructorName}.new
+      client = {@test.fullyQualifiedServiceClassName}.new
 
       @# Call method
       {@methodCallWithResponse(test)}
@@ -283,7 +279,7 @@
     mock_stub = MockGrpcClientStub.new(:{@test.clientMethodName}, mock_method)
 
     {@test.grpcStubCallString}.stub(:new, mock_stub) do
-      client = {@test.serviceConstructorName}.new
+      client = {@test.fullyQualifiedServiceClassName}.new
 
       @# Call method
       {@clientStreamingCall(test)}
@@ -311,7 +307,7 @@
     mock_stub = MockGrpcClientStub.new(:{@test.clientMethodName}, mock_method)
 
     {@test.grpcStubCallString}.stub(:new, mock_stub) do
-      client = {@test.serviceConstructorName}.new
+      client = {@test.fullyQualifiedServiceClassName}.new
 
       @# Call method
       {@clientStreamingCall(test)}
@@ -335,7 +331,7 @@
     mock_stub = MockGrpcClientStub.new(:{@test.clientMethodName}, mock_method)
 
     {@test.grpcStubCallString}.stub(:new, mock_stub) do
-      client = {@test.serviceConstructorName}.new
+      client = {@test.fullyQualifiedServiceClassName}.new
 
       @# Call method
       err = assert_raises Google::Gax::GaxError do
@@ -358,7 +354,7 @@
     mock_stub = MockGrpcClientStub.new(:{@test.clientMethodName}, mock_method)
 
     {@test.grpcStubCallString}.stub(:new, mock_stub) do
-      client = {@test.serviceConstructorName}.new
+      client = {@test.fullyQualifiedServiceClassName}.new
 
       @# Call method
       err = assert_raises Google::Gax::GaxError do
@@ -462,11 +458,7 @@
 @end
 
 @private expectedValue(assert)
-  @if assert.hasEnumTypeName
-    {@assert.enumTypeName}.lookup({@assert.expectedValueIdentifier})
-  @else
-    {@assert.expectedValueIdentifier}
-  @end
+  {@assert.expectedValueIdentifier}
 @end
 
 @private methodCallWithResponse(test)
diff --git a/src/main/resources/com/google/api/codegen/ruby/yardopts.snip b/src/main/resources/com/google/api/codegen/ruby/yardopts.snip
new file mode 100644
index 0000000000..32e1110be1
--- /dev/null
+++ b/src/main/resources/com/google/api/codegen/ruby/yardopts.snip
@@ -0,0 +1,10 @@
+@snippet generate(metadata)
+  --no-private
+  --title={@metadata.fullName}
+  --exclude lib/{@metadata.versionPath}
+  --markup markdown
+
+  ./lib/**/*.rb
+  -
+  README.md
+@end
diff --git a/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_common_protos.baseline b/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_common_protos.baseline
index a994775753..85869c75ae 100644
--- a/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_common_protos.baseline
+++ b/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_common_protos.baseline
@@ -311,7 +311,7 @@ if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')
   tasks.uploadArchives.dependsOn(failUploadArchives)
 }
 
-task checkOutGhPages {
+task checkOutGhPages << {
   if (!new File('tmp_gh-pages').exists()) {
     exec {
       commandLine 'git', 'clone', '--branch', 'gh-pages',
@@ -358,3 +358,4 @@ task createApiDocsRedirect {
 task updateDocsWithCurrentVersion {
   dependsOn 'createApiDocsRedirect'
 }
+
diff --git a/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_grpc_stubs.baseline b/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_grpc_stubs.baseline
index 850bd376b7..8e0f771574 100644
--- a/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_grpc_stubs.baseline
+++ b/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_grpc_stubs.baseline
@@ -226,7 +226,7 @@ repositories {
 dependencies {
   compile "io.grpc:grpc-stub:1.0.1"
   compile "io.grpc:grpc-protobuf:1.0.1"
-  compile "com.google.api.grpc:proto-google-cloud-library-v1:0.1.7"
+  compile project(":proto-google-cloud-library-v1")
 }
 
 ext {
@@ -312,7 +312,7 @@ if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')
   tasks.uploadArchives.dependsOn(failUploadArchives)
 }
 
-task checkOutGhPages {
+task checkOutGhPages << {
   if (!new File('tmp_gh-pages').exists()) {
     exec {
       commandLine 'git', 'clone', '--branch', 'gh-pages',
@@ -359,3 +359,4 @@ task createApiDocsRedirect {
 task updateDocsWithCurrentVersion {
   dependsOn 'createApiDocsRedirect'
 }
+
diff --git a/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_library.baseline b/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_library.baseline
index 6386b865e2..c55298ed4f 100644
--- a/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_library.baseline
+++ b/src/test/java/com/google/api/codegen/grpcmetadatagen/testdata/java_library.baseline
@@ -226,8 +226,8 @@ repositories {
 dependencies {
   compile "com.google.protobuf:protobuf-java:3.0.0"
   compile "com.google.api:api-common:0.0.2"
-  compile "com.google.api.grpc:proto-google-common-protos:0.1.6"
-  compile "com.google.api.grpc:proto-google-some-other-package-v1:0.0.0"
+  compile project(":proto-google-common-protos")
+  compile project(":proto-google-some-other-package-v1")
 }
 
 ext {
@@ -313,7 +313,7 @@ if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')
   tasks.uploadArchives.dependsOn(failUploadArchives)
 }
 
-task checkOutGhPages {
+task checkOutGhPages << {
   if (!new File('tmp_gh-pages').exists()) {
     exec {
       commandLine 'git', 'clone', '--branch', 'gh-pages',
@@ -360,3 +360,4 @@ task createApiDocsRedirect {
 task updateDocsWithCurrentVersion {
   dependsOn 'createApiDocsRedirect'
 }
+
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/go/go_foo.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/go/go_foo.v1.json.baseline
index 7b1daa17a4..950240773d 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/go/go_foo.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/go/go_foo.v1.json.baseline
@@ -22,9 +22,6 @@ func main() {
   ctx := context.Background()
 
   c := &http.Client{}
-  if err != nil {
-    log.Fatal(err)
-  }
 
   fooService, err := foo.New(c)
   if err != nil {
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_bigquery.v2.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_bigquery.v2.json.baseline
index dfe08b452b..41539a5f37 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_bigquery.v2.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_bigquery.v2.json.baseline
@@ -528,7 +528,7 @@ authorize(function(authClient) {
       // TODO: Add desired media content for upload. See
       // https://github.com/google/google-api-nodejs-client#media-uploads
       mimeType: '',  // See https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
-      body: {},
+      body: '',
     },
 
     auth: authClient,
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_dfareporting.v2.6.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_dfareporting.v2.6.json.baseline
index 788df4eb10..2fc2c732c5 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_dfareporting.v2.6.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_dfareporting.v2.6.json.baseline
@@ -2605,7 +2605,7 @@ authorize(function(authClient) {
       // TODO: Add desired media content for upload. See
       // https://github.com/google/google-api-nodejs-client#media-uploads
       mimeType: '',  // See https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
-      body: {},
+      body: '',
     },
 
     auth: authClient,
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_storage.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_storage.v1.json.baseline
index a9dd333186..676ebf7e12 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_storage.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/nodejs/nodejs_storage.v1.json.baseline
@@ -1620,7 +1620,7 @@ authorize(function(authClient) {
       // TODO: Add desired media content for upload. See
       // https://github.com/google/google-api-nodejs-client#media-uploads
       mimeType: '',  // See https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
-      body: {},
+      body: '',
     },
 
     auth: authClient,
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/py/py_foo.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/py/py_foo.v1.json.baseline
index e4f28fe1fb..6d6855a4e7 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/py/py_foo.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/py/py_foo.v1.json.baseline
@@ -10,9 +10,10 @@ BEFORE RUNNING:
 """
 from pprint import pprint
 
+import httplib2
 from googleapiclient import discovery
 
-service = discovery.build('foo', 'v1', discoveryServiceUrl='localhost:8080/$discovery/foo?version=v1')
+service = discovery.build('foo', 'v1', http=httplib2.Http(timeout=60), discoveryServiceUrl='localhost:8080/$discovery/foo?version=v1')
 
 request = service.baz().get()
 response = request.execute()
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_adexchangebuyer.v1.4.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_adexchangebuyer.v1.4.json.baseline
index c93b47822a..19eaaab62e 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_adexchangebuyer.v1.4.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_adexchangebuyer.v1.4.json.baseline
@@ -7,7 +7,6 @@
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -24,7 +23,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_account(id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -33,7 +32,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -47,7 +45,7 @@ service.authorization = nil
 response = service.list_accounts()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -56,7 +54,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -77,7 +74,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::Account.new
 response = service.patch_account(id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -86,7 +83,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -107,7 +103,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::Account.new
 response = service.update_account(id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -116,7 +112,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -133,7 +128,7 @@ account_id = 0  # TODO: Update placeholder value.
 response = service.get_billing_info(account_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -142,7 +137,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -156,7 +150,7 @@ service.authorization = nil
 response = service.list_billing_infos()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -165,7 +159,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -185,7 +178,7 @@ billing_id = 0  # TODO: Update placeholder value.
 response = service.get_budget(account_id, billing_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -194,7 +187,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -218,7 +210,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::Budget.new
 response = service.patch_budget(account_id, billing_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -227,7 +219,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -251,7 +242,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::Budget.new
 response = service.update_budget(account_id, billing_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -288,7 +279,6 @@ service.add_creative_deal(account_id, buyer_creative_id, deal_id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -308,7 +298,7 @@ buyer_creative_id = 'my-buyer-creative-id'  # TODO: Update placeholder value.
 response = service.get_creative(account_id, buyer_creative_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -317,7 +307,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -334,7 +323,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::Creative.new
 response = service.insert_creative(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -343,7 +332,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -360,7 +348,7 @@ end
 
 items.each do |creative|
   # TODO: Change code below to process each `creative` resource:
-  puts JSON.pretty_generate(creative)
+  puts creative.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -370,7 +358,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -390,7 +377,7 @@ buyer_creative_id = 'my-buyer-creative-id'  # TODO: Update placeholder value.
 response = service.list_creative_deals(account_id, buyer_creative_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -427,7 +414,6 @@ service.remove_creative_deal(account_id, buyer_creative_id, deal_id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -447,7 +433,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::DeleteOrderDealsRequest.new
 response = service.delete_marketplacedeal_order_deals(proposal_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -456,7 +442,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -476,7 +461,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::AddOrderDealsRequest.new
 response = service.insert_marketplacedeal(proposal_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -485,7 +470,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -503,7 +487,7 @@ proposal_id = 'my-proposal-id'  # TODO: Update placeholder value.
 response = service.list_marketplacedeals(proposal_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -512,7 +496,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -532,7 +515,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::EditAllOrderDealsRequest.new
 response = service.update_marketplacedeal(proposal_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -541,7 +524,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -561,7 +543,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::AddOrderNotesRequest.new
 response = service.insert_marketplacenote(proposal_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -570,7 +552,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -588,7 +569,7 @@ proposal_id = 'my-proposal-id'  # TODO: Update placeholder value.
 response = service.list_marketplacenotes(proposal_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -622,7 +603,6 @@ service.update_marketplace_private_auction_proposal(private_auction_id, request_
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -645,7 +625,7 @@ start_date_time = ''  # TODO: Update placeholder value.
 response = service.list_performance_reports(account_id, end_date_time, start_date_time)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -679,7 +659,6 @@ service.delete_pretargeting_config(account_id, config_id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -699,7 +678,7 @@ config_id = 0  # TODO: Update placeholder value.
 response = service.get_pretargeting_config(account_id, config_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -708,7 +687,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -728,7 +706,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::PretargetingConfig.new
 response = service.insert_pretargeting_config(account_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -737,7 +715,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -754,7 +731,7 @@ account_id = 0  # TODO: Update placeholder value.
 response = service.list_pretargeting_configs(account_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -763,7 +740,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -787,7 +763,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::PretargetingConfig.new
 response = service.patch_pretargeting_config(account_id, config_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -796,7 +772,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -820,7 +795,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::PretargetingConfig.new
 response = service.update_pretargeting_config(account_id, config_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -829,7 +804,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -846,7 +820,7 @@ product_id = 'my-product-id'  # TODO: Update placeholder value.
 response = service.get_product(product_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -855,7 +829,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -869,7 +842,7 @@ service.authorization = nil
 response = service.search_products()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -878,7 +851,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -895,7 +867,7 @@ proposal_id = 'my-proposal-id'  # TODO: Update placeholder value.
 response = service.get_proposal(proposal_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -904,7 +876,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -921,7 +892,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::CreateOrdersRequest.new
 response = service.insert_proposal(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -930,7 +901,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -960,7 +930,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::Proposal.new
 response = service.patch_proposal(proposal_id, revision_number, update_action, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -969,7 +939,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -983,7 +952,7 @@ service.authorization = nil
 response = service.search_proposals()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -1014,7 +983,6 @@ service.proposal_setup_complete(proposal_id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -1044,7 +1012,7 @@ request_body = Google::Apis::AdexchangebuyerV1_4::Proposal.new
 response = service.update_proposal(proposal_id, revision_number, update_action, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Ad Exchange Buyer API
@@ -1053,7 +1021,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/adexchangebuyer_v1_4'
-require 'json'
 
 service = Google::Apis::AdexchangebuyerV1_4::AdExchangeBuyerService.new
 
@@ -1070,4 +1037,4 @@ account_id = 0  # TODO: Update placeholder value.
 response = service.list_pub_profiles(account_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_appengine.v1beta5.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_appengine.v1beta5.json.baseline
index e1cc873a8f..21bbce1eb6 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_appengine.v1beta5.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_appengine.v1beta5.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -29,7 +28,7 @@ request_body = Google::Apis::AppengineV1beta5::Application.new
 response = service.create_app(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -47,7 +46,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -60,7 +58,7 @@ apps_id = 'my-apps-id'  # TODO: Update placeholder value.
 response = service.get_app(apps_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -78,7 +76,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -94,7 +91,7 @@ locations_id = 'my-locations-id'  # TODO: Update placeholder value.
 response = service.get_app_location(apps_id, locations_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -112,7 +109,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -128,7 +124,7 @@ end
 
 locations.each do |location|
   # TODO: Change code below to process each `location` resource:
-  puts JSON.pretty_generate(location)
+  puts location.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -147,7 +143,6 @@ end
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -163,7 +158,7 @@ operations_id = 'my-operations-id'  # TODO: Update placeholder value.
 response = service.get_app_operation(apps_id, operations_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -181,7 +176,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -197,7 +191,7 @@ end
 
 operations.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -216,7 +210,6 @@ end
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -233,7 +226,7 @@ request_body = Google::Apis::AppengineV1beta5::Application.new
 response = service.patch_app(apps_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -251,7 +244,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -267,7 +259,7 @@ services_id = 'my-services-id'  # TODO: Update placeholder value.
 response = service.delete_app_service(apps_id, services_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -285,7 +277,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -301,7 +292,7 @@ services_id = 'my-services-id'  # TODO: Update placeholder value.
 response = service.get_app_service(apps_id, services_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -319,7 +310,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -335,7 +325,7 @@ end
 
 services.each do |service2|
   # TODO: Change code below to process each `service2` resource:
-  puts JSON.pretty_generate(service2)
+  puts service2.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -354,7 +344,6 @@ end
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -374,7 +363,7 @@ request_body = Google::Apis::AppengineV1beta5::Service.new
 response = service.patch_app_service(apps_id, services_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -392,7 +381,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -411,7 +399,7 @@ request_body = Google::Apis::AppengineV1beta5::Version.new
 response = service.create_app_service_version(apps_id, services_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -429,7 +417,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -448,7 +435,7 @@ versions_id = 'my-versions-id'  # TODO: Update placeholder value.
 response = service.delete_app_service_version(apps_id, services_id, versions_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -466,7 +453,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -485,7 +471,7 @@ versions_id = 'my-versions-id'  # TODO: Update placeholder value.
 response = service.get_app_service_version(apps_id, services_id, versions_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -503,7 +489,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -529,7 +514,7 @@ request_body = Google::Apis::AppengineV1beta5::DebugInstanceRequest.new
 response = service.debug_instance(apps_id, services_id, versions_id, instances_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -547,7 +532,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -570,7 +554,7 @@ instances_id = 'my-instances-id'  # TODO: Update placeholder value.
 response = service.delete_app_service_version_instance(apps_id, services_id, versions_id, instances_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -588,7 +572,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -611,7 +594,7 @@ instances_id = 'my-instances-id'  # TODO: Update placeholder value.
 response = service.get_app_service_version_instance(apps_id, services_id, versions_id, instances_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google App Engine Admin API
@@ -629,7 +612,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -651,7 +633,7 @@ end
 
 instances.each do |instance|
   # TODO: Change code below to process each `instance` resource:
-  puts JSON.pretty_generate(instance)
+  puts instance.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -670,7 +652,6 @@ end
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -689,7 +670,7 @@ end
 
 versions.each do |version|
   # TODO: Change code below to process each `version` resource:
-  puts JSON.pretty_generate(version)
+  puts version.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -708,7 +689,6 @@ end
 
 require 'googleauth'
 require 'google/apis/appengine_v1beta5'
-require 'json'
 
 service = Google::Apis::AppengineV1beta5::AppengineService.new
 
@@ -731,4 +711,4 @@ request_body = Google::Apis::AppengineV1beta5::Version.new
 response = service.patch_app_service_version(apps_id, services_id, versions_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_bigquery.v2.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_bigquery.v2.json.baseline
index 2dfb2aa57c..a3815e89e8 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_bigquery.v2.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_bigquery.v2.json.baseline
@@ -46,7 +46,6 @@ service.delete_dataset(project_id, dataset_id)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -62,7 +61,7 @@ dataset_id = 'my-dataset-id'  # TODO: Update placeholder value.
 response = service.get_dataset(project_id, dataset_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -80,7 +79,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -96,7 +94,7 @@ request_body = Google::Apis::BigqueryV2::Dataset.new
 response = service.insert_dataset(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -114,7 +112,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -130,7 +127,7 @@ end
 
 datasets.each do |dataset|
   # TODO: Change code below to process each `dataset` resource:
-  puts JSON.pretty_generate(dataset)
+  puts dataset.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -149,7 +146,6 @@ end
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -169,7 +165,7 @@ request_body = Google::Apis::BigqueryV2::Dataset.new
 response = service.patch_dataset(project_id, dataset_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -187,7 +183,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -207,7 +202,7 @@ request_body = Google::Apis::BigqueryV2::Dataset.new
 response = service.update_dataset(project_id, dataset_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -225,7 +220,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -241,7 +235,7 @@ job_id = 'my-job-id'  # TODO: Update placeholder value.
 response = service.cancel_job(project_id, job_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -259,7 +253,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -275,7 +268,7 @@ job_id = 'my-job-id'  # TODO: Update placeholder value.
 response = service.get_job(project_id, job_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -293,7 +286,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -312,7 +304,7 @@ end
 
 errors.each do |error_proto|
   # TODO: Change code below to process each `error_proto` resource:
-  puts JSON.pretty_generate(error_proto)
+  puts error_proto.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -331,7 +323,6 @@ end
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -351,7 +342,7 @@ request_body = Google::Apis::BigqueryV2::Job.new
 response = service.insert_job(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -369,7 +360,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -385,7 +375,7 @@ end
 
 jobs.each do |job|
   # TODO: Change code below to process each `job` resource:
-  puts JSON.pretty_generate(job)
+  puts job.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -404,7 +394,6 @@ end
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -420,7 +409,7 @@ request_body = Google::Apis::BigqueryV2::QueryRequest.new
 response = service.query_job(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -438,7 +427,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -451,7 +439,7 @@ end
 
 projects.each do |project|
   # TODO: Change code below to process each `project` resource:
-  puts JSON.pretty_generate(project)
+  puts project.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -470,7 +458,6 @@ end
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -492,7 +479,7 @@ request_body = Google::Apis::BigqueryV2::InsertAllTableDataRequest.new
 response = service.insert_all_table_data(project_id, dataset_id, table_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -510,7 +497,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -532,7 +518,7 @@ end
 
 rows.each do |table_row|
   # TODO: Change code below to process each `table_row` resource:
-  puts JSON.pretty_generate(table_row)
+  puts table_row.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -584,7 +570,6 @@ service.delete_table(project_id, dataset_id, table_id)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -603,7 +588,7 @@ table_id = 'my-table-id'  # TODO: Update placeholder value.
 response = service.get_table(project_id, dataset_id, table_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -621,7 +606,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -640,7 +624,7 @@ request_body = Google::Apis::BigqueryV2::Table.new
 response = service.insert_table(project_id, dataset_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -658,7 +642,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -677,7 +660,7 @@ end
 
 tables.each do |table|
   # TODO: Change code below to process each `table` resource:
-  puts JSON.pretty_generate(table)
+  puts table.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -696,7 +679,6 @@ end
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -719,7 +701,7 @@ request_body = Google::Apis::BigqueryV2::Table.new
 response = service.patch_table(project_id, dataset_id, table_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the BigQuery API
@@ -737,7 +719,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/bigquery_v2'
-require 'json'
 
 service = Google::Apis::BigqueryV2::BigqueryService.new
 
@@ -760,4 +741,4 @@ request_body = Google::Apis::BigqueryV2::Table.new
 response = service.update_table(project_id, dataset_id, table_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudbilling.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudbilling.v1.json.baseline
index 1d13b8cb2b..f6b481b794 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudbilling.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudbilling.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/cloudbilling_v1'
-require 'json'
 
 service = Google::Apis::CloudbillingV1::CloudbillingService.new
 
@@ -30,7 +29,7 @@ name = 'billingAccounts/my-billing-account'  # TODO: Update placeholder value.
 response = service.get_billing_account(name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Billing API
@@ -48,7 +47,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudbilling_v1'
-require 'json'
 
 service = Google::Apis::CloudbillingV1::CloudbillingService.new
 
@@ -61,7 +59,7 @@ end
 
 billing_accounts.each do |billing_account|
   # TODO: Change code below to process each `billing_account` resource:
-  puts JSON.pretty_generate(billing_account)
+  puts billing_account.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -80,7 +78,6 @@ end
 
 require 'googleauth'
 require 'google/apis/cloudbilling_v1'
-require 'json'
 
 service = Google::Apis::CloudbillingV1::CloudbillingService.new
 
@@ -97,7 +94,7 @@ end
 
 project_billing_info2.each do |project_billing_info|
   # TODO: Change code below to process each `project_billing_info` resource:
-  puts JSON.pretty_generate(project_billing_info)
+  puts project_billing_info.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -116,7 +113,6 @@ end
 
 require 'googleauth'
 require 'google/apis/cloudbilling_v1'
-require 'json'
 
 service = Google::Apis::CloudbillingV1::CloudbillingService.new
 
@@ -130,7 +126,7 @@ name = 'projects/my-project'  # TODO: Update placeholder value.
 response = service.get_project_billing_info(name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Billing API
@@ -148,7 +144,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudbilling_v1'
-require 'json'
 
 service = Google::Apis::CloudbillingV1::CloudbillingService.new
 
@@ -166,4 +161,4 @@ request_body = Google::Apis::CloudbillingV1::ProjectBillingInfo.new
 response = service.update_project_billing_info(name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_clouddebugger.v2.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_clouddebugger.v2.json.baseline
index 57029dc4ba..a72c650098 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_clouddebugger.v2.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_clouddebugger.v2.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/clouddebugger_v2'
-require 'json'
 
 service = Google::Apis::ClouddebuggerV2::CloudDebuggerService.new
 
@@ -29,7 +28,7 @@ debuggee_id = 'my-debuggee-id'  # TODO: Update placeholder value.
 response = service.list_controller_debuggee_breakpoints(debuggee_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Debugger API
@@ -47,7 +46,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouddebugger_v2'
-require 'json'
 
 service = Google::Apis::ClouddebuggerV2::CloudDebuggerService.new
 
@@ -67,7 +65,7 @@ request_body = Google::Apis::ClouddebuggerV2::UpdateActiveBreakpointRequest.new
 response = service.update_active_breakpoint(debuggee_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Debugger API
@@ -85,7 +83,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouddebugger_v2'
-require 'json'
 
 service = Google::Apis::ClouddebuggerV2::CloudDebuggerService.new
 
@@ -98,7 +95,7 @@ request_body = Google::Apis::ClouddebuggerV2::RegisterDebuggeeRequest.new
 response = service.register_debuggee(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Debugger API
@@ -146,7 +143,6 @@ service.delete_debugger_debuggee_breakpoint(debuggee_id, breakpoint_id)
 
 require 'googleauth'
 require 'google/apis/clouddebugger_v2'
-require 'json'
 
 service = Google::Apis::ClouddebuggerV2::CloudDebuggerService.new
 
@@ -162,7 +158,7 @@ breakpoint_id = 'my-breakpoint-id'  # TODO: Update placeholder value.
 response = service.get_debugger_debuggee_breakpoint(debuggee_id, breakpoint_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Debugger API
@@ -180,7 +176,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouddebugger_v2'
-require 'json'
 
 service = Google::Apis::ClouddebuggerV2::CloudDebuggerService.new
 
@@ -193,7 +188,7 @@ debuggee_id = 'my-debuggee-id'  # TODO: Update placeholder value.
 response = service.list_debugger_debuggee_breakpoints(debuggee_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Debugger API
@@ -211,7 +206,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouddebugger_v2'
-require 'json'
 
 service = Google::Apis::ClouddebuggerV2::CloudDebuggerService.new
 
@@ -227,7 +221,7 @@ request_body = Google::Apis::ClouddebuggerV2::Breakpoint.new
 response = service.set_debugger_debuggee_breakpoint(debuggee_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Debugger API
@@ -245,7 +239,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouddebugger_v2'
-require 'json'
 
 service = Google::Apis::ClouddebuggerV2::CloudDebuggerService.new
 
@@ -255,4 +248,4 @@ service.authorization = \
 response = service.list_debugger_debuggees()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudmonitoring.v2beta2.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudmonitoring.v2beta2.json.baseline
index c1239bd714..4d86d50024 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudmonitoring.v2beta2.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudmonitoring.v2beta2.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/cloudmonitoring_v2beta2'
-require 'json'
 
 service = Google::Apis::CloudmonitoringV2beta2::CloudMonitoringService.new
 
@@ -32,7 +31,7 @@ request_body = Google::Apis::CloudmonitoringV2beta2::MetricDescriptor.new
 response = service.create_metric_descriptor(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Monitoring API
@@ -50,7 +49,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudmonitoring_v2beta2'
-require 'json'
 
 service = Google::Apis::CloudmonitoringV2beta2::CloudMonitoringService.new
 
@@ -66,7 +64,7 @@ metric = 'my-metric'  # TODO: Update placeholder value.
 response = service.delete_metric_descriptor(project, metric)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Monitoring API
@@ -84,7 +82,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudmonitoring_v2beta2'
-require 'json'
 
 service = Google::Apis::CloudmonitoringV2beta2::CloudMonitoringService.new
 
@@ -103,7 +100,7 @@ end
 
 metrics.each do |metric_descriptor|
   # TODO: Change code below to process each `metric_descriptor` resource:
-  puts JSON.pretty_generate(metric_descriptor)
+  puts metric_descriptor.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -122,7 +119,6 @@ end
 
 require 'googleauth'
 require 'google/apis/cloudmonitoring_v2beta2'
-require 'json'
 
 service = Google::Apis::CloudmonitoringV2beta2::CloudMonitoringService.new
 
@@ -149,7 +145,7 @@ end
 
 timeseries2.each do |timeseries|
   # TODO: Change code below to process each `timeseries` resource:
-  puts JSON.pretty_generate(timeseries)
+  puts timeseries.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -168,7 +164,6 @@ end
 
 require 'googleauth'
 require 'google/apis/cloudmonitoring_v2beta2'
-require 'json'
 
 service = Google::Apis::CloudmonitoringV2beta2::CloudMonitoringService.new
 
@@ -184,7 +179,7 @@ request_body = Google::Apis::CloudmonitoringV2beta2::WriteTimeseriesRequest.new
 response = service.write_timeseries(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Monitoring API
@@ -202,7 +197,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudmonitoring_v2beta2'
-require 'json'
 
 service = Google::Apis::CloudmonitoringV2beta2::CloudMonitoringService.new
 
@@ -229,5 +223,5 @@ end
 
 timeseries.each do |timeseries_descriptor|
   # TODO: Change code below to process each `timeseries_descriptor` resource:
-  puts JSON.pretty_generate(timeseries_descriptor)
+  puts timeseries_descriptor.to_json
 end
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudresourcemanager.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudresourcemanager.v1.json.baseline
index da826c13b6..87ca7a3efa 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudresourcemanager.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudresourcemanager.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -29,7 +28,7 @@ name = 'operations/my-operation'  # TODO: Update placeholder value.
 response = service.get_operation(name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -47,7 +46,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -60,7 +58,7 @@ name = 'organizations/my-organization'  # TODO: Update placeholder value.
 response = service.get_organization(name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -78,7 +76,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -96,7 +93,7 @@ request_body = Google::Apis::CloudresourcemanagerV1::GetIamPolicyRequest.new
 response = service.get_organization_iam_policy(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -114,7 +111,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -131,7 +127,7 @@ end
 
 organizations.each do |organization|
   # TODO: Change code below to process each `organization` resource:
-  puts JSON.pretty_generate(organization)
+  puts organization.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -150,7 +146,6 @@ end
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -168,7 +163,7 @@ request_body = Google::Apis::CloudresourcemanagerV1::SetIamPolicyRequest.new
 response = service.set_organization_iam_policy(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -186,7 +181,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -204,7 +198,7 @@ request_body = Google::Apis::CloudresourcemanagerV1::TestIamPermissionsRequest.n
 response = service.test_organization_iam_permissions(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -222,7 +216,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -235,7 +228,7 @@ request_body = Google::Apis::CloudresourcemanagerV1::Project.new
 response = service.create_project(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -281,7 +274,6 @@ service.delete_project(project_id)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -295,7 +287,7 @@ project_id = 'my-project-id'  # TODO: Update placeholder value.
 response = service.get_project(project_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -313,7 +305,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -330,7 +321,7 @@ request_body = Google::Apis::CloudresourcemanagerV1::GetAncestryRequest.new
 response = service.get_project_ancestry(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -348,7 +339,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -366,7 +356,7 @@ request_body = Google::Apis::CloudresourcemanagerV1::GetIamPolicyRequest.new
 response = service.get_project_iam_policy(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -384,7 +374,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -397,7 +386,7 @@ end
 
 projects.each do |project|
   # TODO: Change code below to process each `project` resource:
-  puts JSON.pretty_generate(project)
+  puts project.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -416,7 +405,6 @@ end
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -434,7 +422,7 @@ request_body = Google::Apis::CloudresourcemanagerV1::SetIamPolicyRequest.new
 response = service.set_project_iam_policy(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -452,7 +440,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -470,7 +457,7 @@ request_body = Google::Apis::CloudresourcemanagerV1::TestIamPermissionsRequest.n
 response = service.test_project_iam_permissions(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Resource Manager API
@@ -519,7 +506,6 @@ service.undelete_project(project_id, request_body)
 
 require 'googleauth'
 require 'google/apis/cloudresourcemanager_v1'
-require 'json'
 
 service = Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService.new
 
@@ -537,4 +523,4 @@ request_body = Google::Apis::CloudresourcemanagerV1::Project.new
 response = service.update_project(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudtrace.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudtrace.v1.json.baseline
index e7aab75db2..32a44e8bff 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudtrace.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_cloudtrace.v1.json.baseline
@@ -47,7 +47,6 @@ service.patch_project_traces(project_id, request_body)
 
 require 'googleauth'
 require 'google/apis/cloudtrace_v1'
-require 'json'
 
 service = Google::Apis::CloudtraceV1::CloudTraceService.new
 
@@ -63,7 +62,7 @@ trace_id = 'my-trace-id'  # TODO: Update placeholder value.
 response = service.get_project_trace(project_id, trace_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Trace API
@@ -81,7 +80,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/cloudtrace_v1'
-require 'json'
 
 service = Google::Apis::CloudtraceV1::CloudTraceService.new
 
@@ -97,5 +95,5 @@ end
 
 traces.each do |trace|
   # TODO: Change code below to process each `trace` resource:
-  puts JSON.pretty_generate(trace)
+  puts trace.to_json
 end
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_clouduseraccounts.beta.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_clouduseraccounts.beta.json.baseline
index d15ad0b058..f329fb0558 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_clouduseraccounts.beta.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_clouduseraccounts.beta.json.baseline
@@ -46,7 +46,6 @@ service.delete_global_accounts_operation(project, operation)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -62,7 +61,7 @@ operation = 'my-operation'  # TODO: Update placeholder value.
 response = service.get_global_accounts_operation(project, operation)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -80,7 +79,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -96,7 +94,7 @@ end
 
 items.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -115,7 +113,6 @@ end
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -134,7 +131,7 @@ request_body = Google::Apis::ClouduseraccountsBeta::GroupsAddMemberRequest.new
 response = service.add_group_member(project, group_name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -152,7 +149,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -168,7 +164,7 @@ group_name = 'my-group-name'  # TODO: Update placeholder value.
 response = service.delete_group(project, group_name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -186,7 +182,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -202,7 +197,7 @@ group_name = 'my-group-name'  # TODO: Update placeholder value.
 response = service.get_group(project, group_name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -220,7 +215,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -236,7 +230,7 @@ request_body = Google::Apis::ClouduseraccountsBeta::Group.new
 response = service.insert_group(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -254,7 +248,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -270,7 +263,7 @@ end
 
 items.each do |group|
   # TODO: Change code below to process each `group` resource:
-  puts JSON.pretty_generate(group)
+  puts group.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -289,7 +282,6 @@ end
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -308,7 +300,7 @@ request_body = Google::Apis::ClouduseraccountsBeta::GroupsRemoveMemberRequest.ne
 response = service.remove_group_member(project, group_name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -326,7 +318,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -348,7 +339,7 @@ instance = ''  # TODO: Update placeholder value.
 response = service.get_linux_authorized_keys_view(project, zone, user, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -366,7 +357,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -385,7 +375,7 @@ instance = ''  # TODO: Update placeholder value.
 response = service.get_linux_linux_account_views(project, zone, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -403,7 +393,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -422,7 +411,7 @@ request_body = Google::Apis::ClouduseraccountsBeta::PublicKey.new
 response = service.add_user_public_key(project, user, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -440,7 +429,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -456,7 +444,7 @@ user = 'my-user'  # TODO: Update placeholder value.
 response = service.delete_user(project, user)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -474,7 +462,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -490,7 +477,7 @@ user = 'my-user'  # TODO: Update placeholder value.
 response = service.get_user(project, user)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -508,7 +495,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -524,7 +510,7 @@ request_body = Google::Apis::ClouduseraccountsBeta::User.new
 response = service.insert_user(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud User Accounts API
@@ -542,7 +528,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -558,7 +543,7 @@ end
 
 items.each do |user|
   # TODO: Change code below to process each `user` resource:
-  puts JSON.pretty_generate(user)
+  puts user.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -577,7 +562,6 @@ end
 
 require 'googleauth'
 require 'google/apis/clouduseraccounts_beta'
-require 'json'
 
 service = Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService.new
 
@@ -597,4 +581,4 @@ fingerprint = ''  # TODO: Update placeholder value.
 response = service.remove_user_public_key(project, user, fingerprint)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_compute.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_compute.v1.json.baseline
index ec635ca6f9..d8270de3ac 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_compute.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_compute.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -32,7 +31,7 @@ end
 
 items.each do |name, addresses_scoped_list|
   # TODO: Change code below to process each (name, addresses_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(addresses_scoped_list)
+  puts String(name << " => " << addresses_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -51,7 +50,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -70,7 +68,7 @@ address = 'my-address'  # TODO: Update placeholder value.
 response = service.delete_address(project, region, address)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -88,7 +86,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -107,7 +104,7 @@ address = 'my-address'  # TODO: Update placeholder value.
 response = service.get_address(project, region, address)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -125,7 +122,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -144,7 +140,7 @@ request_body = Google::Apis::ComputeV1::Address.new
 response = service.insert_address(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -162,7 +158,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -181,7 +176,7 @@ end
 
 items.each do |address|
   # TODO: Change code below to process each `address` resource:
-  puts JSON.pretty_generate(address)
+  puts address.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -200,7 +195,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -216,7 +210,7 @@ end
 
 items.each do |name, autoscalers_scoped_list|
   # TODO: Change code below to process each (name, autoscalers_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(autoscalers_scoped_list)
+  puts String(name << " => " << autoscalers_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -235,7 +229,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -254,7 +247,7 @@ autoscaler = 'my-autoscaler'  # TODO: Update placeholder value.
 response = service.delete_autoscaler(project, zone, autoscaler)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -272,7 +265,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -291,7 +283,7 @@ autoscaler = 'my-autoscaler'  # TODO: Update placeholder value.
 response = service.get_autoscaler(project, zone, autoscaler)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -309,7 +301,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -328,7 +319,7 @@ request_body = Google::Apis::ComputeV1::Autoscaler.new
 response = service.insert_autoscaler(project, zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -346,7 +337,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -365,7 +355,7 @@ end
 
 items.each do |autoscaler|
   # TODO: Change code below to process each `autoscaler` resource:
-  puts JSON.pretty_generate(autoscaler)
+  puts autoscaler.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -384,7 +374,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -407,7 +396,7 @@ request_body = Google::Apis::ComputeV1::Autoscaler.new
 response = service.patch_autoscaler(project, zone, autoscaler, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -425,7 +414,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -445,7 +433,7 @@ request_body = Google::Apis::ComputeV1::Autoscaler.new
 response = service.update_autoscaler(project, zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -463,7 +451,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -479,7 +466,7 @@ end
 
 items.each do |name, backend_services_scoped_list|
   # TODO: Change code below to process each (name, backend_services_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(backend_services_scoped_list)
+  puts String(name << " => " << backend_services_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -498,7 +485,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -514,7 +500,7 @@ backend_service = 'my-backend-service'  # TODO: Update placeholder value.
 response = service.delete_backend_service(project, backend_service)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -532,7 +518,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -548,7 +533,7 @@ backend_service = 'my-backend-service'  # TODO: Update placeholder value.
 response = service.get_backend_service(project, backend_service)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -566,7 +551,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -584,7 +568,7 @@ request_body = Google::Apis::ComputeV1::ResourceGroupReference.new
 response = service.get_backend_service_health(project, backend_service, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -602,7 +586,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -618,7 +601,7 @@ request_body = Google::Apis::ComputeV1::BackendService.new
 response = service.insert_backend_service(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -636,7 +619,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -652,7 +634,7 @@ end
 
 items.each do |backend_service|
   # TODO: Change code below to process each `backend_service` resource:
-  puts JSON.pretty_generate(backend_service)
+  puts backend_service.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -671,7 +653,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -691,7 +672,7 @@ request_body = Google::Apis::ComputeV1::BackendService.new
 response = service.patch_backend_service(project, backend_service, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -709,7 +690,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -729,7 +709,7 @@ request_body = Google::Apis::ComputeV1::BackendService.new
 response = service.update_backend_service(project, backend_service, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -747,7 +727,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -763,7 +742,7 @@ end
 
 items.each do |name, disk_types_scoped_list|
   # TODO: Change code below to process each (name, disk_types_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(disk_types_scoped_list)
+  puts String(name << " => " << disk_types_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -782,7 +761,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -801,7 +779,7 @@ disk_type = 'my-disk-type'  # TODO: Update placeholder value.
 response = service.get_disk_type(project, zone, disk_type)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -819,7 +797,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -838,7 +815,7 @@ end
 
 items.each do |disk_type|
   # TODO: Change code below to process each `disk_type` resource:
-  puts JSON.pretty_generate(disk_type)
+  puts disk_type.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -857,7 +834,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -873,7 +849,7 @@ end
 
 items.each do |name, disks_scoped_list|
   # TODO: Change code below to process each (name, disks_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(disks_scoped_list)
+  puts String(name << " => " << disks_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -892,7 +868,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -914,7 +889,7 @@ request_body = Google::Apis::ComputeV1::Snapshot.new
 response = service.create_disk_snapshot(project, zone, disk, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -932,7 +907,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -951,7 +925,7 @@ disk = 'my-disk'  # TODO: Update placeholder value.
 response = service.delete_disk(project, zone, disk)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -969,7 +943,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -988,7 +961,7 @@ disk = 'my-disk'  # TODO: Update placeholder value.
 response = service.get_disk(project, zone, disk)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1006,7 +979,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1025,7 +997,7 @@ request_body = Google::Apis::ComputeV1::Disk.new
 response = service.insert_disk(project, zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1043,7 +1015,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1062,7 +1033,7 @@ end
 
 items.each do |disk|
   # TODO: Change code below to process each `disk` resource:
-  puts JSON.pretty_generate(disk)
+  puts disk.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1081,7 +1052,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1103,7 +1073,7 @@ request_body = Google::Apis::ComputeV1::DisksResizeRequest.new
 response = service.resize_disk(project, zone, disk, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1121,7 +1091,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1137,7 +1106,7 @@ firewall = 'my-firewall'  # TODO: Update placeholder value.
 response = service.delete_firewall(project, firewall)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1155,7 +1124,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1171,7 +1139,7 @@ firewall = 'my-firewall'  # TODO: Update placeholder value.
 response = service.get_firewall(project, firewall)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1189,7 +1157,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1205,7 +1172,7 @@ request_body = Google::Apis::ComputeV1::Firewall.new
 response = service.insert_firewall(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1223,7 +1190,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1239,7 +1205,7 @@ end
 
 items.each do |firewall|
   # TODO: Change code below to process each `firewall` resource:
-  puts JSON.pretty_generate(firewall)
+  puts firewall.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1258,7 +1224,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1278,7 +1243,7 @@ request_body = Google::Apis::ComputeV1::Firewall.new
 response = service.patch_firewall(project, firewall, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1296,7 +1261,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1316,7 +1280,7 @@ request_body = Google::Apis::ComputeV1::Firewall.new
 response = service.update_firewall(project, firewall, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1334,7 +1298,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1350,7 +1313,7 @@ end
 
 items.each do |name, forwarding_rules_scoped_list|
   # TODO: Change code below to process each (name, forwarding_rules_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(forwarding_rules_scoped_list)
+  puts String(name << " => " << forwarding_rules_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1369,7 +1332,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1388,7 +1350,7 @@ forwarding_rule = 'my-forwarding-rule'  # TODO: Update placeholder value.
 response = service.delete_forwarding_rule(project, region, forwarding_rule)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1406,7 +1368,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1425,7 +1386,7 @@ forwarding_rule = 'my-forwarding-rule'  # TODO: Update placeholder value.
 response = service.get_forwarding_rule(project, region, forwarding_rule)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1443,7 +1404,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1462,7 +1422,7 @@ request_body = Google::Apis::ComputeV1::ForwardingRule.new
 response = service.insert_forwarding_rule(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1480,7 +1440,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1499,7 +1458,7 @@ end
 
 items.each do |forwarding_rule|
   # TODO: Change code below to process each `forwarding_rule` resource:
-  puts JSON.pretty_generate(forwarding_rule)
+  puts forwarding_rule.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1518,7 +1477,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1540,7 +1498,7 @@ request_body = Google::Apis::ComputeV1::TargetReference.new
 response = service.set_forwarding_rule_target(project, region, forwarding_rule, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1558,7 +1516,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1574,7 +1531,7 @@ address = 'my-address'  # TODO: Update placeholder value.
 response = service.delete_global_address(project, address)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1592,7 +1549,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1608,7 +1564,7 @@ address = 'my-address'  # TODO: Update placeholder value.
 response = service.get_global_address(project, address)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1626,7 +1582,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1642,7 +1597,7 @@ request_body = Google::Apis::ComputeV1::Address.new
 response = service.insert_global_address(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1660,7 +1615,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1676,7 +1630,7 @@ end
 
 items.each do |address|
   # TODO: Change code below to process each `address` resource:
-  puts JSON.pretty_generate(address)
+  puts address.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1695,7 +1649,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1711,7 +1664,7 @@ forwarding_rule = 'my-forwarding-rule'  # TODO: Update placeholder value.
 response = service.delete_global_forwarding_rule(project, forwarding_rule)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1729,7 +1682,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1745,7 +1697,7 @@ forwarding_rule = 'my-forwarding-rule'  # TODO: Update placeholder value.
 response = service.get_global_forwarding_rule(project, forwarding_rule)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1763,7 +1715,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1779,7 +1730,7 @@ request_body = Google::Apis::ComputeV1::ForwardingRule.new
 response = service.insert_global_forwarding_rule(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1797,7 +1748,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1813,7 +1763,7 @@ end
 
 items.each do |forwarding_rule|
   # TODO: Change code below to process each `forwarding_rule` resource:
-  puts JSON.pretty_generate(forwarding_rule)
+  puts forwarding_rule.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1832,7 +1782,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1851,7 +1800,7 @@ request_body = Google::Apis::ComputeV1::TargetReference.new
 response = service.set_global_forwarding_rule_target(project, forwarding_rule, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1869,7 +1818,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1885,7 +1833,7 @@ end
 
 items.each do |name, operations_scoped_list|
   # TODO: Change code below to process each (name, operations_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(operations_scoped_list)
+  puts String(name << " => " << operations_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1934,7 +1882,6 @@ service.delete_global_operation(project, operation)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1950,7 +1897,7 @@ operation = 'my-operation'  # TODO: Update placeholder value.
 response = service.get_global_operation(project, operation)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -1968,7 +1915,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -1984,7 +1930,7 @@ end
 
 items.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2003,7 +1949,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2019,7 +1964,7 @@ health_check = 'my-health-check'  # TODO: Update placeholder value.
 response = service.delete_health_check(project, health_check)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2037,7 +1982,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2053,7 +1997,7 @@ health_check = 'my-health-check'  # TODO: Update placeholder value.
 response = service.get_health_check(project, health_check)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2071,7 +2015,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2087,7 +2030,7 @@ request_body = Google::Apis::ComputeV1::HealthCheck.new
 response = service.insert_health_check(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2105,7 +2048,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2121,7 +2063,7 @@ end
 
 items.each do |health_check|
   # TODO: Change code below to process each `health_check` resource:
-  puts JSON.pretty_generate(health_check)
+  puts health_check.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2140,7 +2082,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2160,7 +2101,7 @@ request_body = Google::Apis::ComputeV1::HealthCheck.new
 response = service.patch_health_check(project, health_check, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2178,7 +2119,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2198,7 +2138,7 @@ request_body = Google::Apis::ComputeV1::HealthCheck.new
 response = service.update_health_check(project, health_check, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2216,7 +2156,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2232,7 +2171,7 @@ http_health_check = 'my-http-health-check'  # TODO: Update placeholder value.
 response = service.delete_http_health_check(project, http_health_check)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2250,7 +2189,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2266,7 +2204,7 @@ http_health_check = 'my-http-health-check'  # TODO: Update placeholder value.
 response = service.get_http_health_check(project, http_health_check)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2284,7 +2222,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2300,7 +2237,7 @@ request_body = Google::Apis::ComputeV1::HttpHealthCheck.new
 response = service.insert_http_health_check(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2318,7 +2255,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2334,7 +2270,7 @@ end
 
 items.each do |http_health_check|
   # TODO: Change code below to process each `http_health_check` resource:
-  puts JSON.pretty_generate(http_health_check)
+  puts http_health_check.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2353,7 +2289,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2373,7 +2308,7 @@ request_body = Google::Apis::ComputeV1::HttpHealthCheck.new
 response = service.patch_http_health_check(project, http_health_check, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2391,7 +2326,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2411,7 +2345,7 @@ request_body = Google::Apis::ComputeV1::HttpHealthCheck.new
 response = service.update_http_health_check(project, http_health_check, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2429,7 +2363,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2445,7 +2378,7 @@ https_health_check = 'my-https-health-check'  # TODO: Update placeholder value.
 response = service.delete_https_health_check(project, https_health_check)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2463,7 +2396,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2479,7 +2411,7 @@ https_health_check = 'my-https-health-check'  # TODO: Update placeholder value.
 response = service.get_https_health_check(project, https_health_check)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2497,7 +2429,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2513,7 +2444,7 @@ request_body = Google::Apis::ComputeV1::HttpsHealthCheck.new
 response = service.insert_https_health_check(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2531,7 +2462,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2547,7 +2477,7 @@ end
 
 items.each do |https_health_check|
   # TODO: Change code below to process each `https_health_check` resource:
-  puts JSON.pretty_generate(https_health_check)
+  puts https_health_check.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2566,7 +2496,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2586,7 +2515,7 @@ request_body = Google::Apis::ComputeV1::HttpsHealthCheck.new
 response = service.patch_https_health_check(project, https_health_check, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2604,7 +2533,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2624,7 +2552,7 @@ request_body = Google::Apis::ComputeV1::HttpsHealthCheck.new
 response = service.update_https_health_check(project, https_health_check, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2642,7 +2570,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2658,7 +2585,7 @@ image = 'my-image'  # TODO: Update placeholder value.
 response = service.delete_image(project, image)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2676,7 +2603,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2695,7 +2621,7 @@ request_body = Google::Apis::ComputeV1::DeprecationStatus.new
 response = service.deprecate_image(project, image, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2713,7 +2639,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2729,7 +2654,7 @@ image = 'my-image'  # TODO: Update placeholder value.
 response = service.get_image(project, image)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2747,7 +2672,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2763,7 +2687,7 @@ family = 'my-family'  # TODO: Update placeholder value.
 response = service.get_image_from_family(project, family)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2781,7 +2705,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2797,7 +2720,7 @@ request_body = Google::Apis::ComputeV1::Image.new
 response = service.insert_image(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2815,7 +2738,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2831,7 +2753,7 @@ end
 
 items.each do |image|
   # TODO: Change code below to process each `image` resource:
-  puts JSON.pretty_generate(image)
+  puts image.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2850,7 +2772,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2872,7 +2793,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupManagersAbandonInstancesReq
 response = service.abandon_instance_group_manager_instances(project, zone, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2890,7 +2811,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2906,7 +2826,7 @@ end
 
 items.each do |name, instance_group_managers_scoped_list|
   # TODO: Change code below to process each (name, instance_group_managers_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(instance_group_managers_scoped_list)
+  puts String(name << " => " << instance_group_managers_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2925,7 +2845,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2944,7 +2863,7 @@ instance_group_manager = 'my-instance-group-manager'  # TODO: Update placeholder
 response = service.delete_instance_group_manager(project, zone, instance_group_manager)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -2962,7 +2881,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -2984,7 +2902,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupManagersDeleteInstancesRequ
 response = service.delete_instance_group_manager_instances(project, zone, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3002,7 +2920,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3021,7 +2938,7 @@ instance_group_manager = 'my-instance-group-manager'  # TODO: Update placeholder
 response = service.get_instance_group_manager(project, zone, instance_group_manager)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3039,7 +2956,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3058,7 +2974,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupManager.new
 response = service.insert_instance_group_manager(project, zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3076,7 +2992,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3095,7 +3010,7 @@ end
 
 items.each do |instance_group_manager|
   # TODO: Change code below to process each `instance_group_manager` resource:
-  puts JSON.pretty_generate(instance_group_manager)
+  puts instance_group_manager.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3114,7 +3029,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3133,7 +3047,7 @@ instance_group_manager = 'my-instance-group-manager'  # TODO: Update placeholder
 response = service.list_instance_group_manager_managed_instances(project, zone, instance_group_manager)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3151,7 +3065,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3173,7 +3086,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupManagersRecreateInstancesRe
 response = service.recreate_instance_group_manager_instances(project, zone, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3191,7 +3104,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3215,7 +3127,7 @@ size = 0  # TODO: Update placeholder value.
 response = service.resize_instance_group_manager(project, zone, instance_group_manager, size)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3233,7 +3145,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3255,7 +3166,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupManagersSetInstanceTemplate
 response = service.set_instance_group_manager_instance_template(project, zone, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3273,7 +3184,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3295,7 +3205,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupManagersSetTargetPoolsReque
 response = service.set_instance_group_manager_target_pools(project, zone, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3313,7 +3223,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3335,7 +3244,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupsAddInstancesRequest.new
 response = service.add_instance_group_instances(project, zone, instance_group, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3353,7 +3262,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3369,7 +3277,7 @@ end
 
 items.each do |name, instance_groups_scoped_list|
   # TODO: Change code below to process each (name, instance_groups_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(instance_groups_scoped_list)
+  puts String(name << " => " << instance_groups_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3388,7 +3296,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3407,7 +3314,7 @@ instance_group = 'my-instance-group'  # TODO: Update placeholder value.
 response = service.delete_instance_group(project, zone, instance_group)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3425,7 +3332,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3444,7 +3350,7 @@ instance_group = 'my-instance-group'  # TODO: Update placeholder value.
 response = service.get_instance_group(project, zone, instance_group)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3462,7 +3368,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3481,7 +3386,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroup.new
 response = service.insert_instance_group(project, zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3499,7 +3404,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3518,7 +3422,7 @@ end
 
 items.each do |instance_group|
   # TODO: Change code below to process each `instance_group` resource:
-  puts JSON.pretty_generate(instance_group)
+  puts instance_group.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3537,7 +3441,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3562,7 +3465,7 @@ end
 
 items.each do |instance_with_named_ports|
   # TODO: Change code below to process each `instance_with_named_ports` resource:
-  puts JSON.pretty_generate(instance_with_named_ports)
+  puts instance_with_named_ports.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3581,7 +3484,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3603,7 +3505,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupsRemoveInstancesRequest.new
 response = service.remove_instance_group_instances(project, zone, instance_group, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3621,7 +3523,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3643,7 +3544,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupsSetNamedPortsRequest.new
 response = service.set_instance_group_named_ports(project, zone, instance_group, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3661,7 +3562,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3677,7 +3577,7 @@ instance_template = 'my-instance-template'  # TODO: Update placeholder value.
 response = service.delete_instance_template(project, instance_template)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3695,7 +3595,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3711,7 +3610,7 @@ instance_template = 'my-instance-template'  # TODO: Update placeholder value.
 response = service.get_instance_template(project, instance_template)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3729,7 +3628,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3745,7 +3643,7 @@ request_body = Google::Apis::ComputeV1::InstanceTemplate.new
 response = service.insert_instance_template(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3763,7 +3661,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3779,7 +3676,7 @@ end
 
 items.each do |instance_template|
   # TODO: Change code below to process each `instance_template` resource:
-  puts JSON.pretty_generate(instance_template)
+  puts instance_template.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3798,7 +3695,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3823,7 +3719,7 @@ request_body = Google::Apis::ComputeV1::AccessConfig.new
 response = service.add_instance_access_config(project, zone, instance, network_interface, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3841,7 +3737,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3857,7 +3752,7 @@ end
 
 items.each do |name, instances_scoped_list|
   # TODO: Change code below to process each (name, instances_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(instances_scoped_list)
+  puts String(name << " => " << instances_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3876,7 +3771,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3898,7 +3792,7 @@ request_body = Google::Apis::ComputeV1::AttachedDisk.new
 response = service.attach_disk(project, zone, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3916,7 +3810,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3935,7 +3828,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.delete_instance(project, zone, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3953,7 +3846,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -3978,7 +3870,7 @@ network_interface = ''  # TODO: Update placeholder value.
 response = service.delete_instance_access_config(project, zone, instance, access_config, network_interface)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -3996,7 +3888,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4018,7 +3909,7 @@ device_name = ''  # TODO: Update placeholder value.
 response = service.detach_disk(project, zone, instance, device_name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4036,7 +3927,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4055,7 +3945,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.get_instance(project, zone, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4073,7 +3963,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4092,7 +3981,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.get_instance_serial_port_output(project, zone, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4110,7 +3999,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4129,7 +4017,7 @@ request_body = Google::Apis::ComputeV1::Instance.new
 response = service.insert_instance(project, zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4147,7 +4035,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4166,7 +4053,7 @@ end
 
 items.each do |instance|
   # TODO: Change code below to process each `instance` resource:
-  puts JSON.pretty_generate(instance)
+  puts instance.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4185,7 +4072,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4204,7 +4090,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.reset_instance(project, zone, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4222,7 +4108,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4247,7 +4132,7 @@ device_name = ''  # TODO: Update placeholder value.
 response = service.set_disk_auto_delete(project, zone, instance, auto_delete, device_name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4265,7 +4150,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4287,7 +4171,7 @@ request_body = Google::Apis::ComputeV1::InstancesSetMachineTypeRequest.new
 response = service.set_instance_machine_type(project, zone, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4305,7 +4189,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4327,7 +4210,7 @@ request_body = Google::Apis::ComputeV1::Metadata.new
 response = service.set_instance_metadata(project, zone, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4345,7 +4228,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4367,7 +4249,7 @@ request_body = Google::Apis::ComputeV1::Scheduling.new
 response = service.set_instance_scheduling(project, zone, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4385,7 +4267,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4407,7 +4288,7 @@ request_body = Google::Apis::ComputeV1::InstancesSetServiceAccountRequest.new
 response = service.set_instance_service_account(project, zone, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4425,7 +4306,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4447,7 +4327,7 @@ request_body = Google::Apis::ComputeV1::Tags.new
 response = service.set_instance_tags(project, zone, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4465,7 +4345,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4484,7 +4363,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.start_instance(project, zone, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4502,7 +4381,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4524,7 +4402,7 @@ request_body = Google::Apis::ComputeV1::InstancesStartWithEncryptionKeyRequest.n
 response = service.start_instance_with_encryption_key(project, zone, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4542,7 +4420,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4561,7 +4438,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.stop_instance(project, zone, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4579,7 +4456,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4595,7 +4471,7 @@ license = 'my-license'  # TODO: Update placeholder value.
 response = service.get_license(project, license)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4613,7 +4489,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4629,7 +4504,7 @@ end
 
 items.each do |name, machine_types_scoped_list|
   # TODO: Change code below to process each (name, machine_types_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(machine_types_scoped_list)
+  puts String(name << " => " << machine_types_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4648,7 +4523,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4667,7 +4541,7 @@ machine_type = 'my-machine-type'  # TODO: Update placeholder value.
 response = service.get_machine_type(project, zone, machine_type)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4685,7 +4559,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4704,7 +4577,7 @@ end
 
 items.each do |machine_type|
   # TODO: Change code below to process each `machine_type` resource:
-  puts JSON.pretty_generate(machine_type)
+  puts machine_type.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4723,7 +4596,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4739,7 +4611,7 @@ network = 'my-network'  # TODO: Update placeholder value.
 response = service.delete_network(project, network)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4757,7 +4629,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4773,7 +4644,7 @@ network = 'my-network'  # TODO: Update placeholder value.
 response = service.get_network(project, network)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4791,7 +4662,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4807,7 +4677,7 @@ request_body = Google::Apis::ComputeV1::Network.new
 response = service.insert_network(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4825,7 +4695,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4841,7 +4710,7 @@ end
 
 items.each do |network|
   # TODO: Change code below to process each `network` resource:
-  puts JSON.pretty_generate(network)
+  puts network.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4860,7 +4729,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4876,7 +4744,7 @@ network = 'my-network'  # TODO: Update placeholder value.
 response = service.switch_network_to_custom_mode(project, network)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4894,7 +4762,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4907,7 +4774,7 @@ project = 'my-project'  # TODO: Update placeholder value.
 response = service.get_project(project)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4925,7 +4792,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4941,7 +4807,7 @@ request_body = Google::Apis::ComputeV1::MoveDiskRequest.new
 response = service.move_disk(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4959,7 +4825,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -4975,7 +4840,7 @@ request_body = Google::Apis::ComputeV1::MoveInstanceRequest.new
 response = service.move_instance(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -4993,7 +4858,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5009,7 +4873,7 @@ request_body = Google::Apis::ComputeV1::Metadata.new
 response = service.set_common_instance_metadata(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5027,7 +4891,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5043,7 +4906,7 @@ request_body = Google::Apis::ComputeV1::UsageExportLocation.new
 response = service.set_usage_export_bucket(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5061,7 +4924,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5080,7 +4942,7 @@ autoscaler = 'my-autoscaler'  # TODO: Update placeholder value.
 response = service.delete_region_autoscaler(project, region, autoscaler)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5098,7 +4960,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5117,7 +4978,7 @@ autoscaler = 'my-autoscaler'  # TODO: Update placeholder value.
 response = service.get_region_autoscaler(project, region, autoscaler)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5135,7 +4996,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5154,7 +5014,7 @@ request_body = Google::Apis::ComputeV1::Autoscaler.new
 response = service.insert_region_autoscaler(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5172,7 +5032,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5191,7 +5050,7 @@ end
 
 items.each do |autoscaler|
   # TODO: Change code below to process each `autoscaler` resource:
-  puts JSON.pretty_generate(autoscaler)
+  puts autoscaler.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -5210,7 +5069,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5233,7 +5091,7 @@ request_body = Google::Apis::ComputeV1::Autoscaler.new
 response = service.patch_region_autoscaler(project, region, autoscaler, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5251,7 +5109,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5271,7 +5128,7 @@ request_body = Google::Apis::ComputeV1::Autoscaler.new
 response = service.update_region_autoscaler(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5289,7 +5146,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5308,7 +5164,7 @@ backend_service = 'my-backend-service'  # TODO: Update placeholder value.
 response = service.delete_region_backend_service(project, region, backend_service)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5326,7 +5182,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5345,7 +5200,7 @@ backend_service = 'my-backend-service'  # TODO: Update placeholder value.
 response = service.get_region_backend_service(project, region, backend_service)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5363,7 +5218,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5384,7 +5238,7 @@ request_body = Google::Apis::ComputeV1::ResourceGroupReference.new
 response = service.get_region_backend_service_health(project, region, backend_service, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5402,7 +5256,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5421,7 +5274,7 @@ request_body = Google::Apis::ComputeV1::BackendService.new
 response = service.insert_region_backend_service(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5439,7 +5292,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5458,7 +5310,7 @@ end
 
 items.each do |backend_service|
   # TODO: Change code below to process each `backend_service` resource:
-  puts JSON.pretty_generate(backend_service)
+  puts backend_service.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -5477,7 +5329,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5500,7 +5351,7 @@ request_body = Google::Apis::ComputeV1::BackendService.new
 response = service.patch_region_backend_service(project, region, backend_service, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5518,7 +5369,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5541,7 +5391,7 @@ request_body = Google::Apis::ComputeV1::BackendService.new
 response = service.update_region_backend_service(project, region, backend_service, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5559,7 +5409,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5581,7 +5430,7 @@ request_body = Google::Apis::ComputeV1::RegionInstanceGroupManagersAbandonInstan
 response = service.abandon_region_instance_group_manager_instances(project, region, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5599,7 +5448,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5618,7 +5466,7 @@ instance_group_manager = 'my-instance-group-manager'  # TODO: Update placeholder
 response = service.delete_region_instance_group_manager(project, region, instance_group_manager)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5636,7 +5484,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5658,7 +5505,7 @@ request_body = Google::Apis::ComputeV1::RegionInstanceGroupManagersDeleteInstanc
 response = service.delete_region_instance_group_manager_instances(project, region, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5676,7 +5523,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5695,7 +5541,7 @@ instance_group_manager = 'my-instance-group-manager'  # TODO: Update placeholder
 response = service.get_region_instance_group_manager(project, region, instance_group_manager)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5713,7 +5559,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5732,7 +5577,7 @@ request_body = Google::Apis::ComputeV1::InstanceGroupManager.new
 response = service.insert_region_instance_group_manager(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5750,7 +5595,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5769,7 +5613,7 @@ end
 
 items.each do |instance_group_manager|
   # TODO: Change code below to process each `instance_group_manager` resource:
-  puts JSON.pretty_generate(instance_group_manager)
+  puts instance_group_manager.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -5788,7 +5632,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5807,7 +5650,7 @@ instance_group_manager = 'my-instance-group-manager'  # TODO: Update placeholder
 response = service.list_region_instance_group_manager_managed_instances(project, region, instance_group_manager)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5825,7 +5668,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5847,7 +5689,7 @@ request_body = Google::Apis::ComputeV1::RegionInstanceGroupManagersRecreateReque
 response = service.recreate_region_instance_group_manager_instances(project, region, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5865,7 +5707,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5887,7 +5728,7 @@ size = 0  # TODO: Update placeholder value.
 response = service.resize_region_instance_group_manager(project, region, instance_group_manager, size)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5905,7 +5746,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5927,7 +5767,7 @@ request_body = Google::Apis::ComputeV1::RegionInstanceGroupManagersSetTemplateRe
 response = service.set_region_instance_group_manager_instance_template(project, region, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5945,7 +5785,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -5967,7 +5806,7 @@ request_body = Google::Apis::ComputeV1::RegionInstanceGroupManagersSetTargetPool
 response = service.set_region_instance_group_manager_target_pools(project, region, instance_group_manager, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -5985,7 +5824,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6004,7 +5842,7 @@ instance_group = 'my-instance-group'  # TODO: Update placeholder value.
 response = service.get_region_instance_group(project, region, instance_group)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6022,7 +5860,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6041,7 +5878,7 @@ end
 
 items.each do |instance_group|
   # TODO: Change code below to process each `instance_group` resource:
-  puts JSON.pretty_generate(instance_group)
+  puts instance_group.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -6060,7 +5897,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6085,7 +5921,7 @@ end
 
 items.each do |instance_with_named_ports|
   # TODO: Change code below to process each `instance_with_named_ports` resource:
-  puts JSON.pretty_generate(instance_with_named_ports)
+  puts instance_with_named_ports.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -6104,7 +5940,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6126,7 +5961,7 @@ request_body = Google::Apis::ComputeV1::RegionInstanceGroupsSetNamedPortsRequest
 response = service.set_region_instance_group_named_ports(project, region, instance_group, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6177,7 +6012,6 @@ service.delete_region_operation(project, region, operation)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6196,7 +6030,7 @@ operation = 'my-operation'  # TODO: Update placeholder value.
 response = service.get_region_operation(project, region, operation)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6214,7 +6048,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6233,7 +6066,7 @@ end
 
 items.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -6252,7 +6085,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6268,7 +6100,7 @@ region = 'my-region'  # TODO: Update placeholder value.
 response = service.get_region(project, region)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6286,7 +6118,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6302,7 +6133,7 @@ end
 
 items.each do |region|
   # TODO: Change code below to process each `region` resource:
-  puts JSON.pretty_generate(region)
+  puts region.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -6321,7 +6152,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6337,7 +6167,7 @@ end
 
 items.each do |name, routers_scoped_list|
   # TODO: Change code below to process each (name, routers_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(routers_scoped_list)
+  puts String(name << " => " << routers_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -6356,7 +6186,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6375,7 +6204,7 @@ router = 'my-router'  # TODO: Update placeholder value.
 response = service.delete_router(project, region, router)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6393,7 +6222,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6412,7 +6240,7 @@ router = 'my-router'  # TODO: Update placeholder value.
 response = service.get_router(project, region, router)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6430,7 +6258,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6449,7 +6276,7 @@ router = 'my-router'  # TODO: Update placeholder value.
 response = service.get_router_router_status(project, region, router)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6467,7 +6294,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6486,7 +6312,7 @@ request_body = Google::Apis::ComputeV1::Router.new
 response = service.insert_router(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6504,7 +6330,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6523,7 +6348,7 @@ end
 
 items.each do |router|
   # TODO: Change code below to process each `router` resource:
-  puts JSON.pretty_generate(router)
+  puts router.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -6542,7 +6367,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6565,7 +6389,7 @@ request_body = Google::Apis::ComputeV1::Router.new
 response = service.patch_router(project, region, router, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6583,7 +6407,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6605,7 +6428,7 @@ request_body = Google::Apis::ComputeV1::Router.new
 response = service.preview_router(project, region, router, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6623,7 +6446,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6646,7 +6468,7 @@ request_body = Google::Apis::ComputeV1::Router.new
 response = service.update_router(project, region, router, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6664,7 +6486,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6680,7 +6501,7 @@ route = 'my-route'  # TODO: Update placeholder value.
 response = service.delete_route(project, route)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6698,7 +6519,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6714,7 +6534,7 @@ route = 'my-route'  # TODO: Update placeholder value.
 response = service.get_route(project, route)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6732,7 +6552,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6748,7 +6567,7 @@ request_body = Google::Apis::ComputeV1::Route.new
 response = service.insert_route(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6766,7 +6585,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6782,7 +6600,7 @@ end
 
 items.each do |route|
   # TODO: Change code below to process each `route` resource:
-  puts JSON.pretty_generate(route)
+  puts route.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -6801,7 +6619,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6817,7 +6634,7 @@ snapshot = 'my-snapshot'  # TODO: Update placeholder value.
 response = service.delete_snapshot(project, snapshot)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6835,7 +6652,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6851,7 +6667,7 @@ snapshot = 'my-snapshot'  # TODO: Update placeholder value.
 response = service.get_snapshot(project, snapshot)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6869,7 +6685,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6885,7 +6700,7 @@ end
 
 items.each do |snapshot|
   # TODO: Change code below to process each `snapshot` resource:
-  puts JSON.pretty_generate(snapshot)
+  puts snapshot.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -6904,7 +6719,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6920,7 +6734,7 @@ ssl_certificate = 'my-ssl-certificate'  # TODO: Update placeholder value.
 response = service.delete_ssl_certificate(project, ssl_certificate)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6938,7 +6752,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6954,7 +6767,7 @@ ssl_certificate = 'my-ssl-certificate'  # TODO: Update placeholder value.
 response = service.get_ssl_certificate(project, ssl_certificate)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -6972,7 +6785,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -6988,7 +6800,7 @@ request_body = Google::Apis::ComputeV1::SslCertificate.new
 response = service.insert_ssl_certificate(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7006,7 +6818,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7022,7 +6833,7 @@ end
 
 items.each do |ssl_certificate|
   # TODO: Change code below to process each `ssl_certificate` resource:
-  puts JSON.pretty_generate(ssl_certificate)
+  puts ssl_certificate.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -7041,7 +6852,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7057,7 +6867,7 @@ end
 
 items.each do |name, subnetworks_scoped_list|
   # TODO: Change code below to process each (name, subnetworks_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(subnetworks_scoped_list)
+  puts String(name << " => " << subnetworks_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -7076,7 +6886,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7095,7 +6904,7 @@ subnetwork = 'my-subnetwork'  # TODO: Update placeholder value.
 response = service.delete_subnetwork(project, region, subnetwork)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7113,7 +6922,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7135,7 +6943,7 @@ request_body = Google::Apis::ComputeV1::SubnetworksExpandIpCidrRangeRequest.new
 response = service.expand_subnetwork_ip_cidr_range(project, region, subnetwork, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7153,7 +6961,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7172,7 +6979,7 @@ subnetwork = 'my-subnetwork'  # TODO: Update placeholder value.
 response = service.get_subnetwork(project, region, subnetwork)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7190,7 +6997,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7209,7 +7015,7 @@ request_body = Google::Apis::ComputeV1::Subnetwork.new
 response = service.insert_subnetwork(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7227,7 +7033,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7246,7 +7051,7 @@ end
 
 items.each do |subnetwork|
   # TODO: Change code below to process each `subnetwork` resource:
-  puts JSON.pretty_generate(subnetwork)
+  puts subnetwork.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -7265,7 +7070,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7281,7 +7085,7 @@ target_http_proxy = 'my-target-http-proxy'  # TODO: Update placeholder value.
 response = service.delete_target_http_proxy(project, target_http_proxy)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7299,7 +7103,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7315,7 +7118,7 @@ target_http_proxy = 'my-target-http-proxy'  # TODO: Update placeholder value.
 response = service.get_target_http_proxy(project, target_http_proxy)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7333,7 +7136,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7349,7 +7151,7 @@ request_body = Google::Apis::ComputeV1::TargetHttpProxy.new
 response = service.insert_target_http_proxy(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7367,7 +7169,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7383,7 +7184,7 @@ end
 
 items.each do |target_http_proxy|
   # TODO: Change code below to process each `target_http_proxy` resource:
-  puts JSON.pretty_generate(target_http_proxy)
+  puts target_http_proxy.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -7402,7 +7203,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7421,7 +7221,7 @@ request_body = Google::Apis::ComputeV1::UrlMapReference.new
 response = service.set_target_http_proxy_url_map(project, target_http_proxy, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7439,7 +7239,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7455,7 +7254,7 @@ target_https_proxy = 'my-target-https-proxy'  # TODO: Update placeholder value.
 response = service.delete_target_https_proxy(project, target_https_proxy)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7473,7 +7272,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7489,7 +7287,7 @@ target_https_proxy = 'my-target-https-proxy'  # TODO: Update placeholder value.
 response = service.get_target_https_proxy(project, target_https_proxy)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7507,7 +7305,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7523,7 +7320,7 @@ request_body = Google::Apis::ComputeV1::TargetHttpsProxy.new
 response = service.insert_target_https_proxy(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7541,7 +7338,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7557,7 +7353,7 @@ end
 
 items.each do |target_https_proxy|
   # TODO: Change code below to process each `target_https_proxy` resource:
-  puts JSON.pretty_generate(target_https_proxy)
+  puts target_https_proxy.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -7576,7 +7372,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7595,7 +7390,7 @@ request_body = Google::Apis::ComputeV1::TargetHttpsProxiesSetSslCertificatesRequ
 response = service.set_target_https_proxy_ssl_certificates(project, target_https_proxy, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7613,7 +7408,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7632,7 +7426,7 @@ request_body = Google::Apis::ComputeV1::UrlMapReference.new
 response = service.set_target_https_proxy_url_map(project, target_https_proxy, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7650,7 +7444,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7666,7 +7459,7 @@ end
 
 items.each do |name, target_instances_scoped_list|
   # TODO: Change code below to process each (name, target_instances_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(target_instances_scoped_list)
+  puts String(name << " => " << target_instances_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -7685,7 +7478,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7704,7 +7496,7 @@ target_instance = 'my-target-instance'  # TODO: Update placeholder value.
 response = service.delete_target_instance(project, zone, target_instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7722,7 +7514,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7741,7 +7532,7 @@ target_instance = 'my-target-instance'  # TODO: Update placeholder value.
 response = service.get_target_instance(project, zone, target_instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7759,7 +7550,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7778,7 +7568,7 @@ request_body = Google::Apis::ComputeV1::TargetInstance.new
 response = service.insert_target_instance(project, zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7796,7 +7586,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7815,7 +7604,7 @@ end
 
 items.each do |target_instance|
   # TODO: Change code below to process each `target_instance` resource:
-  puts JSON.pretty_generate(target_instance)
+  puts target_instance.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -7834,7 +7623,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7856,7 +7644,7 @@ request_body = Google::Apis::ComputeV1::AddTargetPoolsHealthCheckRequest.new
 response = service.add_target_pool_health_check(project, region, target_pool, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7874,7 +7662,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7896,7 +7683,7 @@ request_body = Google::Apis::ComputeV1::AddTargetPoolsInstanceRequest.new
 response = service.add_target_pool_instance(project, region, target_pool, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7914,7 +7701,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7930,7 +7716,7 @@ end
 
 items.each do |name, target_pools_scoped_list|
   # TODO: Change code below to process each (name, target_pools_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(target_pools_scoped_list)
+  puts String(name << " => " << target_pools_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -7949,7 +7735,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -7968,7 +7753,7 @@ target_pool = 'my-target-pool'  # TODO: Update placeholder value.
 response = service.delete_target_pool(project, region, target_pool)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -7986,7 +7771,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8005,7 +7789,7 @@ target_pool = 'my-target-pool'  # TODO: Update placeholder value.
 response = service.get_target_pool(project, region, target_pool)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8023,7 +7807,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8045,7 +7828,7 @@ request_body = Google::Apis::ComputeV1::InstanceReference.new
 response = service.get_target_pool_health(project, region, target_pool, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8063,7 +7846,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8082,7 +7864,7 @@ request_body = Google::Apis::ComputeV1::TargetPool.new
 response = service.insert_target_pool(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8100,7 +7882,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8119,7 +7900,7 @@ end
 
 items.each do |target_pool|
   # TODO: Change code below to process each `target_pool` resource:
-  puts JSON.pretty_generate(target_pool)
+  puts target_pool.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -8138,7 +7919,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8160,7 +7940,7 @@ request_body = Google::Apis::ComputeV1::RemoveTargetPoolsHealthCheckRequest.new
 response = service.remove_target_pool_health_check(project, region, target_pool, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8178,7 +7958,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8200,7 +7979,7 @@ request_body = Google::Apis::ComputeV1::RemoveTargetPoolsInstanceRequest.new
 response = service.remove_target_pool_instance(project, region, target_pool, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8218,7 +7997,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8240,7 +8018,7 @@ request_body = Google::Apis::ComputeV1::TargetReference.new
 response = service.set_target_pool_backup(project, region, target_pool, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8258,7 +8036,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8274,7 +8051,7 @@ target_ssl_proxy = 'my-target-ssl-proxy'  # TODO: Update placeholder value.
 response = service.delete_target_ssl_proxy(project, target_ssl_proxy)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8292,7 +8069,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8308,7 +8084,7 @@ target_ssl_proxy = 'my-target-ssl-proxy'  # TODO: Update placeholder value.
 response = service.get_target_ssl_proxy(project, target_ssl_proxy)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8326,7 +8102,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8342,7 +8117,7 @@ request_body = Google::Apis::ComputeV1::TargetSslProxy.new
 response = service.insert_target_ssl_proxy(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8360,7 +8135,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8376,7 +8150,7 @@ end
 
 items.each do |target_ssl_proxy|
   # TODO: Change code below to process each `target_ssl_proxy` resource:
-  puts JSON.pretty_generate(target_ssl_proxy)
+  puts target_ssl_proxy.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -8395,7 +8169,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8414,7 +8187,7 @@ request_body = Google::Apis::ComputeV1::TargetSslProxiesSetBackendServiceRequest
 response = service.set_target_ssl_proxy_backend_service(project, target_ssl_proxy, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8432,7 +8205,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8451,7 +8223,7 @@ request_body = Google::Apis::ComputeV1::TargetSslProxiesSetProxyHeaderRequest.ne
 response = service.set_target_ssl_proxy_proxy_header(project, target_ssl_proxy, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8469,7 +8241,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8488,7 +8259,7 @@ request_body = Google::Apis::ComputeV1::TargetSslProxiesSetSslCertificatesReques
 response = service.set_target_ssl_proxy_ssl_certificates(project, target_ssl_proxy, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8506,7 +8277,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8522,7 +8292,7 @@ end
 
 items.each do |name, target_vpn_gateways_scoped_list|
   # TODO: Change code below to process each (name, target_vpn_gateways_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(target_vpn_gateways_scoped_list)
+  puts String(name << " => " << target_vpn_gateways_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -8541,7 +8311,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8560,7 +8329,7 @@ target_vpn_gateway = 'my-target-vpn-gateway'  # TODO: Update placeholder value.
 response = service.delete_target_vpn_gateway(project, region, target_vpn_gateway)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8578,7 +8347,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8597,7 +8365,7 @@ target_vpn_gateway = 'my-target-vpn-gateway'  # TODO: Update placeholder value.
 response = service.get_target_vpn_gateway(project, region, target_vpn_gateway)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8615,7 +8383,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8634,7 +8401,7 @@ request_body = Google::Apis::ComputeV1::TargetVpnGateway.new
 response = service.insert_target_vpn_gateway(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8652,7 +8419,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8671,7 +8437,7 @@ end
 
 items.each do |target_vpn_gateway|
   # TODO: Change code below to process each `target_vpn_gateway` resource:
-  puts JSON.pretty_generate(target_vpn_gateway)
+  puts target_vpn_gateway.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -8690,7 +8456,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8706,7 +8471,7 @@ url_map = 'my-url-map'  # TODO: Update placeholder value.
 response = service.delete_url_map(project, url_map)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8724,7 +8489,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8740,7 +8504,7 @@ url_map = 'my-url-map'  # TODO: Update placeholder value.
 response = service.get_url_map(project, url_map)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8758,7 +8522,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8774,7 +8537,7 @@ request_body = Google::Apis::ComputeV1::UrlMap.new
 response = service.insert_url_map(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8792,7 +8555,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8811,7 +8573,7 @@ request_body = Google::Apis::ComputeV1::CacheInvalidationRule.new
 response = service.invalidate_url_map_cache(project, url_map, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8829,7 +8591,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8845,7 +8606,7 @@ end
 
 items.each do |url_map|
   # TODO: Change code below to process each `url_map` resource:
-  puts JSON.pretty_generate(url_map)
+  puts url_map.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -8864,7 +8625,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8884,7 +8644,7 @@ request_body = Google::Apis::ComputeV1::UrlMap.new
 response = service.patch_url_map(project, url_map, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8902,7 +8662,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8922,7 +8681,7 @@ request_body = Google::Apis::ComputeV1::UrlMap.new
 response = service.update_url_map(project, url_map, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8940,7 +8699,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8959,7 +8717,7 @@ request_body = Google::Apis::ComputeV1::ValidateUrlMapsRequest.new
 response = service.validate_url_map(project, url_map, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -8977,7 +8735,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -8993,7 +8750,7 @@ end
 
 items.each do |name, vpn_tunnels_scoped_list|
   # TODO: Change code below to process each (name, vpn_tunnels_scoped_list) pair:
-  puts String(name << " => " << JSON.pretty_generate(vpn_tunnels_scoped_list)
+  puts String(name << " => " << vpn_tunnels_scoped_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -9012,7 +8769,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -9031,7 +8787,7 @@ vpn_tunnel = 'my-vpn-tunnel'  # TODO: Update placeholder value.
 response = service.delete_vpn_tunnel(project, region, vpn_tunnel)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -9049,7 +8805,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -9068,7 +8823,7 @@ vpn_tunnel = 'my-vpn-tunnel'  # TODO: Update placeholder value.
 response = service.get_vpn_tunnel(project, region, vpn_tunnel)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -9086,7 +8841,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -9105,7 +8859,7 @@ request_body = Google::Apis::ComputeV1::VpnTunnel.new
 response = service.insert_vpn_tunnel(project, region, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -9123,7 +8877,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -9142,7 +8895,7 @@ end
 
 items.each do |vpn_tunnel|
   # TODO: Change code below to process each `vpn_tunnel` resource:
-  puts JSON.pretty_generate(vpn_tunnel)
+  puts vpn_tunnel.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -9194,7 +8947,6 @@ service.delete_zone_operation(project, zone, operation)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -9213,7 +8965,7 @@ operation = 'my-operation'  # TODO: Update placeholder value.
 response = service.get_zone_operation(project, zone, operation)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -9231,7 +8983,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -9250,7 +9001,7 @@ end
 
 items.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -9269,7 +9020,6 @@ end
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -9285,7 +9035,7 @@ zone = 'my-zone'  # TODO: Update placeholder value.
 response = service.get_zone(project, zone)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Compute Engine API
@@ -9303,7 +9053,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/compute_v1'
-require 'json'
 
 service = Google::Apis::ComputeV1::ComputeService.new
 
@@ -9319,5 +9068,5 @@ end
 
 items.each do |zone|
   # TODO: Change code below to process each `zone` resource:
-  puts JSON.pretty_generate(zone)
+  puts zone.to_json
 end
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_container.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_container.v1.json.baseline
index 511f509a33..07dc7e7ae4 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_container.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_container.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -37,7 +36,7 @@ request_body = Google::Apis::ContainerV1::CreateClusterRequest.new
 response = service.create_cluster(project_id, zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -55,7 +54,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -76,7 +74,7 @@ cluster_id = 'my-cluster-id'  # TODO: Update placeholder value.
 response = service.delete_zone_cluster(project_id, zone, cluster_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -94,7 +92,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -115,7 +112,7 @@ cluster_id = 'my-cluster-id'  # TODO: Update placeholder value.
 response = service.get_zone_cluster(project_id, zone, cluster_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -133,7 +130,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -151,7 +147,7 @@ zone = 'my-zone'  # TODO: Update placeholder value.
 response = service.list_zone_clusters(project_id, zone)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -169,7 +165,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -193,7 +188,7 @@ request_body = Google::Apis::ContainerV1::CreateNodePoolRequest.new
 response = service.create_node_pool(project_id, zone, cluster_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -211,7 +206,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -235,7 +229,7 @@ node_pool_id = 'my-node-pool-id'  # TODO: Update placeholder value.
 response = service.delete_project_zone_cluster_node_pool(project_id, zone, cluster_id, node_pool_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -253,7 +247,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -277,7 +270,7 @@ node_pool_id = 'my-node-pool-id'  # TODO: Update placeholder value.
 response = service.get_project_zone_cluster_node_pool(project_id, zone, cluster_id, node_pool_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -295,7 +288,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -316,7 +308,7 @@ cluster_id = 'my-cluster-id'  # TODO: Update placeholder value.
 response = service.list_project_zone_cluster_node_pools(project_id, zone, cluster_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -334,7 +326,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -359,7 +350,7 @@ request_body = Google::Apis::ContainerV1::UpdateClusterRequest.new
 response = service.update_cluster(project_id, zone, cluster_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -377,7 +368,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -395,7 +385,7 @@ zone = 'my-zone'  # TODO: Update placeholder value.
 response = service.get_project_zone_serverconfig(project_id, zone)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -413,7 +403,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -434,7 +423,7 @@ operation_id = 'my-operation-id'  # TODO: Update placeholder value.
 response = service.get_zone_operation(project_id, zone, operation_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Container Engine API
@@ -452,7 +441,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/container_v1'
-require 'json'
 
 service = Google::Apis::ContainerV1::ContainerService.new
 
@@ -470,4 +458,4 @@ zone = 'my-zone'  # TODO: Update placeholder value.
 response = service.list_zone_operations(project_id, zone)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_datastore.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_datastore.v1.json.baseline
index 936c56e240..e657b4d23a 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_datastore.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_datastore.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/datastore_v1'
-require 'json'
 
 service = Google::Apis::DatastoreV1::DatastoreService.new
 
@@ -32,7 +31,7 @@ request_body = Google::Apis::DatastoreV1::AllocateIdsRequest.new
 response = service.allocate_project_ids(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Datastore API
@@ -50,7 +49,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/datastore_v1'
-require 'json'
 
 service = Google::Apis::DatastoreV1::DatastoreService.new
 
@@ -66,7 +64,7 @@ request_body = Google::Apis::DatastoreV1::BeginTransactionRequest.new
 response = service.begin_project_transaction(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Datastore API
@@ -84,7 +82,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/datastore_v1'
-require 'json'
 
 service = Google::Apis::DatastoreV1::DatastoreService.new
 
@@ -100,7 +97,7 @@ request_body = Google::Apis::DatastoreV1::CommitRequest.new
 response = service.commit_project(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Datastore API
@@ -118,7 +115,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/datastore_v1'
-require 'json'
 
 service = Google::Apis::DatastoreV1::DatastoreService.new
 
@@ -134,7 +130,7 @@ request_body = Google::Apis::DatastoreV1::LookupRequest.new
 response = service.lookup_project(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Datastore API
@@ -152,7 +148,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/datastore_v1'
-require 'json'
 
 service = Google::Apis::DatastoreV1::DatastoreService.new
 
@@ -168,7 +163,7 @@ request_body = Google::Apis::DatastoreV1::RollbackRequest.new
 response = service.rollback_project(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Datastore API
@@ -186,7 +181,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/datastore_v1'
-require 'json'
 
 service = Google::Apis::DatastoreV1::DatastoreService.new
 
@@ -202,4 +196,4 @@ request_body = Google::Apis::DatastoreV1::RunQueryRequest.new
 response = service.run_project_query(project_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_deploymentmanager.v2.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_deploymentmanager.v2.json.baseline
index 011bbacffa..1e989238c2 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_deploymentmanager.v2.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_deploymentmanager.v2.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -35,7 +34,7 @@ request_body = Google::Apis::DeploymentmanagerV2::DeploymentsCancelPreviewReques
 response = service.cancel_deployment_preview(project, deployment, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -53,7 +52,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -69,7 +67,7 @@ deployment = 'my-deployment'  # TODO: Update placeholder value.
 response = service.delete_deployment(project, deployment)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -87,7 +85,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -103,7 +100,7 @@ deployment = 'my-deployment'  # TODO: Update placeholder value.
 response = service.get_deployment(project, deployment)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -121,7 +118,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -137,7 +133,7 @@ resource = 'my-resource'  # TODO: Update placeholder value.
 response = service.get_deployment_iam_policy(project, resource)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -155,7 +151,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -171,7 +166,7 @@ request_body = Google::Apis::DeploymentmanagerV2::Deployment.new
 response = service.insert_deployment(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -189,7 +184,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -205,7 +199,7 @@ end
 
 deployments.each do |deployment|
   # TODO: Change code below to process each `deployment` resource:
-  puts JSON.pretty_generate(deployment)
+  puts deployment.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -224,7 +218,6 @@ end
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -244,7 +237,7 @@ request_body = Google::Apis::DeploymentmanagerV2::Deployment.new
 response = service.patch_deployment(project, deployment, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -262,7 +255,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -281,7 +273,7 @@ request_body = Google::Apis::DeploymentmanagerV2::Policy.new
 response = service.set_deployment_iam_policy(project, resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -299,7 +291,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -318,7 +309,7 @@ request_body = Google::Apis::DeploymentmanagerV2::DeploymentsStopRequest.new
 response = service.stop_deployment(project, deployment, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -336,7 +327,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -355,7 +345,7 @@ request_body = Google::Apis::DeploymentmanagerV2::TestPermissionsRequest.new
 response = service.test_deployment_iam_permissions(project, resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -373,7 +363,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -393,7 +382,7 @@ request_body = Google::Apis::DeploymentmanagerV2::Deployment.new
 response = service.update_deployment(project, deployment, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -411,7 +400,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -430,7 +418,7 @@ manifest = 'my-manifest'  # TODO: Update placeholder value.
 response = service.get_manifest(project, deployment, manifest)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -448,7 +436,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -467,7 +454,7 @@ end
 
 manifests.each do |manifest|
   # TODO: Change code below to process each `manifest` resource:
-  puts JSON.pretty_generate(manifest)
+  puts manifest.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -486,7 +473,6 @@ end
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -502,7 +488,7 @@ operation = 'my-operation'  # TODO: Update placeholder value.
 response = service.get_operation(project, operation)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -520,7 +506,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -536,7 +521,7 @@ end
 
 operations.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -555,7 +540,6 @@ end
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -574,7 +558,7 @@ resource = 'my-resource'  # TODO: Update placeholder value.
 response = service.get_resource(project, deployment, resource)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Deployment Manager API
@@ -592,7 +576,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -611,7 +594,7 @@ end
 
 resources.each do |resource|
   # TODO: Change code below to process each `resource` resource:
-  puts JSON.pretty_generate(resource)
+  puts resource.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -630,7 +613,6 @@ end
 
 require 'googleauth'
 require 'google/apis/deploymentmanager_v2'
-require 'json'
 
 service = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
 
@@ -646,5 +628,5 @@ end
 
 types.each do |type|
   # TODO: Change code below to process each `type` resource:
-  puts JSON.pretty_generate(type)
+  puts type.to_json
 end
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_dfareporting.v2.6.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_dfareporting.v2.6.json.baseline
index 63c3a9b1c9..5946bc789e 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_dfareporting.v2.6.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_dfareporting.v2.6.json.baseline
@@ -7,7 +7,6 @@
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -27,7 +26,7 @@ summary_account_id = 0  # TODO: Update placeholder value.
 response = service.get_account_active_ad_summary(profile_id, summary_account_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -36,7 +35,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -56,7 +54,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_account_permission_group(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -65,7 +63,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -82,7 +79,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_account_permission_groups(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -91,7 +88,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -111,7 +107,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_account_permission(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -120,7 +116,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -137,7 +132,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_account_permissions(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -146,7 +141,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -166,7 +160,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_account_user_profile(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -175,7 +169,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -195,7 +188,7 @@ request_body = Google::Apis::DfareportingV2_6::AccountUserProfile.new
 response = service.insert_account_user_profile(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -204,7 +197,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -224,7 +216,7 @@ end
 
 account_user_profiles.each do |account_user_profile|
   # TODO: Change code below to process each `account_user_profile` resource:
-  puts JSON.pretty_generate(account_user_profile)
+  puts account_user_profile.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -234,7 +226,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -258,7 +249,7 @@ request_body = Google::Apis::DfareportingV2_6::AccountUserProfile.new
 response = service.patch_account_user_profile(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -267,7 +258,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -288,7 +278,7 @@ request_body = Google::Apis::DfareportingV2_6::AccountUserProfile.new
 response = service.update_account_user_profile(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -297,7 +287,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -317,7 +306,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_account(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -326,7 +315,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -346,7 +334,7 @@ end
 
 accounts.each do |account|
   # TODO: Change code below to process each `account` resource:
-  puts JSON.pretty_generate(account)
+  puts account.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -356,7 +344,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -380,7 +367,7 @@ request_body = Google::Apis::DfareportingV2_6::Account.new
 response = service.patch_account(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -389,7 +376,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -410,7 +396,7 @@ request_body = Google::Apis::DfareportingV2_6::Account.new
 response = service.update_account(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -419,7 +405,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -439,7 +424,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_ad(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -448,7 +433,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -468,7 +452,7 @@ request_body = Google::Apis::DfareportingV2_6::Ad.new
 response = service.insert_ad(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -477,7 +461,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -497,7 +480,7 @@ end
 
 ads.each do |ad|
   # TODO: Change code below to process each `ad` resource:
-  puts JSON.pretty_generate(ad)
+  puts ad.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -507,7 +490,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -531,7 +513,7 @@ request_body = Google::Apis::DfareportingV2_6::Ad.new
 response = service.patch_ad(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -540,7 +522,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -561,7 +542,7 @@ request_body = Google::Apis::DfareportingV2_6::Ad.new
 response = service.update_ad(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -595,7 +576,6 @@ service.delete_advertiser_group(profile_id, id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -615,7 +595,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_advertiser_group(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -624,7 +604,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -644,7 +623,7 @@ request_body = Google::Apis::DfareportingV2_6::AdvertiserGroup.new
 response = service.insert_advertiser_group(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -653,7 +632,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -673,7 +651,7 @@ end
 
 advertiser_groups.each do |advertiser_group|
   # TODO: Change code below to process each `advertiser_group` resource:
-  puts JSON.pretty_generate(advertiser_group)
+  puts advertiser_group.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -683,7 +661,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -707,7 +684,7 @@ request_body = Google::Apis::DfareportingV2_6::AdvertiserGroup.new
 response = service.patch_advertiser_group(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -716,7 +693,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -737,7 +713,7 @@ request_body = Google::Apis::DfareportingV2_6::AdvertiserGroup.new
 response = service.update_advertiser_group(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -746,7 +722,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -766,7 +741,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_advertiser(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -775,7 +750,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -795,7 +769,7 @@ request_body = Google::Apis::DfareportingV2_6::Advertiser.new
 response = service.insert_advertiser(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -804,7 +778,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -824,7 +797,7 @@ end
 
 advertisers.each do |advertiser|
   # TODO: Change code below to process each `advertiser` resource:
-  puts JSON.pretty_generate(advertiser)
+  puts advertiser.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -834,7 +807,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -858,7 +830,7 @@ request_body = Google::Apis::DfareportingV2_6::Advertiser.new
 response = service.patch_advertiser(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -867,7 +839,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -888,7 +859,7 @@ request_body = Google::Apis::DfareportingV2_6::Advertiser.new
 response = service.update_advertiser(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -897,7 +868,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -914,7 +884,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_browsers(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -923,7 +893,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -946,7 +915,7 @@ request_body = Google::Apis::DfareportingV2_6::CampaignCreativeAssociation.new
 response = service.insert_campaign_creative_association(profile_id, campaign_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -955,7 +924,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -978,7 +946,7 @@ end
 
 campaign_creative_associations.each do |campaign_creative_association|
   # TODO: Change code below to process each `campaign_creative_association` resource:
-  puts JSON.pretty_generate(campaign_creative_association)
+  puts campaign_creative_association.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -988,7 +956,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1008,7 +975,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_campaign(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1017,7 +984,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1043,7 +1009,7 @@ request_body = Google::Apis::DfareportingV2_6::Campaign.new
 response = service.insert_campaign(profile_id, default_landing_page_name, default_landing_page_url, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1052,7 +1018,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1072,7 +1037,7 @@ end
 
 campaigns.each do |campaign|
   # TODO: Change code below to process each `campaign` resource:
-  puts JSON.pretty_generate(campaign)
+  puts campaign.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1082,7 +1047,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1106,7 +1070,7 @@ request_body = Google::Apis::DfareportingV2_6::Campaign.new
 response = service.patch_campaign(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1115,7 +1079,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1136,7 +1099,7 @@ request_body = Google::Apis::DfareportingV2_6::Campaign.new
 response = service.update_campaign(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1145,7 +1108,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1165,7 +1127,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_change_log(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1174,7 +1136,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1194,7 +1155,7 @@ end
 
 change_logs.each do |change_log|
   # TODO: Change code below to process each `change_log` resource:
-  puts JSON.pretty_generate(change_log)
+  puts change_log.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1204,7 +1165,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1221,7 +1181,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_cities(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1230,7 +1190,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1250,7 +1209,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_connection_type(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1259,7 +1218,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1276,7 +1234,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_connection_types(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1310,7 +1268,6 @@ service.delete_content_category(profile_id, id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1330,7 +1287,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_content_category(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1339,7 +1296,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1359,7 +1315,7 @@ request_body = Google::Apis::DfareportingV2_6::ContentCategory.new
 response = service.insert_content_category(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1368,7 +1324,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1388,7 +1343,7 @@ end
 
 content_categories.each do |content_category|
   # TODO: Change code below to process each `content_category` resource:
-  puts JSON.pretty_generate(content_category)
+  puts content_category.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1398,7 +1353,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1422,7 +1376,7 @@ request_body = Google::Apis::DfareportingV2_6::ContentCategory.new
 response = service.patch_content_category(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1431,7 +1385,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1452,7 +1405,7 @@ request_body = Google::Apis::DfareportingV2_6::ContentCategory.new
 response = service.update_content_category(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1461,7 +1414,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1481,7 +1433,7 @@ request_body = Google::Apis::DfareportingV2_6::ConversionsBatchInsertRequest.new
 response = service.batchinsert_conversion(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1490,7 +1442,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1510,7 +1461,7 @@ dart_id = 0  # TODO: Update placeholder value.
 response = service.get_country(profile_id, dart_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1519,7 +1470,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1536,7 +1486,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_countries(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1545,7 +1495,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1572,7 +1521,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeAssetMetadata.new
 response = service.insert_creative_asset(profile_id, advertiser_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1609,7 +1558,6 @@ service.delete_creative_field_value(profile_id, creative_field_id, id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1632,7 +1580,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_creative_field_value(profile_id, creative_field_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1641,7 +1589,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1664,7 +1611,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeFieldValue.new
 response = service.insert_creative_field_value(profile_id, creative_field_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1673,7 +1620,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1696,7 +1642,7 @@ end
 
 creative_field_values.each do |creative_field_value|
   # TODO: Change code below to process each `creative_field_value` resource:
-  puts JSON.pretty_generate(creative_field_value)
+  puts creative_field_value.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1706,7 +1652,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1733,7 +1678,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeFieldValue.new
 response = service.patch_creative_field_value(profile_id, creative_field_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1742,7 +1687,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1766,7 +1710,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeFieldValue.new
 response = service.update_creative_field_value(profile_id, creative_field_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1800,7 +1744,6 @@ service.delete_creative_field(profile_id, id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1820,7 +1763,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_creative_field(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1829,7 +1772,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1849,7 +1791,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeField.new
 response = service.insert_creative_field(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1858,7 +1800,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1878,7 +1819,7 @@ end
 
 creative_fields.each do |creative_field|
   # TODO: Change code below to process each `creative_field` resource:
-  puts JSON.pretty_generate(creative_field)
+  puts creative_field.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1888,7 +1829,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1912,7 +1852,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeField.new
 response = service.patch_creative_field(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1921,7 +1861,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1942,7 +1881,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeField.new
 response = service.update_creative_field(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1951,7 +1890,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -1971,7 +1909,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_creative_group(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -1980,7 +1918,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2000,7 +1937,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeGroup.new
 response = service.insert_creative_group(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2009,7 +1946,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2029,7 +1965,7 @@ end
 
 creative_groups.each do |creative_group|
   # TODO: Change code below to process each `creative_group` resource:
-  puts JSON.pretty_generate(creative_group)
+  puts creative_group.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2039,7 +1975,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2063,7 +1998,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeGroup.new
 response = service.patch_creative_group(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2072,7 +2007,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2093,7 +2027,7 @@ request_body = Google::Apis::DfareportingV2_6::CreativeGroup.new
 response = service.update_creative_group(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2102,7 +2036,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2122,7 +2055,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_creative(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2131,7 +2064,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2151,7 +2083,7 @@ request_body = Google::Apis::DfareportingV2_6::Creative.new
 response = service.insert_creative(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2160,7 +2092,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2180,7 +2111,7 @@ end
 
 creatives.each do |creative|
   # TODO: Change code below to process each `creative` resource:
-  puts JSON.pretty_generate(creative)
+  puts creative.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2190,7 +2121,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2214,7 +2144,7 @@ request_body = Google::Apis::DfareportingV2_6::Creative.new
 response = service.patch_creative(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2223,7 +2153,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2244,7 +2173,7 @@ request_body = Google::Apis::DfareportingV2_6::Creative.new
 response = service.update_creative(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2253,7 +2182,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2276,7 +2204,7 @@ end
 
 items.each do |dimension_value|
   # TODO: Change code below to process each `dimension_value` resource:
-  puts JSON.pretty_generate(dimension_value)
+  puts dimension_value.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2286,7 +2214,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2306,7 +2233,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_directory_site_contact(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2315,7 +2242,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2335,7 +2261,7 @@ end
 
 directory_site_contacts.each do |directory_site_contact|
   # TODO: Change code below to process each `directory_site_contact` resource:
-  puts JSON.pretty_generate(directory_site_contact)
+  puts directory_site_contact.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2345,7 +2271,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2365,7 +2290,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_directory_site(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2374,7 +2299,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2394,7 +2318,7 @@ request_body = Google::Apis::DfareportingV2_6::DirectorySite.new
 response = service.insert_directory_site(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2403,7 +2327,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2423,7 +2346,7 @@ end
 
 directory_sites.each do |directory_site|
   # TODO: Change code below to process each `directory_site` resource:
-  puts JSON.pretty_generate(directory_site)
+  puts directory_site.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2465,7 +2388,6 @@ service.delete_dynamic_targeting_key(profile_id, object_id_, name, object_type)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2485,7 +2407,7 @@ request_body = Google::Apis::DfareportingV2_6::DynamicTargetingKey.new
 response = service.insert_dynamic_targeting_key(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2494,7 +2416,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2511,7 +2432,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_dynamic_targeting_keys(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2545,7 +2466,6 @@ service.delete_event_tag(profile_id, id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2565,7 +2485,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_event_tag(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2574,7 +2494,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2594,7 +2513,7 @@ request_body = Google::Apis::DfareportingV2_6::EventTag.new
 response = service.insert_event_tag(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2603,7 +2522,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2620,7 +2538,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_event_tags(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2629,7 +2547,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2653,7 +2570,7 @@ request_body = Google::Apis::DfareportingV2_6::EventTag.new
 response = service.patch_event_tag(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2662,7 +2579,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2683,7 +2599,7 @@ request_body = Google::Apis::DfareportingV2_6::EventTag.new
 response = service.update_event_tag(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2692,7 +2608,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2716,7 +2631,7 @@ file_id = 0  # TODO: Update placeholder value.
 response = service.get_file(report_id, file_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2725,7 +2640,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2745,7 +2659,7 @@ end
 
 items.each do |file|
   # TODO: Change code below to process each `file` resource:
-  puts JSON.pretty_generate(file)
+  puts file.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2780,7 +2694,6 @@ service.delete_floodlight_activity(profile_id, id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2797,7 +2710,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.generate_floodlight_activity_tag(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2806,7 +2719,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2826,7 +2738,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_floodlight_activity(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2835,7 +2747,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2855,7 +2766,7 @@ request_body = Google::Apis::DfareportingV2_6::FloodlightActivity.new
 response = service.insert_floodlight_activity(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2864,7 +2775,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2884,7 +2794,7 @@ end
 
 floodlight_activities.each do |floodlight_activity|
   # TODO: Change code below to process each `floodlight_activity` resource:
-  puts JSON.pretty_generate(floodlight_activity)
+  puts floodlight_activity.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -2894,7 +2804,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2918,7 +2827,7 @@ request_body = Google::Apis::DfareportingV2_6::FloodlightActivity.new
 response = service.patch_floodlight_activity(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2927,7 +2836,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2948,7 +2856,7 @@ request_body = Google::Apis::DfareportingV2_6::FloodlightActivity.new
 response = service.update_floodlight_activity(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2957,7 +2865,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -2977,7 +2884,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_floodlight_activity_group(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -2986,7 +2893,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3006,7 +2912,7 @@ request_body = Google::Apis::DfareportingV2_6::FloodlightActivityGroup.new
 response = service.insert_floodlight_activity_group(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3015,7 +2921,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3035,7 +2940,7 @@ end
 
 floodlight_activity_groups.each do |floodlight_activity_group|
   # TODO: Change code below to process each `floodlight_activity_group` resource:
-  puts JSON.pretty_generate(floodlight_activity_group)
+  puts floodlight_activity_group.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3045,7 +2950,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3069,7 +2973,7 @@ request_body = Google::Apis::DfareportingV2_6::FloodlightActivityGroup.new
 response = service.patch_floodlight_activity_group(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3078,7 +2982,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3099,7 +3002,7 @@ request_body = Google::Apis::DfareportingV2_6::FloodlightActivityGroup.new
 response = service.update_floodlight_activity_group(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3108,7 +3011,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3128,7 +3030,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_floodlight_configuration(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3137,7 +3039,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3154,7 +3055,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_floodlight_configurations(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3163,7 +3064,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3187,7 +3087,7 @@ request_body = Google::Apis::DfareportingV2_6::FloodlightConfiguration.new
 response = service.patch_floodlight_configuration(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3196,7 +3096,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3217,7 +3116,7 @@ request_body = Google::Apis::DfareportingV2_6::FloodlightConfiguration.new
 response = service.update_floodlight_configuration(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3226,7 +3125,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3249,7 +3147,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_inventory_item(profile_id, project_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3258,7 +3156,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3281,7 +3178,7 @@ end
 
 inventory_items.each do |inventory_item|
   # TODO: Change code below to process each `inventory_item` resource:
-  puts JSON.pretty_generate(inventory_item)
+  puts inventory_item.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3319,7 +3216,6 @@ service.delete_landing_page(profile_id, campaign_id, id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3342,7 +3238,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_landing_page(profile_id, campaign_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3351,7 +3247,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3374,7 +3269,7 @@ request_body = Google::Apis::DfareportingV2_6::LandingPage.new
 response = service.insert_landing_page(profile_id, campaign_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3383,7 +3278,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3403,7 +3297,7 @@ campaign_id = 0  # TODO: Update placeholder value.
 response = service.list_landing_pages(profile_id, campaign_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3412,7 +3306,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3439,7 +3332,7 @@ request_body = Google::Apis::DfareportingV2_6::LandingPage.new
 response = service.patch_landing_page(profile_id, campaign_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3448,7 +3341,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3472,7 +3364,7 @@ request_body = Google::Apis::DfareportingV2_6::LandingPage.new
 response = service.update_landing_page(profile_id, campaign_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3481,7 +3373,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3498,7 +3389,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_languages(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3507,7 +3398,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3524,7 +3414,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_metros(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3533,7 +3423,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3553,7 +3442,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_mobile_carrier(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3562,7 +3451,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3579,7 +3467,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_mobile_carriers(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3588,7 +3476,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3608,7 +3495,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_operating_system_version(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3617,7 +3504,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3634,7 +3520,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_operating_system_versions(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3643,7 +3529,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3663,7 +3548,7 @@ dart_id = 0  # TODO: Update placeholder value.
 response = service.get_operating_system(profile_id, dart_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3672,7 +3557,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3689,7 +3573,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_operating_systems(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3698,7 +3582,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3721,7 +3604,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_order_document(profile_id, project_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3730,7 +3613,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3753,7 +3635,7 @@ end
 
 order_documents.each do |order_document|
   # TODO: Change code below to process each `order_document` resource:
-  puts JSON.pretty_generate(order_document)
+  puts order_document.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3763,7 +3645,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3786,7 +3667,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_order(profile_id, project_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3795,7 +3676,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3818,7 +3698,7 @@ end
 
 orders.each do |order|
   # TODO: Change code below to process each `order` resource:
-  puts JSON.pretty_generate(order)
+  puts order.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3828,7 +3708,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3848,7 +3727,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_placement_group(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3857,7 +3736,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3877,7 +3755,7 @@ request_body = Google::Apis::DfareportingV2_6::PlacementGroup.new
 response = service.insert_placement_group(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3886,7 +3764,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3906,7 +3783,7 @@ end
 
 placement_groups.each do |placement_group|
   # TODO: Change code below to process each `placement_group` resource:
-  puts JSON.pretty_generate(placement_group)
+  puts placement_group.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -3916,7 +3793,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3940,7 +3816,7 @@ request_body = Google::Apis::DfareportingV2_6::PlacementGroup.new
 response = service.patch_placement_group(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -3949,7 +3825,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -3970,7 +3845,7 @@ request_body = Google::Apis::DfareportingV2_6::PlacementGroup.new
 response = service.update_placement_group(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4004,7 +3879,6 @@ service.delete_placement_strategy(profile_id, id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4024,7 +3898,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_placement_strategy(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4033,7 +3907,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4053,7 +3926,7 @@ request_body = Google::Apis::DfareportingV2_6::PlacementStrategy.new
 response = service.insert_placement_strategy(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4062,7 +3935,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4082,7 +3954,7 @@ end
 
 placement_strategies.each do |placement_strategy|
   # TODO: Change code below to process each `placement_strategy` resource:
-  puts JSON.pretty_generate(placement_strategy)
+  puts placement_strategy.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4092,7 +3964,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4116,7 +3987,7 @@ request_body = Google::Apis::DfareportingV2_6::PlacementStrategy.new
 response = service.patch_placement_strategy(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4125,7 +3996,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4146,7 +4016,7 @@ request_body = Google::Apis::DfareportingV2_6::PlacementStrategy.new
 response = service.update_placement_strategy(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4155,7 +4025,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4172,7 +4041,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.generate_placement_tags(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4181,7 +4050,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4201,7 +4069,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_placement(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4210,7 +4078,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4230,7 +4097,7 @@ request_body = Google::Apis::DfareportingV2_6::Placement.new
 response = service.insert_placement(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4239,7 +4106,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4259,7 +4125,7 @@ end
 
 placements.each do |placement|
   # TODO: Change code below to process each `placement` resource:
-  puts JSON.pretty_generate(placement)
+  puts placement.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4269,7 +4135,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4293,7 +4158,7 @@ request_body = Google::Apis::DfareportingV2_6::Placement.new
 response = service.patch_placement(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4302,7 +4167,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4323,7 +4187,7 @@ request_body = Google::Apis::DfareportingV2_6::Placement.new
 response = service.update_placement(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4332,7 +4196,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4352,7 +4215,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_platform_type(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4361,7 +4224,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4378,7 +4240,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_platform_types(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4387,7 +4249,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4407,7 +4268,7 @@ code = 'my-code'  # TODO: Update placeholder value.
 response = service.get_postal_code(profile_id, code)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4416,7 +4277,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4433,7 +4293,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_postal_codes(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4442,7 +4302,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4462,7 +4321,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_project(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4471,7 +4330,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4491,7 +4349,7 @@ end
 
 projects.each do |project|
   # TODO: Change code below to process each `project` resource:
-  puts JSON.pretty_generate(project)
+  puts project.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4501,7 +4359,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4518,7 +4375,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_regions(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4527,7 +4384,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4547,7 +4403,7 @@ remarketing_list_id = 0  # TODO: Update placeholder value.
 response = service.get_remarketing_list_share(profile_id, remarketing_list_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4556,7 +4412,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4580,7 +4435,7 @@ request_body = Google::Apis::DfareportingV2_6::RemarketingListShare.new
 response = service.patch_remarketing_list_share(profile_id, remarketing_list_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4589,7 +4444,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4610,7 +4464,7 @@ request_body = Google::Apis::DfareportingV2_6::RemarketingListShare.new
 response = service.update_remarketing_list_share(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4619,7 +4473,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4639,7 +4492,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_remarketing_list(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4648,7 +4501,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4668,7 +4520,7 @@ request_body = Google::Apis::DfareportingV2_6::RemarketingList.new
 response = service.insert_remarketing_list(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4677,7 +4529,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4700,7 +4551,7 @@ end
 
 remarketing_lists.each do |remarketing_list|
   # TODO: Change code below to process each `remarketing_list` resource:
-  puts JSON.pretty_generate(remarketing_list)
+  puts remarketing_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4710,7 +4561,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4734,7 +4584,7 @@ request_body = Google::Apis::DfareportingV2_6::RemarketingList.new
 response = service.patch_remarketing_list(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4743,7 +4593,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4764,7 +4613,7 @@ request_body = Google::Apis::DfareportingV2_6::RemarketingList.new
 response = service.update_remarketing_list(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4773,7 +4622,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4793,7 +4641,7 @@ request_body = Google::Apis::DfareportingV2_6::Report.new
 response = service.query_report_compatible_field(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4827,7 +4675,6 @@ service.delete_report(profile_id, report_id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4854,7 +4701,7 @@ file_id = 0  # TODO: Update placeholder value.
 response = service.get_report_file(profile_id, report_id, file_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4863,7 +4710,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4886,7 +4732,7 @@ end
 
 items.each do |file|
   # TODO: Change code below to process each `file` resource:
-  puts JSON.pretty_generate(file)
+  puts file.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4896,7 +4742,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4916,7 +4761,7 @@ report_id = 0  # TODO: Update placeholder value.
 response = service.get_report(profile_id, report_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4925,7 +4770,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4945,7 +4789,7 @@ request_body = Google::Apis::DfareportingV2_6::Report.new
 response = service.insert_report(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -4954,7 +4798,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -4974,7 +4817,7 @@ end
 
 items.each do |report|
   # TODO: Change code below to process each `report` resource:
-  puts JSON.pretty_generate(report)
+  puts report.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -4984,7 +4827,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5008,7 +4850,7 @@ request_body = Google::Apis::DfareportingV2_6::Report.new
 response = service.patch_report(profile_id, report_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5017,7 +4859,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5037,7 +4878,7 @@ report_id = 0  # TODO: Update placeholder value.
 response = service.run_report(profile_id, report_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5046,7 +4887,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5070,7 +4910,7 @@ request_body = Google::Apis::DfareportingV2_6::Report.new
 response = service.update_report(profile_id, report_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5079,7 +4919,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5099,7 +4938,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_site(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5108,7 +4947,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5128,7 +4966,7 @@ request_body = Google::Apis::DfareportingV2_6::Site.new
 response = service.insert_site(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5137,7 +4975,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5157,7 +4994,7 @@ end
 
 sites.each do |site|
   # TODO: Change code below to process each `site` resource:
-  puts JSON.pretty_generate(site)
+  puts site.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -5167,7 +5004,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5191,7 +5027,7 @@ request_body = Google::Apis::DfareportingV2_6::Site.new
 response = service.patch_site(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5200,7 +5036,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5221,7 +5056,7 @@ request_body = Google::Apis::DfareportingV2_6::Site.new
 response = service.update_site(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5230,7 +5065,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5250,7 +5084,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_size(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5259,7 +5093,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5279,7 +5112,7 @@ request_body = Google::Apis::DfareportingV2_6::Size.new
 response = service.insert_size(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5288,7 +5121,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5305,7 +5137,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_sizes(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5314,7 +5146,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5334,7 +5165,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_subaccount(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5343,7 +5174,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5363,7 +5193,7 @@ request_body = Google::Apis::DfareportingV2_6::Subaccount.new
 response = service.insert_subaccount(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5372,7 +5202,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5392,7 +5221,7 @@ end
 
 subaccounts.each do |subaccount|
   # TODO: Change code below to process each `subaccount` resource:
-  puts JSON.pretty_generate(subaccount)
+  puts subaccount.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -5402,7 +5231,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5426,7 +5254,7 @@ request_body = Google::Apis::DfareportingV2_6::Subaccount.new
 response = service.patch_subaccount(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5435,7 +5263,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5456,7 +5283,7 @@ request_body = Google::Apis::DfareportingV2_6::Subaccount.new
 response = service.update_subaccount(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5465,7 +5292,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5485,7 +5311,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_targetable_remarketing_list(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5494,7 +5320,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5517,7 +5342,7 @@ end
 
 targetable_remarketing_lists.each do |targetable_remarketing_list|
   # TODO: Change code below to process each `targetable_remarketing_list` resource:
-  puts JSON.pretty_generate(targetable_remarketing_list)
+  puts targetable_remarketing_list.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -5527,7 +5352,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5547,7 +5371,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_targeting_template(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5556,7 +5380,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5576,7 +5399,7 @@ request_body = Google::Apis::DfareportingV2_6::TargetingTemplate.new
 response = service.insert_targeting_template(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5585,7 +5408,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5605,7 +5427,7 @@ end
 
 targeting_templates.each do |targeting_template|
   # TODO: Change code below to process each `targeting_template` resource:
-  puts JSON.pretty_generate(targeting_template)
+  puts targeting_template.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -5615,7 +5437,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5639,7 +5460,7 @@ request_body = Google::Apis::DfareportingV2_6::TargetingTemplate.new
 response = service.patch_targeting_template(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5648,7 +5469,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5669,7 +5489,7 @@ request_body = Google::Apis::DfareportingV2_6::TargetingTemplate.new
 response = service.update_targeting_template(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5678,7 +5498,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5696,7 +5515,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.get_user_profile(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5705,7 +5524,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5720,7 +5538,7 @@ service.authorization = nil
 response = service.list_user_profiles()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5729,7 +5547,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5749,7 +5566,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_user_role_permission_group(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5758,7 +5575,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5775,7 +5591,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_user_role_permission_groups(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5784,7 +5600,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5804,7 +5619,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_user_role_permission(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5813,7 +5628,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5830,7 +5644,7 @@ profile_id = 0  # TODO: Update placeholder value.
 response = service.list_user_role_permissions(profile_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5864,7 +5678,6 @@ service.delete_user_role(profile_id, id)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5884,7 +5697,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_user_role(profile_id, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5893,7 +5706,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5913,7 +5725,7 @@ request_body = Google::Apis::DfareportingV2_6::UserRole.new
 response = service.insert_user_role(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5922,7 +5734,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5942,7 +5753,7 @@ end
 
 user_roles.each do |user_role|
   # TODO: Change code below to process each `user_role` resource:
-  puts JSON.pretty_generate(user_role)
+  puts user_role.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -5952,7 +5763,6 @@ end
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -5976,7 +5786,7 @@ request_body = Google::Apis::DfareportingV2_6::UserRole.new
 response = service.patch_user_role(profile_id, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the DCM/DFA Reporting And Trafficking API
@@ -5985,7 +5795,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/dfareporting_v2_6'
-require 'json'
 
 service = Google::Apis::DfareportingV2_6::DfareportingService.new
 
@@ -6006,4 +5815,4 @@ request_body = Google::Apis::DfareportingV2_6::UserRole.new
 response = service.update_user_role(profile_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_dns.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_dns.v1.json.baseline
index 4eeac27b92..5254db5248 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_dns.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_dns.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/dns_v1'
-require 'json'
 
 service = Google::Apis::DnsV1::DnsService.new
 
@@ -35,7 +34,7 @@ request_body = Google::Apis::DnsV1::Change.new
 response = service.create_change(project, managed_zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud DNS API
@@ -53,7 +52,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/dns_v1'
-require 'json'
 
 service = Google::Apis::DnsV1::DnsService.new
 
@@ -72,7 +70,7 @@ change_id = 'my-change-id'  # TODO: Update placeholder value.
 response = service.get_change(project, managed_zone, change_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud DNS API
@@ -90,7 +88,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/dns_v1'
-require 'json'
 
 service = Google::Apis::DnsV1::DnsService.new
 
@@ -109,7 +106,7 @@ end
 
 changes.each do |change|
   # TODO: Change code below to process each `change` resource:
-  puts JSON.pretty_generate(change)
+  puts change.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -128,7 +125,6 @@ end
 
 require 'googleauth'
 require 'google/apis/dns_v1'
-require 'json'
 
 service = Google::Apis::DnsV1::DnsService.new
 
@@ -144,7 +140,7 @@ request_body = Google::Apis::DnsV1::ManagedZone.new
 response = service.create_managed_zone(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud DNS API
@@ -192,7 +188,6 @@ service.delete_managed_zone(project, managed_zone)
 
 require 'googleauth'
 require 'google/apis/dns_v1'
-require 'json'
 
 service = Google::Apis::DnsV1::DnsService.new
 
@@ -208,7 +203,7 @@ managed_zone = 'my-managed-zone'  # TODO: Update placeholder value.
 response = service.get_managed_zone(project, managed_zone)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud DNS API
@@ -226,7 +221,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/dns_v1'
-require 'json'
 
 service = Google::Apis::DnsV1::DnsService.new
 
@@ -242,7 +236,7 @@ end
 
 managed_zones.each do |managed_zone|
   # TODO: Change code below to process each `managed_zone` resource:
-  puts JSON.pretty_generate(managed_zone)
+  puts managed_zone.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -261,7 +255,6 @@ end
 
 require 'googleauth'
 require 'google/apis/dns_v1'
-require 'json'
 
 service = Google::Apis::DnsV1::DnsService.new
 
@@ -274,7 +267,7 @@ project = 'my-project'  # TODO: Update placeholder value.
 response = service.get_project(project)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud DNS API
@@ -292,7 +285,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/dns_v1'
-require 'json'
 
 service = Google::Apis::DnsV1::DnsService.new
 
@@ -311,5 +303,5 @@ end
 
 rrsets.each do |resource_record_set|
   # TODO: Change code below to process each `resource_record_set` resource:
-  puts JSON.pretty_generate(resource_record_set)
+  puts resource_record_set.to_json
 end
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_foo.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_foo.v1.json.baseline
index bcf5fd8433..1dca655c7d 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_foo.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_foo.v1.json.baseline
@@ -7,11 +7,10 @@
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/foo_v1'
-require 'json'
 
 service = Google::Apis::FooV1::FooService.new
 
 response = service.get_bar_baz()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_genomics.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_genomics.v1.json.baseline
index 82032f7f42..e8b218c5ab 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_genomics.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_genomics.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -29,7 +28,7 @@ request_body = Google::Apis::GenomicsV1::BatchCreateAnnotationsRequest.new
 response = service.batch_create_annotations(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -47,7 +46,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -60,7 +58,7 @@ request_body = Google::Apis::GenomicsV1::Annotation.new
 response = service.create_annotation(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -105,7 +103,6 @@ service.delete_annotation(annotation_id)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -118,7 +115,7 @@ annotation_id = 'my-annotation-id'  # TODO: Update placeholder value.
 response = service.get_annotation(annotation_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -136,7 +133,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -153,7 +149,7 @@ end
 
 annotations.each do |annotation|
   # TODO: Change code below to process each `annotation` resource:
-  puts JSON.pretty_generate(annotation)
+  puts annotation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -172,7 +168,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -189,7 +184,7 @@ request_body = Google::Apis::GenomicsV1::Annotation.new
 response = service.update_annotation(annotation_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -207,7 +202,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -220,7 +214,7 @@ request_body = Google::Apis::GenomicsV1::AnnotationSet.new
 response = service.create_annotation_set(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -265,7 +259,6 @@ service.delete_annotationset(annotation_set_id)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -278,7 +271,7 @@ annotation_set_id = 'my-annotation-set-id'  # TODO: Update placeholder value.
 response = service.get_annotation_set(annotation_set_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -296,7 +289,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -313,7 +305,7 @@ end
 
 annotation_sets.each do |annotation_set|
   # TODO: Change code below to process each `annotation_set` resource:
-  puts JSON.pretty_generate(annotation_set)
+  puts annotation_set.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -332,7 +324,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -349,7 +340,7 @@ request_body = Google::Apis::GenomicsV1::AnnotationSet.new
 response = service.update_annotationset(annotation_set_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -367,7 +358,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -380,7 +370,7 @@ request_body = Google::Apis::GenomicsV1::CallSet.new
 response = service.create_call_set(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -425,7 +415,6 @@ service.delete_call_set(call_set_id)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -438,7 +427,7 @@ call_set_id = 'my-call-set-id'  # TODO: Update placeholder value.
 response = service.get_call_set(call_set_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -456,7 +445,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -473,7 +461,7 @@ request_body = Google::Apis::GenomicsV1::CallSet.new
 response = service.patch_call_set(call_set_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -491,7 +479,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -508,7 +495,7 @@ end
 
 call_sets.each do |call_set|
   # TODO: Change code below to process each `call_set` resource:
-  puts JSON.pretty_generate(call_set)
+  puts call_set.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -527,7 +514,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -540,7 +526,7 @@ request_body = Google::Apis::GenomicsV1::Dataset.new
 response = service.create_dataset(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -585,7 +571,6 @@ service.delete_dataset(dataset_id)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -598,7 +583,7 @@ dataset_id = 'my-dataset-id'  # TODO: Update placeholder value.
 response = service.get_dataset(dataset_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -616,7 +601,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -632,7 +616,7 @@ request_body = Google::Apis::GenomicsV1::GetIamPolicyRequest.new
 response = service.get_dataset_iam_policy(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -650,7 +634,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -663,7 +646,7 @@ end
 
 datasets.each do |dataset|
   # TODO: Change code below to process each `dataset` resource:
-  puts JSON.pretty_generate(dataset)
+  puts dataset.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -682,7 +665,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -699,7 +681,7 @@ request_body = Google::Apis::GenomicsV1::Dataset.new
 response = service.patch_dataset(dataset_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -717,7 +699,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -733,7 +714,7 @@ request_body = Google::Apis::GenomicsV1::SetIamPolicyRequest.new
 response = service.set_dataset_iam_policy(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -751,7 +732,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -767,7 +747,7 @@ request_body = Google::Apis::GenomicsV1::TestIamPermissionsRequest.new
 response = service.test_dataset_iam_permissions(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -785,7 +765,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -801,7 +780,7 @@ request_body = Google::Apis::GenomicsV1::UndeleteDatasetRequest.new
 response = service.undelete_dataset(dataset_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -849,7 +828,6 @@ service.cancel_operation(name, request_body)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -862,7 +840,7 @@ name = 'operations/my-operation'  # TODO: Update placeholder value.
 response = service.get_operation(name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -880,7 +858,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -896,7 +873,7 @@ end
 
 operations.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -915,7 +892,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -931,7 +907,7 @@ end
 
 coverage_buckets.each do |coverage_bucket|
   # TODO: Change code below to process each `coverage_bucket` resource:
-  puts JSON.pretty_generate(coverage_bucket)
+  puts coverage_bucket.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -978,7 +954,6 @@ service.delete_read_group_set(read_group_set_id)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -995,7 +970,7 @@ request_body = Google::Apis::GenomicsV1::ExportReadGroupSetRequest.new
 response = service.export_read_group_sets(read_group_set_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1013,7 +988,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1026,7 +1000,7 @@ read_group_set_id = 'my-read-group-set-id'  # TODO: Update placeholder value.
 response = service.get_read_group_set(read_group_set_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1044,7 +1018,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1057,7 +1030,7 @@ request_body = Google::Apis::GenomicsV1::ImportReadGroupSetsRequest.new
 response = service.import_read_group_sets(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1075,7 +1048,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1093,7 +1065,7 @@ request_body = Google::Apis::GenomicsV1::ReadGroupSet.new
 response = service.patch_read_group_set(read_group_set_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1111,7 +1083,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1128,7 +1099,7 @@ end
 
 read_group_sets.each do |read_group_set|
   # TODO: Change code below to process each `read_group_set` resource:
-  puts JSON.pretty_generate(read_group_set)
+  puts read_group_set.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1147,7 +1118,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1164,7 +1134,7 @@ end
 
 alignments.each do |read|
   # TODO: Change code below to process each `read` resource:
-  puts JSON.pretty_generate(read)
+  puts read.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1183,7 +1153,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1196,7 +1165,7 @@ request_body = Google::Apis::GenomicsV1::StreamReadsRequest.new
 response = service.stream_reads(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1214,7 +1183,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1230,7 +1198,7 @@ end
 
 sequence.each do |item|
   # TODO: Change code below to process each `item` resource:
-  puts JSON.pretty_generate(item)
+  puts item.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1249,7 +1217,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1262,7 +1229,7 @@ reference_id = 'my-reference-id'  # TODO: Update placeholder value.
 response = service.get_reference(reference_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1280,7 +1247,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1297,7 +1263,7 @@ end
 
 references.each do |reference|
   # TODO: Change code below to process each `reference` resource:
-  puts JSON.pretty_generate(reference)
+  puts reference.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1316,7 +1282,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1329,7 +1294,7 @@ reference_set_id = 'my-reference-set-id'  # TODO: Update placeholder value.
 response = service.get_reference_set(reference_set_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1347,7 +1312,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1364,7 +1328,7 @@ end
 
 reference_sets.each do |reference_set|
   # TODO: Change code below to process each `reference_set` resource:
-  puts JSON.pretty_generate(reference_set)
+  puts reference_set.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1383,7 +1347,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1396,7 +1359,7 @@ request_body = Google::Apis::GenomicsV1::Variant.new
 response = service.create_variant(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1441,7 +1404,6 @@ service.delete_variant(variant_id)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1454,7 +1416,7 @@ variant_id = 'my-variant-id'  # TODO: Update placeholder value.
 response = service.get_variant(variant_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1472,7 +1434,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1485,7 +1446,7 @@ request_body = Google::Apis::GenomicsV1::ImportVariantsRequest.new
 response = service.import_variants(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1530,7 +1491,6 @@ service.merge_variants(request_body)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1547,7 +1507,7 @@ request_body = Google::Apis::GenomicsV1::Variant.new
 response = service.patch_variant(variant_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1565,7 +1525,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1582,7 +1541,7 @@ end
 
 variants.each do |variant|
   # TODO: Change code below to process each `variant` resource:
-  puts JSON.pretty_generate(variant)
+  puts variant.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1601,7 +1560,6 @@ end
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1614,7 +1572,7 @@ request_body = Google::Apis::GenomicsV1::StreamVariantsRequest.new
 response = service.stream_variants(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1632,7 +1590,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1645,7 +1602,7 @@ request_body = Google::Apis::GenomicsV1::VariantSet.new
 response = service.create_variantset(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1690,7 +1647,6 @@ service.delete_variantset(variant_set_id)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1707,7 +1663,7 @@ request_body = Google::Apis::GenomicsV1::ExportVariantSetRequest.new
 response = service.export_variant_set(variant_set_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1725,7 +1681,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1738,7 +1693,7 @@ variant_set_id = 'my-variant-set-id'  # TODO: Update placeholder value.
 response = service.get_variantset(variant_set_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1756,7 +1711,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1773,7 +1727,7 @@ request_body = Google::Apis::GenomicsV1::VariantSet.new
 response = service.patch_variantset(variant_set_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Genomics API
@@ -1791,7 +1745,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/genomics_v1'
-require 'json'
 
 service = Google::Apis::GenomicsV1::GenomicsService.new
 
@@ -1808,5 +1761,5 @@ end
 
 variant_sets.each do |variant_set|
   # TODO: Change code below to process each `variant_set` resource:
-  puts JSON.pretty_generate(variant_set)
+  puts variant_set.to_json
 end
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_logging.v2beta1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_logging.v2beta1.json.baseline
index b9c7f9c2cd..9ef9ac51cb 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_logging.v2beta1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_logging.v2beta1.json.baseline
@@ -48,7 +48,6 @@ service.delete_billing_account_log(log_name)
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -66,7 +65,7 @@ end
 
 log_names.each do |item|
   # TODO: Change code below to process each `item` resource:
-  puts JSON.pretty_generate(item)
+  puts item.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -85,7 +84,6 @@ end
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -102,7 +100,7 @@ end
 
 entries.each do |log_entry|
   # TODO: Change code below to process each `log_entry` resource:
-  puts JSON.pretty_generate(log_entry)
+  puts log_entry.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -121,7 +119,6 @@ end
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -134,7 +131,7 @@ request_body = Google::Apis::LoggingV2beta1::WriteLogEntriesRequest.new
 response = service.write_entry_log_entries(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Logging API
@@ -152,7 +149,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -165,7 +161,7 @@ end
 
 resource_descriptors.each do |monitored_resource_descriptor|
   # TODO: Change code below to process each `monitored_resource_descriptor` resource:
-  puts JSON.pretty_generate(monitored_resource_descriptor)
+  puts monitored_resource_descriptor.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -216,7 +212,6 @@ service.delete_organization_log(log_name)
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -234,7 +229,7 @@ end
 
 log_names.each do |item|
   # TODO: Change code below to process each `item` resource:
-  puts JSON.pretty_generate(item)
+  puts item.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -285,7 +280,6 @@ service.delete_log(log_name)
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -303,7 +297,7 @@ end
 
 log_names.each do |item|
   # TODO: Change code below to process each `item` resource:
-  puts JSON.pretty_generate(item)
+  puts item.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -322,7 +316,6 @@ end
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -340,7 +333,7 @@ request_body = Google::Apis::LoggingV2beta1::LogMetric.new
 response = service.create_project_metric(parent, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Logging API
@@ -386,7 +379,6 @@ service.delete_project_metric(metric_name)
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -400,7 +392,7 @@ metric_name = 'projects/my-project/metrics/my-metric'  # TODO: Update placeholde
 response = service.get_project_metric(metric_name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Logging API
@@ -418,7 +410,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -435,7 +426,7 @@ end
 
 metrics.each do |log_metric|
   # TODO: Change code below to process each `log_metric` resource:
-  puts JSON.pretty_generate(log_metric)
+  puts log_metric.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -454,7 +445,6 @@ end
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -474,7 +464,7 @@ request_body = Google::Apis::LoggingV2beta1::LogMetric.new
 response = service.update_project_metric(metric_name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Logging API
@@ -492,7 +482,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -511,7 +500,7 @@ request_body = Google::Apis::LoggingV2beta1::LogSink.new
 response = service.create_project_sink(parent, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Logging API
@@ -561,7 +550,6 @@ service.delete_project_sink(sink_name)
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -577,7 +565,7 @@ sink_name = 'projects/my-project/sinks/my-sink'  # TODO: Update placeholder valu
 response = service.get_project_sink(sink_name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Stackdriver Logging API
@@ -595,7 +583,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -612,7 +599,7 @@ end
 
 sinks.each do |log_sink|
   # TODO: Change code below to process each `log_sink` resource:
-  puts JSON.pretty_generate(log_sink)
+  puts log_sink.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -631,7 +618,6 @@ end
 
 require 'googleauth'
 require 'google/apis/logging_v2beta1'
-require 'json'
 
 service = Google::Apis::LoggingV2beta1::LoggingService.new
 
@@ -652,4 +638,4 @@ request_body = Google::Apis::LoggingV2beta1::LogSink.new
 response = service.update_project_sink(sink_name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_prediction.v1.6.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_prediction.v1.6.json.baseline
index 848ccf32f9..4eba31feec 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_prediction.v1.6.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_prediction.v1.6.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/prediction_v1_6'
-require 'json'
 
 service = Google::Apis::PredictionV1_6::PredictionService.new
 
@@ -35,7 +34,7 @@ request_body = Google::Apis::PredictionV1_6::Input.new
 response = service.predict_hosted_model(project, hosted_model_name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Prediction API
@@ -53,7 +52,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/prediction_v1_6'
-require 'json'
 
 service = Google::Apis::PredictionV1_6::PredictionService.new
 
@@ -69,7 +67,7 @@ id = 'my-id'  # TODO: Update placeholder value.
 response = service.analyze_trained_model(project, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Prediction API
@@ -117,7 +115,6 @@ service.delete_trained_model(project, id)
 
 require 'googleauth'
 require 'google/apis/prediction_v1_6'
-require 'json'
 
 service = Google::Apis::PredictionV1_6::PredictionService.new
 
@@ -133,7 +130,7 @@ id = 'my-id'  # TODO: Update placeholder value.
 response = service.get_trained_model(project, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Prediction API
@@ -151,7 +148,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/prediction_v1_6'
-require 'json'
 
 service = Google::Apis::PredictionV1_6::PredictionService.new
 
@@ -167,7 +163,7 @@ request_body = Google::Apis::PredictionV1_6::Insert.new
 response = service.insert_trained_model(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Prediction API
@@ -185,7 +181,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/prediction_v1_6'
-require 'json'
 
 service = Google::Apis::PredictionV1_6::PredictionService.new
 
@@ -201,7 +196,7 @@ end
 
 items.each do |insert2|
   # TODO: Change code below to process each `insert2` resource:
-  puts JSON.pretty_generate(insert2)
+  puts insert2.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -220,7 +215,6 @@ end
 
 require 'googleauth'
 require 'google/apis/prediction_v1_6'
-require 'json'
 
 service = Google::Apis::PredictionV1_6::PredictionService.new
 
@@ -239,7 +233,7 @@ request_body = Google::Apis::PredictionV1_6::Input.new
 response = service.predict_trained_model(project, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Prediction API
@@ -257,7 +251,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/prediction_v1_6'
-require 'json'
 
 service = Google::Apis::PredictionV1_6::PredictionService.new
 
@@ -277,4 +270,4 @@ request_body = Google::Apis::PredictionV1_6::Update.new
 response = service.update_trained_model(project, id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_pubsub.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_pubsub.v1.json.baseline
index 5a105c1897..a2c4a8a530 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_pubsub.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_pubsub.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -31,7 +30,7 @@ resource = 'projects/my-project/snapshots/my-snapshot'  # TODO: Update placehold
 response = service.get_project_snapshot_iam_policy(resource)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -49,7 +48,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -67,7 +65,7 @@ request_body = Google::Apis::PubsubV1::SetIamPolicyRequest.new
 response = service.set_snapshot_iam_policy(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -85,7 +83,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -103,7 +100,7 @@ request_body = Google::Apis::PubsubV1::TestIamPermissionsRequest.new
 response = service.test_snapshot_iam_permissions(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -152,7 +149,6 @@ service.acknowledge_subscription(subscription, request_body)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -174,7 +170,7 @@ request_body = Google::Apis::PubsubV1::Subscription.new
 response = service.create_subscription(name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -220,7 +216,6 @@ service.delete_subscription(subscription)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -234,7 +229,7 @@ subscription = 'projects/my-project/subscriptions/my-subscription'  # TODO: Upda
 response = service.get_subscription(subscription)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -252,7 +247,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -267,7 +261,7 @@ resource = 'projects/my-project/subscriptions/my-subscription'  # TODO: Update p
 response = service.get_project_subscription_iam_policy(resource)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -285,7 +279,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -302,7 +295,7 @@ end
 
 subscriptions.each do |subscription|
   # TODO: Change code below to process each `subscription` resource:
-  puts JSON.pretty_generate(subscription)
+  puts subscription.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -383,7 +376,6 @@ service.modify_subscription_push_config(subscription, request_body)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -400,7 +392,7 @@ request_body = Google::Apis::PubsubV1::PullRequest.new
 response = service.pull_subscription(subscription, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -418,7 +410,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -436,7 +427,7 @@ request_body = Google::Apis::PubsubV1::SetIamPolicyRequest.new
 response = service.set_subscription_iam_policy(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -454,7 +445,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -472,7 +462,7 @@ request_body = Google::Apis::PubsubV1::TestIamPermissionsRequest.new
 response = service.test_subscription_iam_permissions(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -490,7 +480,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -512,7 +501,7 @@ request_body = Google::Apis::PubsubV1::Topic.new
 response = service.create_topic(name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -558,7 +547,6 @@ service.delete_topic(topic)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -572,7 +560,7 @@ topic = 'projects/my-project/topics/my-topic'  # TODO: Update placeholder value.
 response = service.get_topic(topic)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -590,7 +578,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -605,7 +592,7 @@ resource = 'projects/my-project/topics/my-topic'  # TODO: Update placeholder val
 response = service.get_project_topic_iam_policy(resource)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -623,7 +610,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -640,7 +626,7 @@ end
 
 topics.each do |topic|
   # TODO: Change code below to process each `topic` resource:
-  puts JSON.pretty_generate(topic)
+  puts topic.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -659,7 +645,6 @@ end
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -676,7 +661,7 @@ request_body = Google::Apis::PubsubV1::PublishRequest.new
 response = service.publish_topic(topic, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -694,7 +679,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -712,7 +696,7 @@ request_body = Google::Apis::PubsubV1::SetIamPolicyRequest.new
 response = service.set_topic_iam_policy(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Cloud Pub/Sub API
@@ -730,7 +714,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -747,7 +730,7 @@ end
 
 subscriptions.each do |item|
   # TODO: Change code below to process each `item` resource:
-  puts JSON.pretty_generate(item)
+  puts item.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -766,7 +749,6 @@ end
 
 require 'googleauth'
 require 'google/apis/pubsub_v1'
-require 'json'
 
 service = Google::Apis::PubsubV1::PubsubService.new
 
@@ -784,4 +766,4 @@ request_body = Google::Apis::PubsubV1::TestIamPermissionsRequest.new
 response = service.test_topic_iam_permissions(resource, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_replicapoolupdater.v1beta1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_replicapoolupdater.v1beta1.json.baseline
index e1da0bfc71..3545b5f6e8 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_replicapoolupdater.v1beta1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_replicapoolupdater.v1beta1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -35,7 +34,7 @@ rolling_update = 'my-rolling-update'  # TODO: Update placeholder value.
 response = service.cancel_rolling_update(project, zone, rolling_update)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Compute Engine Instance Group Updater API
@@ -53,7 +52,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -72,7 +70,7 @@ rolling_update = 'my-rolling-update'  # TODO: Update placeholder value.
 response = service.get_rolling_update(project, zone, rolling_update)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Compute Engine Instance Group Updater API
@@ -90,7 +88,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -109,7 +106,7 @@ request_body = Google::Apis::ReplicapoolupdaterV1beta1::RollingUpdate.new
 response = service.insert_rolling_update(project, zone, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Compute Engine Instance Group Updater API
@@ -127,7 +124,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -146,7 +142,7 @@ end
 
 items.each do |rolling_update|
   # TODO: Change code below to process each `rolling_update` resource:
-  puts JSON.pretty_generate(rolling_update)
+  puts rolling_update.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -165,7 +161,6 @@ end
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -187,7 +182,7 @@ end
 
 items.each do |instance_update|
   # TODO: Change code below to process each `instance_update` resource:
-  puts JSON.pretty_generate(instance_update)
+  puts instance_update.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -206,7 +201,6 @@ end
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -225,7 +219,7 @@ rolling_update = 'my-rolling-update'  # TODO: Update placeholder value.
 response = service.pause_rolling_update(project, zone, rolling_update)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Compute Engine Instance Group Updater API
@@ -243,7 +237,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -262,7 +255,7 @@ rolling_update = 'my-rolling-update'  # TODO: Update placeholder value.
 response = service.resume_rolling_update(project, zone, rolling_update)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Compute Engine Instance Group Updater API
@@ -280,7 +273,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -299,7 +291,7 @@ rolling_update = 'my-rolling-update'  # TODO: Update placeholder value.
 response = service.rollback_rolling_update(project, zone, rolling_update)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Compute Engine Instance Group Updater API
@@ -317,7 +309,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -336,7 +327,7 @@ operation = 'my-operation'  # TODO: Update placeholder value.
 response = service.get_zone_operation(project, zone, operation)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Compute Engine Instance Group Updater API
@@ -354,7 +345,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/replicapoolupdater_v1beta1'
-require 'json'
 
 service = Google::Apis::ReplicapoolupdaterV1beta1::ReplicapoolupdaterService.new
 
@@ -373,5 +363,5 @@ end
 
 items.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_sheets.v4.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_sheets.v4.json.baseline
index 2bbd263208..eb845c69e5 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_sheets.v4.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_sheets.v4.json.baseline
@@ -7,7 +7,6 @@
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -32,7 +31,7 @@ request_body.requests = requests;
 response = service.batch_update_spreadsheet(spreadsheet_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -41,7 +40,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -59,7 +57,7 @@ request_body = Google::Apis::SheetsV4::Spreadsheet.new
 response = service.create_spreadsheet(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -68,7 +66,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -95,7 +92,7 @@ include_grid_data = false  # TODO: Update placeholder value.
 response = service.get_spreadsheet(spreadsheet_id, ranges: ranges, include_grid_data: include_grid_data)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -104,7 +101,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -132,7 +128,7 @@ request_body.destination_spreadsheet_id = destination_spreadsheet_id;
 response = service.copy_spreadsheet(spreadsheet_id, sheet_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -141,7 +137,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -172,7 +167,7 @@ request_body = Google::Apis::SheetsV4::ValueRange.new
 response = service.append_spreadsheet_value(spreadsheet_id, range, request_body, value_input_option: value_input_option, insert_data_option: insert_data_option)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -181,7 +176,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -206,7 +200,7 @@ request_body.ranges = ranges;
 response = service.batch_clear_values(spreadsheet_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -215,7 +209,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -248,7 +241,7 @@ date_time_render_option = ''  # TODO: Update placeholder value.
 response = service.batch_get_spreadsheet_values(spreadsheet_id, ranges: ranges, value_render_option: value_render_option, date_time_render_option: date_time_render_option)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -257,7 +250,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -286,7 +278,7 @@ request_body.data = data;
 response = service.batch_update_values(spreadsheet_id, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -295,7 +287,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -319,7 +310,7 @@ request_body = Google::Apis::SheetsV4::ClearValuesRequest.new
 response = service.clear_values(spreadsheet_id, range, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -328,7 +319,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -361,7 +351,7 @@ date_time_render_option = ''  # TODO: Update placeholder value.
 response = service.get_spreadsheet_values(spreadsheet_id, range, value_render_option: value_render_option, date_time_render_option: date_time_render_option)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Sheets API
@@ -370,7 +360,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/sheets_v4'
-require 'json'
 
 service = Google::Apis::SheetsV4::SheetsService.new
 
@@ -398,4 +387,4 @@ request_body = Google::Apis::SheetsV4::ValueRange.new
 response = service.update_spreadsheet_value(spreadsheet_id, range, request_body, value_input_option: value_input_option)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_sqladmin.v1beta4.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_sqladmin.v1beta4.json.baseline
index 3eb114fa7f..7000f2c16a 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_sqladmin.v1beta4.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_sqladmin.v1beta4.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -35,7 +34,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.delete_backup_run(project, instance, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -53,7 +52,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -72,7 +70,7 @@ id = 0  # TODO: Update placeholder value.
 response = service.get_backup_run(project, instance, id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -90,7 +88,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -109,7 +106,7 @@ request_body = Google::Apis::SqladminV1beta4::BackupRun.new
 response = service.insert_backup_run(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -127,7 +124,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -146,7 +142,7 @@ end
 
 items.each do |backup_run|
   # TODO: Change code below to process each `backup_run` resource:
-  puts JSON.pretty_generate(backup_run)
+  puts backup_run.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -165,7 +161,6 @@ end
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -184,7 +179,7 @@ database = 'my-database'  # TODO: Update placeholder value.
 response = service.delete_database(project, instance, database)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -202,7 +197,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -221,7 +215,7 @@ database = 'my-database'  # TODO: Update placeholder value.
 response = service.get_database(project, instance, database)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -239,7 +233,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -258,7 +251,7 @@ request_body = Google::Apis::SqladminV1beta4::Database.new
 response = service.insert_database(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -276,7 +269,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -292,7 +284,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.list_databases(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -310,7 +302,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -333,7 +324,7 @@ request_body = Google::Apis::SqladminV1beta4::Database.new
 response = service.patch_database(project, instance, database, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -351,7 +342,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -374,7 +364,7 @@ request_body = Google::Apis::SqladminV1beta4::Database.new
 response = service.update_database(project, instance, database, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -392,7 +382,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -402,7 +391,7 @@ service.authorization = \
 response = service.list_flags()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -420,7 +409,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -439,7 +427,7 @@ request_body = Google::Apis::SqladminV1beta4::CloneInstancesRequest.new
 response = service.clone_instance(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -457,7 +445,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -473,7 +460,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.delete_instance(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -491,7 +478,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -510,7 +496,7 @@ request_body = Google::Apis::SqladminV1beta4::ExportInstancesRequest.new
 response = service.export_instance(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -528,7 +514,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -547,7 +532,7 @@ request_body = Google::Apis::SqladminV1beta4::InstancesFailoverRequest.new
 response = service.failover_instance(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -565,7 +550,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -581,7 +565,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.get_instance(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -599,7 +583,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -618,7 +601,7 @@ request_body = Google::Apis::SqladminV1beta4::ImportInstancesRequest.new
 response = service.import_instance(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -636,7 +619,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -652,7 +634,7 @@ request_body = Google::Apis::SqladminV1beta4::DatabaseInstance.new
 response = service.insert_instance(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -670,7 +652,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -686,7 +667,7 @@ end
 
 items.each do |database_instance|
   # TODO: Change code below to process each `database_instance` resource:
-  puts JSON.pretty_generate(database_instance)
+  puts database_instance.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -705,7 +686,6 @@ end
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -725,7 +705,7 @@ request_body = Google::Apis::SqladminV1beta4::DatabaseInstance.new
 response = service.patch_instance(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -743,7 +723,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -759,7 +738,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.promote_instance_replica(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -777,7 +756,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -793,7 +771,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.reset_instance_ssl_config(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -811,7 +789,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -827,7 +804,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.restart_instance(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -845,7 +822,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -864,7 +840,7 @@ request_body = Google::Apis::SqladminV1beta4::RestoreInstancesBackupRequest.new
 response = service.restore_instance_backup(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -882,7 +858,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -898,7 +873,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.start_instance_replica(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -916,7 +891,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -932,7 +906,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.stop_instance_replica(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -950,7 +924,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -969,7 +942,7 @@ request_body = Google::Apis::SqladminV1beta4::InstancesTruncateLogRequest.new
 response = service.truncate_instance_log(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -987,7 +960,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1007,7 +979,7 @@ request_body = Google::Apis::SqladminV1beta4::DatabaseInstance.new
 response = service.update_instance(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1025,7 +997,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1041,7 +1012,7 @@ operation = 'my-operation'  # TODO: Update placeholder value.
 response = service.get_operation(project, operation)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1059,7 +1030,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1078,7 +1048,7 @@ end
 
 items.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1097,7 +1067,6 @@ end
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1116,7 +1085,7 @@ request_body = Google::Apis::SqladminV1beta4::SslCertsCreateEphemeralRequest.new
 response = service.create_ssl_cert_ephemeral(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1134,7 +1103,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1153,7 +1121,7 @@ sha1_fingerprint = 'my-sha1-fingerprint'  # TODO: Update placeholder value.
 response = service.delete_ssl_cert(project, instance, sha1_fingerprint)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1171,7 +1139,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1190,7 +1157,7 @@ sha1_fingerprint = 'my-sha1-fingerprint'  # TODO: Update placeholder value.
 response = service.get_ssl_cert(project, instance, sha1_fingerprint)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1208,7 +1175,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1227,7 +1193,7 @@ request_body = Google::Apis::SqladminV1beta4::InsertSslCertsRequest.new
 response = service.insert_ssl_cert(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1245,7 +1211,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1261,7 +1226,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.list_ssl_certs(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1279,7 +1244,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1292,7 +1256,7 @@ project = 'my-project'  # TODO: Update placeholder value.
 response = service.list_tiers(project)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1310,7 +1274,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1332,7 +1295,7 @@ name = ''  # TODO: Update placeholder value.
 response = service.delete_user(project, instance, host, name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1350,7 +1313,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1369,7 +1331,7 @@ request_body = Google::Apis::SqladminV1beta4::User.new
 response = service.insert_user(project, instance, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1387,7 +1349,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1403,7 +1364,7 @@ instance = 'my-instance'  # TODO: Update placeholder value.
 response = service.list_users(project, instance)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud SQL Administration API
@@ -1421,7 +1382,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/sqladmin_v1beta4'
-require 'json'
 
 service = Google::Apis::SqladminV1beta4::SQLAdminService.new
 
@@ -1447,4 +1407,4 @@ request_body = Google::Apis::SqladminV1beta4::User.new
 response = service.update_user(project, instance, host, name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_storage.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_storage.v1.json.baseline
index ca4dd43bfb..e06b4f9378 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_storage.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_storage.v1.json.baseline
@@ -47,7 +47,6 @@ service.delete_bucket_access_control(bucket, entity)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -64,7 +63,7 @@ entity = 'my-entity'  # TODO: Update placeholder value.
 response = service.get_bucket_access_control(bucket, entity)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -82,7 +81,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -98,7 +96,7 @@ request_body = Google::Apis::StorageV1::BucketAccessControl.new
 response = service.insert_bucket_access_control(bucket, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -116,7 +114,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -129,7 +126,7 @@ bucket = 'my-bucket'  # TODO: Update placeholder value.
 response = service.list_bucket_access_controls(bucket)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -147,7 +144,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -168,7 +164,7 @@ request_body = Google::Apis::StorageV1::BucketAccessControl.new
 response = service.patch_bucket_access_control(bucket, entity, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -186,7 +182,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -207,7 +202,7 @@ request_body = Google::Apis::StorageV1::BucketAccessControl.new
 response = service.update_bucket_access_control(bucket, entity, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -252,7 +247,6 @@ service.delete_bucket(bucket)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -265,7 +259,7 @@ bucket = 'my-bucket'  # TODO: Update placeholder value.
 response = service.get_bucket(bucket)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -283,7 +277,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -299,7 +292,7 @@ request_body = Google::Apis::StorageV1::Bucket.new
 response = service.insert_bucket(project, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -317,7 +310,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -333,7 +325,7 @@ end
 
 items.each do |bucket|
   # TODO: Change code below to process each `bucket` resource:
-  puts JSON.pretty_generate(bucket)
+  puts bucket.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -352,7 +344,6 @@ end
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -369,7 +360,7 @@ request_body = Google::Apis::StorageV1::Bucket.new
 response = service.patch_bucket(bucket, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -387,7 +378,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -404,7 +394,7 @@ request_body = Google::Apis::StorageV1::Bucket.new
 response = service.update_bucket(bucket, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -480,7 +470,6 @@ service.delete_default_object_access_control(bucket, entity)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -497,7 +486,7 @@ entity = 'my-entity'  # TODO: Update placeholder value.
 response = service.get_default_object_access_control(bucket, entity)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -515,7 +504,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -531,7 +519,7 @@ request_body = Google::Apis::StorageV1::ObjectAccessControl.new
 response = service.insert_default_object_access_control(bucket, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -549,7 +537,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -562,7 +549,7 @@ bucket = 'my-bucket'  # TODO: Update placeholder value.
 response = service.list_default_object_access_controls(bucket)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -580,7 +567,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -601,7 +587,7 @@ request_body = Google::Apis::StorageV1::ObjectAccessControl.new
 response = service.patch_default_object_access_control(bucket, entity, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -619,7 +605,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -640,7 +625,7 @@ request_body = Google::Apis::StorageV1::ObjectAccessControl.new
 response = service.update_default_object_access_control(bucket, entity, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -693,7 +678,6 @@ service.delete_object_access_control(bucket, object, entity)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -714,7 +698,7 @@ entity = 'my-entity'  # TODO: Update placeholder value.
 response = service.get_object_access_control(bucket, object, entity)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -732,7 +716,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -752,7 +735,7 @@ request_body = Google::Apis::StorageV1::ObjectAccessControl.new
 response = service.insert_object_access_control(bucket, object, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -770,7 +753,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -787,7 +769,7 @@ object = 'my-object'  # TODO: Update placeholder value.
 response = service.list_object_access_controls(bucket, object)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -805,7 +787,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -830,7 +811,7 @@ request_body = Google::Apis::StorageV1::ObjectAccessControl.new
 response = service.patch_object_access_control(bucket, object, entity, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -848,7 +829,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -873,7 +853,7 @@ request_body = Google::Apis::StorageV1::ObjectAccessControl.new
 response = service.update_object_access_control(bucket, object, entity, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -891,7 +871,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -915,7 +894,7 @@ request_body = Google::Apis::StorageV1::ComposeRequest.new
 response = service.compose_object(destination_bucket, destination_object, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -933,7 +912,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -966,7 +944,7 @@ request_body = Google::Apis::StorageV1::Object.new
 response = service.copy_object(source_bucket, source_object, destination_bucket, destination_object, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -1015,7 +993,6 @@ service.delete_object(bucket, object)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -1036,7 +1013,7 @@ object = 'my-object'  # TODO: Update placeholder value.
 response = service.get_object(bucket, object)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -1054,7 +1031,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -1075,7 +1051,7 @@ request_body = Google::Apis::StorageV1::Object.new
 response = service.insert_object(bucket, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -1093,7 +1069,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -1109,7 +1084,7 @@ end
 
 items.each do |object|
   # TODO: Change code below to process each `object` resource:
-  puts JSON.pretty_generate(object)
+  puts object.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -1128,7 +1103,6 @@ end
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -1149,7 +1123,7 @@ request_body = Google::Apis::StorageV1::Object.new
 response = service.patch_object(bucket, object, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -1167,7 +1141,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -1196,7 +1169,7 @@ request_body = Google::Apis::StorageV1::Object.new
 response = service.rewrite_object(source_bucket, source_object, destination_bucket, destination_object, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -1214,7 +1187,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -1239,7 +1211,7 @@ request_body = Google::Apis::StorageV1::Object.new
 response = service.update_object(bucket, object, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Cloud Storage JSON API
@@ -1257,7 +1229,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storage_v1'
-require 'json'
 
 service = Google::Apis::StorageV1::StorageService.new
 
@@ -1273,4 +1244,4 @@ request_body = Google::Apis::StorageV1::Channel.new
 response = service.watch_all_objects(bucket, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_storagetransfer.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_storagetransfer.v1.json.baseline
index a60d0e961d..274f626b1f 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_storagetransfer.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_storagetransfer.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/storagetransfer_v1'
-require 'json'
 
 service = Google::Apis::StoragetransferV1::StoragetransferService.new
 
@@ -26,7 +25,7 @@ service.authorization = \
 response = service.get_google_service_account_v1()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Storage Transfer API
@@ -44,7 +43,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storagetransfer_v1'
-require 'json'
 
 service = Google::Apis::StoragetransferV1::StoragetransferService.new
 
@@ -58,7 +56,7 @@ project_id = 'my-project-id'  # TODO: Update placeholder value.
 response = service.get_google_service_account(project_id)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Storage Transfer API
@@ -76,7 +74,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storagetransfer_v1'
-require 'json'
 
 service = Google::Apis::StoragetransferV1::StoragetransferService.new
 
@@ -89,7 +86,7 @@ request_body = Google::Apis::StoragetransferV1::TransferJob.new
 response = service.create_transfer_job(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Storage Transfer API
@@ -107,7 +104,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storagetransfer_v1'
-require 'json'
 
 service = Google::Apis::StoragetransferV1::StoragetransferService.new
 
@@ -120,7 +116,7 @@ job_name = 'transferJobs/my-transfer-job'  # TODO: Update placeholder value.
 response = service.get_transfer_job(job_name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Storage Transfer API
@@ -138,7 +134,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storagetransfer_v1'
-require 'json'
 
 service = Google::Apis::StoragetransferV1::StoragetransferService.new
 
@@ -151,7 +146,7 @@ end
 
 transfer_jobs.each do |transfer_job|
   # TODO: Change code below to process each `transfer_job` resource:
-  puts JSON.pretty_generate(transfer_job)
+  puts transfer_job.to_json
 end
 # BEFORE RUNNING:
 # ---------------
@@ -170,7 +165,6 @@ end
 
 require 'googleauth'
 require 'google/apis/storagetransfer_v1'
-require 'json'
 
 service = Google::Apis::StoragetransferV1::StoragetransferService.new
 
@@ -187,7 +181,7 @@ request_body = Google::Apis::StoragetransferV1::UpdateTransferJobRequest.new
 response = service.patch_transfer_job(job_name, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Storage Transfer API
@@ -259,7 +253,6 @@ service.delete_transfer_operation(name)
 
 require 'googleauth'
 require 'google/apis/storagetransfer_v1'
-require 'json'
 
 service = Google::Apis::StoragetransferV1::StoragetransferService.new
 
@@ -272,7 +265,7 @@ name = 'transferOperations/my-transfer-operation'  # TODO: Update placeholder va
 response = service.get_transfer_operation(name)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Google Storage Transfer API
@@ -290,7 +283,6 @@ puts JSON.pretty_generate(response)
 
 require 'googleauth'
 require 'google/apis/storagetransfer_v1'
-require 'json'
 
 service = Google::Apis::StoragetransferV1::StoragetransferService.new
 
@@ -306,7 +298,7 @@ end
 
 operations.each do |operation|
   # TODO: Change code below to process each `operation` resource:
-  puts JSON.pretty_generate(operation)
+  puts operation.to_json
 end
 # BEFORE RUNNING:
 # ---------------
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_taskqueue.v1beta2.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_taskqueue.v1beta2.json.baseline
index 6baf30bb24..06e79b72f5 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_taskqueue.v1beta2.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_taskqueue.v1beta2.json.baseline
@@ -7,7 +7,6 @@
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/taskqueue_v1beta2'
-require 'json'
 
 service = Google::Apis::TaskqueueV1beta2::TaskqueueService.new
 
@@ -28,7 +27,7 @@ taskqueue = 'my-taskqueue'  # TODO: Update placeholder value.
 response = service.get_taskqueue(project, taskqueue)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the TaskQueue API
@@ -66,7 +65,6 @@ service.delete_task(project, taskqueue, task)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/taskqueue_v1beta2'
-require 'json'
 
 service = Google::Apis::TaskqueueV1beta2::TaskqueueService.new
 
@@ -90,7 +88,7 @@ task = 'my-task'  # TODO: Update placeholder value.
 response = service.get_task(project, taskqueue, task)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the TaskQueue API
@@ -99,7 +97,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/taskqueue_v1beta2'
-require 'json'
 
 service = Google::Apis::TaskqueueV1beta2::TaskqueueService.new
 
@@ -123,7 +120,7 @@ request_body = Google::Apis::TaskqueueV1beta2::Task.new
 response = service.insert_task(project, taskqueue, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the TaskQueue API
@@ -132,7 +129,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/taskqueue_v1beta2'
-require 'json'
 
 service = Google::Apis::TaskqueueV1beta2::TaskqueueService.new
 
@@ -159,7 +155,7 @@ lease_secs = 0  # TODO: Update placeholder value.
 response = service.lease_task(project, taskqueue, num_tasks, lease_secs)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the TaskQueue API
@@ -168,7 +164,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/taskqueue_v1beta2'
-require 'json'
 
 service = Google::Apis::TaskqueueV1beta2::TaskqueueService.new
 
@@ -189,7 +184,7 @@ taskqueue = 'my-taskqueue'  # TODO: Update placeholder value.
 response = service.list_tasks(project, taskqueue)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the TaskQueue API
@@ -198,7 +193,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/taskqueue_v1beta2'
-require 'json'
 
 service = Google::Apis::TaskqueueV1beta2::TaskqueueService.new
 
@@ -227,7 +221,7 @@ request_body = Google::Apis::TaskqueueV1beta2::Task.new
 response = service.patch_task(project, taskqueue, task, new_lease_seconds, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the TaskQueue API
@@ -236,7 +230,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/taskqueue_v1beta2'
-require 'json'
 
 service = Google::Apis::TaskqueueV1beta2::TaskqueueService.new
 
@@ -264,4 +257,4 @@ request_body = Google::Apis::TaskqueueV1beta2::Task.new
 response = service.update_task(project, taskqueue, task, new_lease_seconds, request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_translate.v2.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_translate.v2.json.baseline
index 0874d31d32..c9744d3716 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_translate.v2.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_translate.v2.json.baseline
@@ -7,7 +7,6 @@
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/translate_v2'
-require 'json'
 
 service = Google::Apis::TranslateV2::TranslateService.new
 
@@ -19,7 +18,7 @@ q = []  # TODO: Update placeholder value.
 response = service.list_detections(q)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Translate API
@@ -28,7 +27,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/translate_v2'
-require 'json'
 
 service = Google::Apis::TranslateV2::TranslateService.new
 
@@ -37,7 +35,7 @@ service.key = ''  # TODO: Update placeholder with desired API key.
 response = service.list_languages()
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
 # BEFORE RUNNING:
 # ---------------
 # 1. If not already done, enable the Translate API
@@ -46,7 +44,6 @@ puts JSON.pretty_generate(response)
 # 2. Install the Ruby client library by running `gem install google-api-client`
 
 require 'google/apis/translate_v2'
-require 'json'
 
 service = Google::Apis::TranslateV2::TranslateService.new
 
@@ -61,4 +58,4 @@ target = ''  # TODO: Update placeholder value.
 response = service.list_translations(q, target)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_vision.v1.json.baseline b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_vision.v1.json.baseline
index 403b1688c9..aeac8c1a9e 100644
--- a/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_vision.v1.json.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/discoveries/ruby/ruby_vision.v1.json.baseline
@@ -16,7 +16,6 @@
 
 require 'googleauth'
 require 'google/apis/vision_v1'
-require 'json'
 
 service = Google::Apis::VisionV1::VisionService.new
 
@@ -29,4 +28,4 @@ request_body = Google::Apis::VisionV1::BatchAnnotateImagesRequest.new
 response = service.annotate_image(request_body)
 
 # TODO: Change code below to process the `response` object:
-puts JSON.pretty_generate(response)
+puts response.to_json
diff --git a/src/test/java/com/google/api/codegen/testdata/go_doc_library.baseline b/src/test/java/com/google/api/codegen/testdata/go_doc_library.baseline
index 683cbe1b4f..f020cce5b6 100644
--- a/src/test/java/com/google/api/codegen/testdata/go_doc_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/go_doc_library.baseline
@@ -28,11 +28,11 @@ import (
     "google.golang.org/grpc/metadata"
 )
 
-func insertXGoog(ctx context.Context, val string) context.Context {
-    md, _ := metadata.FromContext(ctx)
+func insertXGoog(ctx context.Context, val []string) context.Context {
+    md, _ := metadata.FromOutgoingContext(ctx)
     md = md.Copy()
-    md["x-goog-api-client"] = []string{val}
-    return metadata.NewContext(ctx, md)
+    md["x-goog-api-client"] = val
+    return metadata.NewOutgoingContext(ctx, md)
 }
 
 func DefaultAuthScopes() []string {
diff --git a/src/test/java/com/google/api/codegen/testdata/go_main_library.baseline b/src/test/java/com/google/api/codegen/testdata/go_main_library.baseline
index 927c20af36..b0b3d9a325 100644
--- a/src/test/java/com/google/api/codegen/testdata/go_main_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/go_main_library.baseline
@@ -24,6 +24,7 @@ import (
     "cloud.google.com/go/iam"
     "cloud.google.com/go/internal/version"
     "cloud.google.com/go/longrunning"
+    lroauto "cloud.google.com/go/longrunning/autogen"
     gax "github.com/googleapis/gax-go"
     "golang.org/x/net/context"
     "google.golang.org/api/iterator"
@@ -133,11 +134,16 @@ type Client struct {
     client librarypb.LibraryServiceClient
     labelerClient taggerpb.LabelerClient
 
+    // LROClient is used internally to handle longrunning operations.
+    // It is exposed so that its CallOptions can be modified if required.
+    // Users should not Close this client.
+    LROClient *lroauto.OperationsClient
+
     // The call options for this service.
     CallOptions *CallOptions
 
     // The metadata to be sent with each request.
-    xGoogHeader string
+    xGoogHeader []string
 }
 
 // NewClient creates a new library service client.
@@ -171,6 +177,17 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error
         labelerClient: taggerpb.NewLabelerClient(conn),
     }
     c.SetGoogleClientInfo()
+
+    c.LROClient, err = lroauto.NewOperationsClient(ctx, option.WithGRPCConn(conn))
+    if err != nil {
+        // This error "should not happen", since we are just reusing old connection
+        // and never actually need to dial.
+        // If this does happen, we could leak conn. However, we cannot close conn:
+        // If the user invoked the function with option.WithGRPCConn,
+        // we would close a connection that's still in use.
+        // TODO(pongad): investigate error conditions.
+        return nil, err
+    }
     return c, nil
 }
 
@@ -191,7 +208,7 @@ func (c *Client) Close() error {
 func (c *Client) SetGoogleClientInfo(keyval ...string) {
     kv := append([]string{"gl-go", version.Go()}, keyval...)
     kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
-    c.xGoogHeader = gax.XGoogHeader(kv...)
+    c.xGoogHeader = []string{gax.XGoogHeader(kv...)}
 }
 
 // LibraryShelfPath returns the path for the shelf resource.
@@ -685,8 +702,7 @@ func (c *Client) GetBigBook(ctx context.Context, req *librarypb.GetBookRequest,
         return nil, err
     }
     return &GetBigBookOperation{
-        lro: longrunning.InternalNewOperation(c.Connection(), resp),
-        xGoogHeader: c.xGoogHeader,
+        lro: longrunning.InternalNewOperation(c.LROClient, resp),
     }, nil
 }
 
@@ -704,8 +720,7 @@ func (c *Client) GetBigNothing(ctx context.Context, req *librarypb.GetBookReques
         return nil, err
     }
     return &GetBigNothingOperation{
-        lro: longrunning.InternalNewOperation(c.Connection(), resp),
-        xGoogHeader: c.xGoogHeader,
+        lro: longrunning.InternalNewOperation(c.LROClient, resp),
     }, nil
 }
 
@@ -856,27 +871,22 @@ func (it *StringIterator) takeBuf() interface{} {
 // GetBigBookOperation manages a long-running operation from GetBigBook.
 type GetBigBookOperation struct {
     lro *longrunning.Operation
-
-    // The metadata to be sent with each request.
-    xGoogHeader string
 }
 
 // GetBigBookOperation returns a new GetBigBookOperation from a given name.
 // The name must be that of a previously created GetBigBookOperation, possibly from a different process.
 func (c *Client) GetBigBookOperation(name string) *GetBigBookOperation {
     return &GetBigBookOperation{
-        lro: longrunning.InternalNewOperation(c.Connection(), &longrunningpb.Operation{Name: name}),
-        xGoogHeader: c.xGoogHeader,
+        lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
     }
 }
 
 // Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
 //
 // See documentation of Poll for error-handling information.
-func (op *GetBigBookOperation) Wait(ctx context.Context) (*librarypb.Book, error) {
+func (op *GetBigBookOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*librarypb.Book, error) {
     var resp librarypb.Book
-    ctx = insertXGoog(ctx, op.xGoogHeader)
-    if err := op.lro.Wait(ctx, &resp); err != nil {
+    if err := op.lro.Wait(ctx, &resp, opts...); err != nil {
         return nil, err
     }
     return &resp, nil
@@ -891,10 +901,9 @@ func (op *GetBigBookOperation) Wait(ctx context.Context) (*librarypb.Book, error
 // If Poll succeeds and the operation has completed successfully,
 // op.Done will return true, and the response of the operation is returned.
 // If Poll succeeds and the operation has not completed, the returned response and error are both nil.
-func (op *GetBigBookOperation) Poll(ctx context.Context) (*librarypb.Book, error) {
+func (op *GetBigBookOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*librarypb.Book, error) {
     var resp librarypb.Book
-    ctx = insertXGoog(ctx, op.xGoogHeader)
-    if err := op.lro.Poll(ctx, &resp); err != nil {
+    if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
         return nil, err
     }
     if !op.Done() {
@@ -933,34 +942,28 @@ func (op *GetBigBookOperation) Name() string {
 // Clients can use Poll or other methods to check whether the cancellation succeeded or whether the operation
 // completed despite cancellation. On successful cancellation, the operation is not deleted;
 // instead, op.Poll returns an error with code Canceled.
-func (op *GetBigBookOperation) Cancel(ctx context.Context) error {
-    ctx = insertXGoog(ctx, op.xGoogHeader)
-    return op.lro.Cancel(ctx)
+func (op *GetBigBookOperation) Cancel(ctx context.Context, opts ...gax.CallOption) error {
+    return op.lro.Cancel(ctx, opts...)
 }
 
-// GetBigNothingOperation manages a long-running operation with no result.
+// GetBigNothingOperation manages a long-running operation from GetBigNothing.
 type GetBigNothingOperation struct {
     lro *longrunning.Operation
-
-    // The metadata to be sent with each request.
-    xGoogHeader string
 }
 
 // GetBigNothingOperation returns a new GetBigNothingOperation from a given name.
 // The name must be that of a previously created GetBigNothingOperation, possibly from a different process.
 func (c *Client) GetBigNothingOperation(name string) *GetBigNothingOperation {
     return &GetBigNothingOperation{
-        lro: longrunning.InternalNewOperation(c.Connection(), &longrunningpb.Operation{Name: name}),
-        xGoogHeader: c.xGoogHeader,
+        lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
     }
 }
 
 // Wait blocks until the long-running operation is completed, returning any error encountered.
 //
 // See documentation of Poll for error-handling information.
-func (op *GetBigNothingOperation) Wait(ctx context.Context) error {
-    ctx = insertXGoog(ctx, op.xGoogHeader)
-    return op.lro.Wait(ctx, nil)
+func (op *GetBigNothingOperation) Wait(ctx context.Context, opts ...gax.CallOption) error {
+    return op.lro.Wait(ctx, nil, opts...)
 }
 
 // Poll fetches the latest state of the long-running operation.
@@ -970,9 +973,8 @@ func (op *GetBigNothingOperation) Wait(ctx context.Context) error {
 // If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
 // the operation has completed with failure, the error is returned and op.Done will return true.
 // If Poll succeeds and the operation has completed successfully, op.Done will return true.
-func (op *GetBigNothingOperation) Poll(ctx context.Context) error {
-    ctx = insertXGoog(ctx, op.xGoogHeader)
-    return op.lro.Poll(ctx, nil)
+func (op *GetBigNothingOperation) Poll(ctx context.Context, opts ...gax.CallOption) error {
+    return op.lro.Poll(ctx, nil, opts...)
 }
 
 // Metadata returns metadata associated with the long-running operation.
@@ -1004,7 +1006,6 @@ func (op *GetBigNothingOperation) Name() string {
 // Delete deletes a long-running operation.
 // This method indicates that the client is no longer interested in the operation result.
 // It does not cancel the operation.
-func (op *GetBigNothingOperation) Delete(ctx context.Context) error {
-    ctx = insertXGoog(ctx, op.xGoogHeader)
-    return op.lro.Delete(ctx)
+func (op *GetBigNothingOperation) Delete(ctx context.Context, opts ...gax.CallOption) error {
+    return op.lro.Delete(ctx, opts...)
 }
diff --git a/src/test/java/com/google/api/codegen/testdata/go_mock_library.baseline b/src/test/java/com/google/api/codegen/testdata/go_mock_library.baseline
index daec9c98c1..6190e146d2 100644
--- a/src/test/java/com/google/api/codegen/testdata/go_mock_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/go_mock_library.baseline
@@ -26,10 +26,12 @@ import (
 
 import (
     "flag"
+    "fmt"
     "io"
     "log"
     "net"
     "os"
+    "strings"
     "testing"
 
     "github.com/golang/protobuf/proto"
@@ -39,6 +41,7 @@ import (
     status "google.golang.org/genproto/googleapis/rpc/status"
     "google.golang.org/grpc"
     "google.golang.org/grpc/codes"
+    "google.golang.org/grpc/metadata"
 )
 
 var _ = io.EOF
@@ -60,7 +63,11 @@ type mockLibraryServer struct {
     resps []proto.Message
 }
 
-func (s *mockLibraryServer) CreateShelf(_ context.Context, req *librarypb.CreateShelfRequest) (*librarypb.Shelf, error) {
+func (s *mockLibraryServer) CreateShelf(ctx context.Context, req *librarypb.CreateShelfRequest) (*librarypb.Shelf, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -68,7 +75,11 @@ func (s *mockLibraryServer) CreateShelf(_ context.Context, req *librarypb.Create
     return s.resps[0].(*librarypb.Shelf), nil
 }
 
-func (s *mockLibraryServer) GetShelf(_ context.Context, req *librarypb.GetShelfRequest) (*librarypb.Shelf, error) {
+func (s *mockLibraryServer) GetShelf(ctx context.Context, req *librarypb.GetShelfRequest) (*librarypb.Shelf, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -76,7 +87,11 @@ func (s *mockLibraryServer) GetShelf(_ context.Context, req *librarypb.GetShelfR
     return s.resps[0].(*librarypb.Shelf), nil
 }
 
-func (s *mockLibraryServer) ListShelves(_ context.Context, req *librarypb.ListShelvesRequest) (*librarypb.ListShelvesResponse, error) {
+func (s *mockLibraryServer) ListShelves(ctx context.Context, req *librarypb.ListShelvesRequest) (*librarypb.ListShelvesResponse, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -84,7 +99,11 @@ func (s *mockLibraryServer) ListShelves(_ context.Context, req *librarypb.ListSh
     return s.resps[0].(*librarypb.ListShelvesResponse), nil
 }
 
-func (s *mockLibraryServer) DeleteShelf(_ context.Context, req *librarypb.DeleteShelfRequest) (*emptypb.Empty, error) {
+func (s *mockLibraryServer) DeleteShelf(ctx context.Context, req *librarypb.DeleteShelfRequest) (*emptypb.Empty, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -92,7 +111,11 @@ func (s *mockLibraryServer) DeleteShelf(_ context.Context, req *librarypb.Delete
     return s.resps[0].(*emptypb.Empty), nil
 }
 
-func (s *mockLibraryServer) MergeShelves(_ context.Context, req *librarypb.MergeShelvesRequest) (*librarypb.Shelf, error) {
+func (s *mockLibraryServer) MergeShelves(ctx context.Context, req *librarypb.MergeShelvesRequest) (*librarypb.Shelf, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -100,7 +123,11 @@ func (s *mockLibraryServer) MergeShelves(_ context.Context, req *librarypb.Merge
     return s.resps[0].(*librarypb.Shelf), nil
 }
 
-func (s *mockLibraryServer) CreateBook(_ context.Context, req *librarypb.CreateBookRequest) (*librarypb.Book, error) {
+func (s *mockLibraryServer) CreateBook(ctx context.Context, req *librarypb.CreateBookRequest) (*librarypb.Book, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -108,7 +135,11 @@ func (s *mockLibraryServer) CreateBook(_ context.Context, req *librarypb.CreateB
     return s.resps[0].(*librarypb.Book), nil
 }
 
-func (s *mockLibraryServer) PublishSeries(_ context.Context, req *librarypb.PublishSeriesRequest) (*librarypb.PublishSeriesResponse, error) {
+func (s *mockLibraryServer) PublishSeries(ctx context.Context, req *librarypb.PublishSeriesRequest) (*librarypb.PublishSeriesResponse, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -116,7 +147,11 @@ func (s *mockLibraryServer) PublishSeries(_ context.Context, req *librarypb.Publ
     return s.resps[0].(*librarypb.PublishSeriesResponse), nil
 }
 
-func (s *mockLibraryServer) GetBook(_ context.Context, req *librarypb.GetBookRequest) (*librarypb.Book, error) {
+func (s *mockLibraryServer) GetBook(ctx context.Context, req *librarypb.GetBookRequest) (*librarypb.Book, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -124,7 +159,11 @@ func (s *mockLibraryServer) GetBook(_ context.Context, req *librarypb.GetBookReq
     return s.resps[0].(*librarypb.Book), nil
 }
 
-func (s *mockLibraryServer) ListBooks(_ context.Context, req *librarypb.ListBooksRequest) (*librarypb.ListBooksResponse, error) {
+func (s *mockLibraryServer) ListBooks(ctx context.Context, req *librarypb.ListBooksRequest) (*librarypb.ListBooksResponse, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -132,7 +171,11 @@ func (s *mockLibraryServer) ListBooks(_ context.Context, req *librarypb.ListBook
     return s.resps[0].(*librarypb.ListBooksResponse), nil
 }
 
-func (s *mockLibraryServer) DeleteBook(_ context.Context, req *librarypb.DeleteBookRequest) (*emptypb.Empty, error) {
+func (s *mockLibraryServer) DeleteBook(ctx context.Context, req *librarypb.DeleteBookRequest) (*emptypb.Empty, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -140,7 +183,11 @@ func (s *mockLibraryServer) DeleteBook(_ context.Context, req *librarypb.DeleteB
     return s.resps[0].(*emptypb.Empty), nil
 }
 
-func (s *mockLibraryServer) UpdateBook(_ context.Context, req *librarypb.UpdateBookRequest) (*librarypb.Book, error) {
+func (s *mockLibraryServer) UpdateBook(ctx context.Context, req *librarypb.UpdateBookRequest) (*librarypb.Book, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -148,7 +195,11 @@ func (s *mockLibraryServer) UpdateBook(_ context.Context, req *librarypb.UpdateB
     return s.resps[0].(*librarypb.Book), nil
 }
 
-func (s *mockLibraryServer) MoveBook(_ context.Context, req *librarypb.MoveBookRequest) (*librarypb.Book, error) {
+func (s *mockLibraryServer) MoveBook(ctx context.Context, req *librarypb.MoveBookRequest) (*librarypb.Book, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -156,7 +207,11 @@ func (s *mockLibraryServer) MoveBook(_ context.Context, req *librarypb.MoveBookR
     return s.resps[0].(*librarypb.Book), nil
 }
 
-func (s *mockLibraryServer) ListStrings(_ context.Context, req *librarypb.ListStringsRequest) (*librarypb.ListStringsResponse, error) {
+func (s *mockLibraryServer) ListStrings(ctx context.Context, req *librarypb.ListStringsRequest) (*librarypb.ListStringsResponse, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -164,7 +219,11 @@ func (s *mockLibraryServer) ListStrings(_ context.Context, req *librarypb.ListSt
     return s.resps[0].(*librarypb.ListStringsResponse), nil
 }
 
-func (s *mockLibraryServer) AddComments(_ context.Context, req *librarypb.AddCommentsRequest) (*emptypb.Empty, error) {
+func (s *mockLibraryServer) AddComments(ctx context.Context, req *librarypb.AddCommentsRequest) (*emptypb.Empty, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -172,7 +231,11 @@ func (s *mockLibraryServer) AddComments(_ context.Context, req *librarypb.AddCom
     return s.resps[0].(*emptypb.Empty), nil
 }
 
-func (s *mockLibraryServer) GetBookFromArchive(_ context.Context, req *librarypb.GetBookFromArchiveRequest) (*librarypb.BookFromArchive, error) {
+func (s *mockLibraryServer) GetBookFromArchive(ctx context.Context, req *librarypb.GetBookFromArchiveRequest) (*librarypb.BookFromArchive, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -180,7 +243,11 @@ func (s *mockLibraryServer) GetBookFromArchive(_ context.Context, req *librarypb
     return s.resps[0].(*librarypb.BookFromArchive), nil
 }
 
-func (s *mockLibraryServer) GetBookFromAnywhere(_ context.Context, req *librarypb.GetBookFromAnywhereRequest) (*librarypb.BookFromAnywhere, error) {
+func (s *mockLibraryServer) GetBookFromAnywhere(ctx context.Context, req *librarypb.GetBookFromAnywhereRequest) (*librarypb.BookFromAnywhere, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -188,7 +255,11 @@ func (s *mockLibraryServer) GetBookFromAnywhere(_ context.Context, req *libraryp
     return s.resps[0].(*librarypb.BookFromAnywhere), nil
 }
 
-func (s *mockLibraryServer) UpdateBookIndex(_ context.Context, req *librarypb.UpdateBookIndexRequest) (*emptypb.Empty, error) {
+func (s *mockLibraryServer) UpdateBookIndex(ctx context.Context, req *librarypb.UpdateBookIndexRequest) (*emptypb.Empty, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -197,6 +268,10 @@ func (s *mockLibraryServer) UpdateBookIndex(_ context.Context, req *librarypb.Up
 }
 
 func (s *mockLibraryServer) StreamShelves(req *librarypb.StreamShelvesRequest, stream librarypb.LibraryService_StreamShelvesServer) error {
+    md, _ := metadata.FromIncomingContext(stream.Context())
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return s.err
@@ -210,6 +285,10 @@ func (s *mockLibraryServer) StreamShelves(req *librarypb.StreamShelvesRequest, s
 }
 
 func (s *mockLibraryServer) StreamBooks(req *librarypb.StreamBooksRequest, stream librarypb.LibraryService_StreamBooksServer) error {
+    md, _ := metadata.FromIncomingContext(stream.Context())
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return s.err
@@ -223,6 +302,10 @@ func (s *mockLibraryServer) StreamBooks(req *librarypb.StreamBooksRequest, strea
 }
 
 func (s *mockLibraryServer) DiscussBook(stream librarypb.LibraryService_DiscussBookServer) error {
+    md, _ := metadata.FromIncomingContext(stream.Context())
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     for {
         if req, err := stream.Recv(); err == io.EOF {
             break
@@ -244,6 +327,10 @@ func (s *mockLibraryServer) DiscussBook(stream librarypb.LibraryService_DiscussB
 }
 
 func (s *mockLibraryServer) MonologAboutBook(stream librarypb.LibraryService_MonologAboutBookServer) error {
+    md, _ := metadata.FromIncomingContext(stream.Context())
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     for {
         if req, err := stream.Recv(); err == io.EOF {
             break
@@ -259,7 +346,11 @@ func (s *mockLibraryServer) MonologAboutBook(stream librarypb.LibraryService_Mon
     return stream.SendAndClose(s.resps[0].(*librarypb.Comment))
 }
 
-func (s *mockLibraryServer) FindRelatedBooks(_ context.Context, req *librarypb.FindRelatedBooksRequest) (*librarypb.FindRelatedBooksResponse, error) {
+func (s *mockLibraryServer) FindRelatedBooks(ctx context.Context, req *librarypb.FindRelatedBooksRequest) (*librarypb.FindRelatedBooksResponse, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -267,7 +358,11 @@ func (s *mockLibraryServer) FindRelatedBooks(_ context.Context, req *librarypb.F
     return s.resps[0].(*librarypb.FindRelatedBooksResponse), nil
 }
 
-func (s *mockLibraryServer) AddTag(_ context.Context, req *taggerpb.AddTagRequest) (*taggerpb.AddTagResponse, error) {
+func (s *mockLibraryServer) AddTag(ctx context.Context, req *taggerpb.AddTagRequest) (*taggerpb.AddTagResponse, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -275,7 +370,11 @@ func (s *mockLibraryServer) AddTag(_ context.Context, req *taggerpb.AddTagReques
     return s.resps[0].(*taggerpb.AddTagResponse), nil
 }
 
-func (s *mockLibraryServer) GetBigBook(_ context.Context, req *librarypb.GetBookRequest) (*longrunningpb.Operation, error) {
+func (s *mockLibraryServer) GetBigBook(ctx context.Context, req *librarypb.GetBookRequest) (*longrunningpb.Operation, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -283,7 +382,11 @@ func (s *mockLibraryServer) GetBigBook(_ context.Context, req *librarypb.GetBook
     return s.resps[0].(*longrunningpb.Operation), nil
 }
 
-func (s *mockLibraryServer) GetBigNothing(_ context.Context, req *librarypb.GetBookRequest) (*longrunningpb.Operation, error) {
+func (s *mockLibraryServer) GetBigNothing(ctx context.Context, req *librarypb.GetBookRequest) (*longrunningpb.Operation, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -291,7 +394,11 @@ func (s *mockLibraryServer) GetBigNothing(_ context.Context, req *librarypb.GetB
     return s.resps[0].(*longrunningpb.Operation), nil
 }
 
-func (s *mockLibraryServer) TestOptionalRequiredFlatteningParams(_ context.Context, req *librarypb.TestOptionalRequiredFlatteningParamsRequest) (*librarypb.TestOptionalRequiredFlatteningParamsResponse, error) {
+func (s *mockLibraryServer) TestOptionalRequiredFlatteningParams(ctx context.Context, req *librarypb.TestOptionalRequiredFlatteningParamsRequest) (*librarypb.TestOptionalRequiredFlatteningParamsResponse, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
@@ -314,7 +421,11 @@ type mockLabelerServer struct {
     resps []proto.Message
 }
 
-func (s *mockLabelerServer) AddLabel(_ context.Context, req *taggerpb.AddLabelRequest) (*taggerpb.AddLabelResponse, error) {
+func (s *mockLabelerServer) AddLabel(ctx context.Context, req *taggerpb.AddLabelRequest) (*taggerpb.AddLabelResponse, error) {
+    md, _ := metadata.FromIncomingContext(ctx)
+    if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
+        return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
+    }
     s.reqs = append(s.reqs, req)
     if s.err != nil {
         return nil, s.err
diff --git a/src/test/java/com/google/api/codegen/testdata/go_smoke_library.baseline b/src/test/java/com/google/api/codegen/testdata/go_smoke_library.baseline
index 842059f7dc..5486646af6 100644
--- a/src/test/java/com/google/api/codegen/testdata/go_smoke_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/go_smoke_library.baseline
@@ -22,7 +22,9 @@ import (
 )
 
 import (
+  "strconv"
   "testing"
+  "time"
 
   "cloud.google.com/go/internal/testutil"
   "golang.org/x/net/context"
@@ -31,6 +33,8 @@ import (
 )
 
 var _ = iterator.Done
+var _ = strconv.FormatUint
+var _ = time.Now
 
 func TestLibraryServiceSmoke(t *testing.T) {
   if testing.Short() {
@@ -43,15 +47,14 @@ func TestLibraryServiceSmoke(t *testing.T) {
   }
 
   projectId := testutil.ProjID()
-  uidSpace := testutil.NewUIDSpace("TestLibraryServiceSmoke")
-  _, _ = projectId, uidSpace
+  _ = projectId
 
   c, err := NewClient(ctx, option.WithTokenSource(ts))
   if err != nil {
     t.Fatal(err)
   }
 
-  var formattedName string = LibraryBookPath("testShelf-" + uidSpace.New() + "", projectId)
+  var formattedName string = LibraryBookPath("testShelf-" + strconv.FormatInt(time.Now().UnixNano(), 10) + "", projectId)
   var rating librarypb.Book_Rating = librarypb.Book_GOOD
   var book = &librarypb.Book{
       Rating: rating,
diff --git a/src/test/java/com/google/api/codegen/testdata/java_main_library.baseline b/src/test/java/com/google/api/codegen/testdata/java_main_library.baseline
index 8e9c0ef67a..22f0be044a 100644
--- a/src/test/java/com/google/api/codegen/testdata/java_main_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/java_main_library.baseline
@@ -17,7 +17,9 @@
 package com.google.gcloud.pubsub.spi;
 
 import com.google.api.core.BetaApi;
+import com.google.api.gax.core.CredentialsProvider;
 import com.google.api.gax.grpc.ChannelAndExecutor;
+import com.google.api.gax.grpc.ClientContext;
 import com.google.api.gax.grpc.FixedChannelProvider;
 import com.google.api.gax.grpc.FixedExecutorProvider;
 import com.google.api.gax.grpc.OperationCallable;
@@ -26,6 +28,7 @@ import com.google.api.gax.grpc.StreamingCallable;
 import com.google.api.gax.grpc.UnaryCallable;
 import com.google.api.pathtemplate.PathTemplate;
 import com.google.api.resourcenames.ResourceName;
+import com.google.auth.Credentials;
 import com.google.example.library.v1.AddCommentsRequest;
 import com.google.example.library.v1.ArchivedBookName;
 import com.google.example.library.v1.Book;
@@ -82,7 +85,9 @@ import com.google.tagger.v1.AddLabelRequest;
 import com.google.tagger.v1.AddLabelResponse;
 import com.google.tagger.v1.AddTagRequest;
 import com.google.tagger.v1.AddTagResponse;
+import io.grpc.CallCredentials;
 import io.grpc.ManagedChannel;
+import io.grpc.auth.MoreCallCredentials;
 import java.io.Closeable;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -151,12 +156,10 @@ import javax.annotation.Generated;
  *
  * 
  * 
- * InstantiatingChannelProvider channelProvider =
- *     LibrarySettings.defaultChannelProviderBuilder()
+ * LibrarySettings librarySettings =
+ *     LibrarySettings.defaultBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
- * LibrarySettings librarySettings =
- *     LibrarySettings.defaultBuilder().setChannelProvider(channelProvider).build();
  * LibraryClient libraryClient =
  *     LibraryClient.create(librarySettings);
  * 
@@ -165,8 +168,6 @@ import javax.annotation.Generated;
 @Generated("by GAPIC")
 public class LibraryClient implements AutoCloseable {
   private final LibrarySettings settings;
-  private final ScheduledExecutorService executor;
-  private final ManagedChannel channel;
   private final OperationsClient operationsClient;
   private final List closeables = new ArrayList<>();
 
@@ -229,9 +230,8 @@ public class LibraryClient implements AutoCloseable {
    */
   protected LibraryClient(LibrarySettings settings) throws IOException {
     this.settings = settings;
-    ChannelAndExecutor channelAndExecutor = settings.getChannelAndExecutor();
-    this.executor = channelAndExecutor.getExecutor();
-    this.channel = channelAndExecutor.getChannel();
+
+    ClientContext clientContext = ClientContext.create(settings);
 
     FixedExecutorProvider executorProvider = FixedExecutorProvider.create(this.executor);
     FixedChannelProvider channelProvider = FixedChannelProvider.create(this.channel);
@@ -239,65 +239,49 @@ public class LibraryClient implements AutoCloseable {
         OperationsSettings.defaultBuilder()
             .setExecutorProvider(executorProvider)
             .setChannelProvider(channelProvider)
+            .setCredentialsProvider(credentialsProvider)
             .build();
     this.operationsClient = OperationsClient.create(operationsSettings);
 
-    this.createShelfCallable = UnaryCallable.create(settings.createShelfSettings(), this.channel, this.executor);
-    this.getShelfCallable = UnaryCallable.create(settings.getShelfSettings(), this.channel, this.executor);
-    this.listShelvesCallable = UnaryCallable.create(settings.listShelvesSettings(), this.channel, this.executor);
+    this.createShelfCallable = UnaryCallable.create(settings.createShelfSettings(), clientContext);
+    this.getShelfCallable = UnaryCallable.create(settings.getShelfSettings(), clientContext);
+    this.listShelvesCallable = UnaryCallable.create(settings.listShelvesSettings(), clientContext);
     this.listShelvesPagedCallable =
-        UnaryCallable.createPagedVariant(settings.listShelvesSettings(), this.channel, this.executor);
-    this.deleteShelfCallable = UnaryCallable.create(settings.deleteShelfSettings(), this.channel, this.executor);
-    this.mergeShelvesCallable = UnaryCallable.create(settings.mergeShelvesSettings(), this.channel, this.executor);
-    this.createBookCallable = UnaryCallable.create(settings.createBookSettings(), this.channel, this.executor);
-    this.publishSeriesCallable = UnaryCallable.create(settings.publishSeriesSettings(), this.channel, this.executor);
-    this.getBookCallable = UnaryCallable.create(settings.getBookSettings(), this.channel, this.executor);
-    this.listBooksCallable = UnaryCallable.create(settings.listBooksSettings(), this.channel, this.executor);
+        UnaryCallable.createPagedVariant(settings.listShelvesSettings(), clientContext);
+    this.deleteShelfCallable = UnaryCallable.create(settings.deleteShelfSettings(), clientContext);
+    this.mergeShelvesCallable = UnaryCallable.create(settings.mergeShelvesSettings(), clientContext);
+    this.createBookCallable = UnaryCallable.create(settings.createBookSettings(), clientContext);
+    this.publishSeriesCallable = UnaryCallable.create(settings.publishSeriesSettings(), clientContext);
+    this.getBookCallable = UnaryCallable.create(settings.getBookSettings(), clientContext);
+    this.listBooksCallable = UnaryCallable.create(settings.listBooksSettings(), clientContext);
     this.listBooksPagedCallable =
-        UnaryCallable.createPagedVariant(settings.listBooksSettings(), this.channel, this.executor);
-    this.deleteBookCallable = UnaryCallable.create(settings.deleteBookSettings(), this.channel, this.executor);
-    this.updateBookCallable = UnaryCallable.create(settings.updateBookSettings(), this.channel, this.executor);
-    this.moveBookCallable = UnaryCallable.create(settings.moveBookSettings(), this.channel, this.executor);
-    this.listStringsCallable = UnaryCallable.create(settings.listStringsSettings(), this.channel, this.executor);
+        UnaryCallable.createPagedVariant(settings.listBooksSettings(), clientContext);
+    this.deleteBookCallable = UnaryCallable.create(settings.deleteBookSettings(), clientContext);
+    this.updateBookCallable = UnaryCallable.create(settings.updateBookSettings(), clientContext);
+    this.moveBookCallable = UnaryCallable.create(settings.moveBookSettings(), clientContext);
+    this.listStringsCallable = UnaryCallable.create(settings.listStringsSettings(), clientContext);
     this.listStringsPagedCallable =
-        UnaryCallable.createPagedVariant(settings.listStringsSettings(), this.channel, this.executor);
-    this.addCommentsCallable = UnaryCallable.create(settings.addCommentsSettings(), this.channel, this.executor);
-    this.getBookFromArchiveCallable = UnaryCallable.create(settings.getBookFromArchiveSettings(), this.channel, this.executor);
-    this.getBookFromAnywhereCallable = UnaryCallable.create(settings.getBookFromAnywhereSettings(), this.channel, this.executor);
-    this.updateBookIndexCallable = UnaryCallable.create(settings.updateBookIndexSettings(), this.channel, this.executor);
+        UnaryCallable.createPagedVariant(settings.listStringsSettings(), clientContext);
+    this.addCommentsCallable = UnaryCallable.create(settings.addCommentsSettings(), clientContext);
+    this.getBookFromArchiveCallable = UnaryCallable.create(settings.getBookFromArchiveSettings(), clientContext);
+    this.getBookFromAnywhereCallable = UnaryCallable.create(settings.getBookFromAnywhereSettings(), clientContext);
+    this.updateBookIndexCallable = UnaryCallable.create(settings.updateBookIndexSettings(), clientContext);
     this.streamShelvesCallable = StreamingCallable.create(settings.streamShelvesSettings(), this.channel);
     this.streamBooksCallable = StreamingCallable.create(settings.streamBooksSettings(), this.channel);
     this.discussBookCallable = StreamingCallable.create(settings.discussBookSettings(), this.channel);
     this.monologAboutBookCallable = StreamingCallable.create(settings.monologAboutBookSettings(), this.channel);
-    this.findRelatedBooksCallable = UnaryCallable.create(settings.findRelatedBooksSettings(), this.channel, this.executor);
+    this.findRelatedBooksCallable = UnaryCallable.create(settings.findRelatedBooksSettings(), clientContext);
     this.findRelatedBooksPagedCallable =
-        UnaryCallable.createPagedVariant(settings.findRelatedBooksSettings(), this.channel, this.executor);
-    this.addTagCallable = UnaryCallable.create(settings.addTagSettings(), this.channel, this.executor);
-    this.addLabelCallable = UnaryCallable.create(settings.addLabelSettings(), this.channel, this.executor);
-    this.getBigBookCallable = UnaryCallable.create(settings.getBigBookSettings().getInitialCallSettings(), this.channel, this.executor);
-    this.getBigBookOperationCallable = OperationCallable.create(settings.getBigBookSettings(),this.channel, this.executor, this.operationsClient);
-    this.getBigNothingCallable = UnaryCallable.create(settings.getBigNothingSettings().getInitialCallSettings(), this.channel, this.executor);
-    this.getBigNothingOperationCallable = OperationCallable.create(settings.getBigNothingSettings(),this.channel, this.executor, this.operationsClient);
-    this.testOptionalRequiredFlatteningParamsCallable = UnaryCallable.create(settings.testOptionalRequiredFlatteningParamsSettings(), this.channel, this.executor);
-
-    if (settings.getChannelProvider().shouldAutoClose()) {
-      closeables.add(
-        new Closeable() {
-          @Override
-          public void close() throws IOException {
-            channel.shutdown();
-          }
-        });
-    }
-    if (settings.getExecutorProvider().shouldAutoClose()) {
-      closeables.add(
-        new Closeable() {
-          @Override
-          public void close() throws IOException {
-            executor.shutdown();
-          }
-        });
-    }
+        UnaryCallable.createPagedVariant(settings.findRelatedBooksSettings(), clientContext);
+    this.addTagCallable = UnaryCallable.create(settings.addTagSettings(), clientContext);
+    this.addLabelCallable = UnaryCallable.create(settings.addLabelSettings(), clientContext);
+    this.getBigBookCallable = UnaryCallable.create(settings.getBigBookSettings().getInitialCallSettings(), clientContext);
+    this.getBigBookOperationCallable = OperationCallable.create(settings.getBigBookSettings(),clientContext, this.operationsClient);
+    this.getBigNothingCallable = UnaryCallable.create(settings.getBigNothingSettings().getInitialCallSettings(), clientContext);
+    this.getBigNothingOperationCallable = OperationCallable.create(settings.getBigNothingSettings(),clientContext, this.operationsClient);
+    this.testOptionalRequiredFlatteningParamsCallable = UnaryCallable.create(settings.testOptionalRequiredFlatteningParamsSettings(), clientContext);
+
+    closeables.addAll(clientContext.getCloseables());
   }
 
   public final LibrarySettings getSettings() {
diff --git a/src/test/java/com/google/api/codegen/testdata/java_main_no_path_templates.baseline b/src/test/java/com/google/api/codegen/testdata/java_main_no_path_templates.baseline
index 19296cceb1..46e0c0e5af 100644
--- a/src/test/java/com/google/api/codegen/testdata/java_main_no_path_templates.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/java_main_no_path_templates.baseline
@@ -17,12 +17,17 @@
 package com.google.gcloud.example;
 
 import com.google.api.core.BetaApi;
+import com.google.api.gax.core.CredentialsProvider;
 import com.google.api.gax.grpc.ChannelAndExecutor;
+import com.google.api.gax.grpc.ClientContext;
 import com.google.api.gax.grpc.UnaryCallable;
 import com.google.api.pathtemplate.PathTemplate;
+import com.google.auth.Credentials;
 import com.google.example.noPathTemplates.v1.IncrementRequest;
 import com.google.protobuf.Empty;
+import io.grpc.CallCredentials;
 import io.grpc.ManagedChannel;
+import io.grpc.auth.MoreCallCredentials;
 import java.io.Closeable;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -75,12 +80,10 @@ import javax.annotation.Generated;
  *
  * 
  * 
- * InstantiatingChannelProvider channelProvider =
- *     NoTemplatesApiServiceSettings.defaultChannelProviderBuilder()
+ * NoTemplatesApiServiceSettings noTemplatesApiServiceSettings =
+ *     NoTemplatesApiServiceSettings.defaultBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
- * NoTemplatesApiServiceSettings noTemplatesApiServiceSettings =
- *     NoTemplatesApiServiceSettings.defaultBuilder().setChannelProvider(channelProvider).build();
  * NoTemplatesApiServiceClient noTemplatesApiServiceClient =
  *     NoTemplatesApiServiceClient.create(noTemplatesApiServiceSettings);
  * 
@@ -90,8 +93,6 @@ import javax.annotation.Generated;
 @BetaApi
 public class NoTemplatesApiServiceClient implements AutoCloseable {
   private final NoTemplatesApiServiceSettings settings;
-  private final ScheduledExecutorService executor;
-  private final ManagedChannel channel;
   private final List closeables = new ArrayList<>();
 
   private final UnaryCallable incrementCallable;
@@ -115,31 +116,13 @@ public class NoTemplatesApiServiceClient implements AutoCloseable {
    */
   protected NoTemplatesApiServiceClient(NoTemplatesApiServiceSettings settings) throws IOException {
     this.settings = settings;
-    ChannelAndExecutor channelAndExecutor = settings.getChannelAndExecutor();
-    this.executor = channelAndExecutor.getExecutor();
-    this.channel = channelAndExecutor.getChannel();
 
+    ClientContext clientContext = ClientContext.create(settings);
 
-    this.incrementCallable = UnaryCallable.create(settings.incrementSettings(), this.channel, this.executor);
 
-    if (settings.getChannelProvider().shouldAutoClose()) {
-      closeables.add(
-        new Closeable() {
-          @Override
-          public void close() throws IOException {
-            channel.shutdown();
-          }
-        });
-    }
-    if (settings.getExecutorProvider().shouldAutoClose()) {
-      closeables.add(
-        new Closeable() {
-          @Override
-          public void close() throws IOException {
-            executor.shutdown();
-          }
-        });
-    }
+    this.incrementCallable = UnaryCallable.create(settings.incrementSettings(), clientContext);
+
+    closeables.addAll(clientContext.getCloseables());
   }
 
   public final NoTemplatesApiServiceSettings getSettings() {
diff --git a/src/test/java/com/google/api/codegen/testdata/java_settings_library.baseline b/src/test/java/com/google/api/codegen/testdata/java_settings_library.baseline
index 47257882d3..d182d0a7aa 100644
--- a/src/test/java/com/google/api/codegen/testdata/java_settings_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/java_settings_library.baseline
@@ -572,8 +572,7 @@ public class LibrarySettings extends ClientSettings {
   public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder() {
     return InstantiatingChannelProvider.newBuilder()
         .setEndpoint(getDefaultEndpoint())
-        .setGeneratorHeader(DEFAULT_GAPIC_NAME, getGapicVersion())
-        .setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+        .setGeneratorHeader(DEFAULT_GAPIC_NAME, getGapicVersion());
   }
 
   private static String getGapicVersion() {
@@ -608,7 +607,8 @@ public class LibrarySettings extends ClientSettings {
 
   private LibrarySettings(Builder settingsBuilder) throws IOException {
     super(settingsBuilder.getExecutorProvider(),
-          settingsBuilder.getChannelProvider());
+          settingsBuilder.getChannelProvider(),
+          settingsBuilder.getCredentialsProvider());
 
     createShelfSettings = settingsBuilder.createShelfSettings().build();
     getShelfSettings = settingsBuilder.getShelfSettings().build();
@@ -1016,6 +1016,7 @@ public class LibrarySettings extends ClientSettings {
 
     private Builder() {
       super(defaultChannelProviderBuilder().build());
+      setCredentialsProvider(defaultCredentialsProviderBuilder().build());
 
       createShelfSettings = SimpleCallSettings.newBuilder(METHOD_CREATE_SHELF);
 
@@ -1297,6 +1298,12 @@ public class LibrarySettings extends ClientSettings {
       return this;
     }
 
+    @Override
+    public Builder setCredentialsProvider(CredentialsProvider credentialsProvider) {
+      super.setCredentialsProvider(credentialsProvider);
+      return this;
+    }
+
     /**
      * Applies the given settings to all of the unary API methods in this service. Only
      * values that are non-null will be applied, so this method is not capable
diff --git a/src/test/java/com/google/api/codegen/testdata/java_settings_no_path_templates.baseline b/src/test/java/com/google/api/codegen/testdata/java_settings_no_path_templates.baseline
index 08ab8f627a..5484383396 100644
--- a/src/test/java/com/google/api/codegen/testdata/java_settings_no_path_templates.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/java_settings_no_path_templates.baseline
@@ -99,8 +99,7 @@ public class NoTemplatesApiServiceSettings extends ClientSettings {
   /** Returns a builder for the default ChannelProvider for this service. */
   public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder() {
     return InstantiatingChannelProvider.newBuilder()
-        .setGeneratorHeader(DEFAULT_GAPIC_NAME, getGapicVersion())
-        .setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+        .setGeneratorHeader(DEFAULT_GAPIC_NAME, getGapicVersion());
   }
 
   private static String getGapicVersion() {
@@ -135,7 +134,8 @@ public class NoTemplatesApiServiceSettings extends ClientSettings {
 
   private NoTemplatesApiServiceSettings(Builder settingsBuilder) throws IOException {
     super(settingsBuilder.getExecutorProvider(),
-          settingsBuilder.getChannelProvider());
+          settingsBuilder.getChannelProvider(),
+          settingsBuilder.getCredentialsProvider());
 
     incrementSettings = settingsBuilder.incrementSettings().build();
   }
@@ -208,6 +208,12 @@ public class NoTemplatesApiServiceSettings extends ClientSettings {
       return this;
     }
 
+    @Override
+    public Builder setCredentialsProvider(CredentialsProvider credentialsProvider) {
+      super.setCredentialsProvider(credentialsProvider);
+      return this;
+    }
+
     /**
      * Applies the given settings to all of the unary API methods in this service. Only
      * values that are non-null will be applied, so this method is not capable
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_README_library.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_README_library.baseline
new file mode 100644
index 0000000000..2255e38899
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_README_library.baseline
@@ -0,0 +1,51 @@
+============== file: README.md ==============
+# Node.js Client for Google Example Library API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning))
+
+[Google Example Library API][Product Documentation]: A simple Google Example Library API.
+- [Client Library Documentation][]
+- [Product Documentation][]
+
+## Quick Start
+In order to use this library, you first need to go through the following steps:
+
+1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
+2. [Enable the Google Example Library API.](https://console.cloud.google.com/apis/api/library)
+3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication)
+
+### Installation
+```
+$ npm install --save @google-cloud/library
+```
+
+### Preview
+#### LibraryServiceClient
+```js
+ var libraryV1 = require('@google-cloud/library').v1({
+   // optional auth parameters.
+ });
+
+ var client = libraryV1.libraryServiceClient();
+ var formattedName = client.bookPath("testShelf-" + Date.now().toString(), projectId);
+ var rating = libraryV1.Book.Rating.GOOD;
+ var book = {
+     rating : rating
+ };
+ var request = {
+     name: formattedName,
+     book: book
+ };
+ client.updateBook(request).then(function(responses) {
+     var response = responses[0];
+     // doThingsWith(response)
+ }).catch(function(err) {
+     console.error(err);
+ });
+```
+
+### Next Steps
+- Read the [Client Library Documentation][] for Google Example Library API to see other available methods on the client.
+- Read the [Google Example Library API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
+- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/README.md) to see the full list of Cloud APIs that we cover.
+
+[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/library
+[Product Documentation]: https://cloud.google.com/library
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_README_no_path_templates.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_README_no_path_templates.baseline
new file mode 100644
index 0000000000..eed9248f8d
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_README_no_path_templates.baseline
@@ -0,0 +1,26 @@
+============== file: README.md ==============
+# Node.js Client for Google Fake API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning))
+
+[Google Fake API][Product Documentation]: Tests no path templates
+- [Client Library Documentation][]
+- [Product Documentation][]
+
+## Quick Start
+In order to use this library, you first need to go through the following steps:
+
+1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
+2. [Enable the Google Fake API.](https://console.cloud.google.com/apis/api/library)
+3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication)
+
+### Installation
+```
+$ npm install --save example
+```
+
+### Next Steps
+- Read the [Client Library Documentation][] for Google Fake API to see other available methods on the client.
+- Read the [Google Fake API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
+- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/README.md) to see the full list of Cloud APIs that we cover.
+
+[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/library
+[Product Documentation]: https://cloud.google.com/library
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_doc_README_library.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_doc_README_library.baseline
new file mode 100644
index 0000000000..2255e38899
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_doc_README_library.baseline
@@ -0,0 +1,51 @@
+============== file: README.md ==============
+# Node.js Client for Google Example Library API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning))
+
+[Google Example Library API][Product Documentation]: A simple Google Example Library API.
+- [Client Library Documentation][]
+- [Product Documentation][]
+
+## Quick Start
+In order to use this library, you first need to go through the following steps:
+
+1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
+2. [Enable the Google Example Library API.](https://console.cloud.google.com/apis/api/library)
+3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication)
+
+### Installation
+```
+$ npm install --save @google-cloud/library
+```
+
+### Preview
+#### LibraryServiceClient
+```js
+ var libraryV1 = require('@google-cloud/library').v1({
+   // optional auth parameters.
+ });
+
+ var client = libraryV1.libraryServiceClient();
+ var formattedName = client.bookPath("testShelf-" + Date.now().toString(), projectId);
+ var rating = libraryV1.Book.Rating.GOOD;
+ var book = {
+     rating : rating
+ };
+ var request = {
+     name: formattedName,
+     book: book
+ };
+ client.updateBook(request).then(function(responses) {
+     var response = responses[0];
+     // doThingsWith(response)
+ }).catch(function(err) {
+     console.error(err);
+ });
+```
+
+### Next Steps
+- Read the [Client Library Documentation][] for Google Example Library API to see other available methods on the client.
+- Read the [Google Example Library API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
+- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/README.md) to see the full list of Cloud APIs that we cover.
+
+[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/library
+[Product Documentation]: https://cloud.google.com/library
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_doc_index_library.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_doc_index_library.baseline
index 4a6d18e2c0..efc7f9149a 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_doc_index_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_doc_index_library.baseline
@@ -1,12 +1,12 @@
 ============== file: src/v1/index.js ==============
 /*
- * Copyright 2016 Google Inc. All rights reserved.
+ * Copyright 2017, Google Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_doc_package_library.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_doc_package_library.baseline
index 43870b44f1..b17124184f 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_doc_package_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_doc_package_library.baseline
@@ -1,13 +1,29 @@
 ============== file: package.json ==============
 {
-  "url": "https://github.com/googleapis/googleapis",
+  "repository": "GoogleCloudPlatform/google-cloud-node",
   "name": "@google-cloud/library",
   "version": "0.7.1",
   "author": "Google, Inc.",
   "description": "Google Example Library API client for Node.js",
   "main": "src/index.js",
   "files": [
-    "src"
+    "src",
+    "AUTHORS",
+    "CONTRIBUTING",
+    "COPYING"
+  ],
+  "keywords": [
+    "google apis client",
+    "google api client",
+    "google apis",
+    "google api",
+    "google",
+    "google cloud platform",
+    "google cloud",
+    "cloud",
+    "google library",
+    "library",
+    "Google Example Library API"
   ],
   "dependencies": {
     "google-proto-files": "^0.8.2",
@@ -16,15 +32,16 @@
     "extend": "^3.0.0"
   },
   "devDependencies": {
-    "mocha": "3.2.0",
-    "through2": "2.0.3"
+    "mocha": "^3.2.0",
+    "through2": "^2.0.3"
+  },
+  "scripts": {
+    "test": "mocha",
+    "publish-module": "node ../../scripts/publish.js library"
   },
   "license": "Apache-2.0",
   "engines": {
-    "node": ">=0.12.0"
-  },
-  "scripts": {
-    "test": "mocha"
+    "node": ">=4.0.0"
   }
 }
 
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_doc_version_index_library.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_doc_version_index_library.baseline
index 1a38866ab3..1e9c2ed3fc 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_doc_version_index_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_doc_version_index_library.baseline
@@ -1,12 +1,12 @@
 ============== file: src/index.js ==============
 /*
- * Copyright 2016 Google Inc. All rights reserved.
+ * Copyright 2017, Google Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,5 +16,49 @@
  */
 'use strict';
 
-module.exports.v1 = require('./v1');
+var extend = require('extend');
+var gapic = {
+  v1: require('./v1')
+};
 
+const VERSION = require('../package.json').version;
+
+/**
+ * Create an libraryServiceClient with additional helpers for common
+ * tasks.
+ *
+ * This API represents a simple digital library.  It lets you manage Shelf
+ * resources and Book resources in the library. It defines the following
+ * resource model:
+ *
+ * - The API has a collection of {@link Shelf}
+ *   resources, named ``bookShelves/*``
+ *
+ * - Each Shelf has a collection of {@link Book}
+ *   resources, named `bookShelves/*/books/*`
+ *
+ * Check out [cloud docs!](https://cloud.google.com/library/example/link).
+ * This is [not a cloud link](http://www.google.com).
+ *
+ * Service comment may include special characters: <>&"`'@.
+ *
+ * @param {object=} options - [Configuration object](#/docs).
+ * @param {number=} options.port - The port on which to connect to
+ *     the remote host.
+ * @param {string=} options.servicePath - The domain name of the
+ *     API remote host.
+ */
+function libraryV1(options) {
+  // Define the header options.
+  options = extend({}, options, {
+    libName: 'gccl',
+    libVersion: VERSION
+  });
+
+  // Create the image annotator client with the provided options.
+  var client = gapic.v1(options).libraryServiceClient(options);
+  return client;
+}
+
+module.exports = libraryV1;
+module.exports.v1 = libraryV1;
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_index_library.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_index_library.baseline
index 4a6d18e2c0..efc7f9149a 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_index_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_index_library.baseline
@@ -1,12 +1,12 @@
 ============== file: src/v1/index.js ==============
 /*
- * Copyright 2016 Google Inc. All rights reserved.
+ * Copyright 2017, Google Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_index_no_path_templates.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_index_no_path_templates.baseline
index f1e50f87ae..86987f5481 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_index_no_path_templates.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_index_no_path_templates.baseline
@@ -1,12 +1,12 @@
 ============== file: src/index.js ==============
 /*
- * Copyright 2016 Google Inc. All rights reserved.
+ * Copyright 2017, Google Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_package_library.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_package_library.baseline
index 43870b44f1..b17124184f 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_package_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_package_library.baseline
@@ -1,13 +1,29 @@
 ============== file: package.json ==============
 {
-  "url": "https://github.com/googleapis/googleapis",
+  "repository": "GoogleCloudPlatform/google-cloud-node",
   "name": "@google-cloud/library",
   "version": "0.7.1",
   "author": "Google, Inc.",
   "description": "Google Example Library API client for Node.js",
   "main": "src/index.js",
   "files": [
-    "src"
+    "src",
+    "AUTHORS",
+    "CONTRIBUTING",
+    "COPYING"
+  ],
+  "keywords": [
+    "google apis client",
+    "google api client",
+    "google apis",
+    "google api",
+    "google",
+    "google cloud platform",
+    "google cloud",
+    "cloud",
+    "google library",
+    "library",
+    "Google Example Library API"
   ],
   "dependencies": {
     "google-proto-files": "^0.8.2",
@@ -16,15 +32,16 @@
     "extend": "^3.0.0"
   },
   "devDependencies": {
-    "mocha": "3.2.0",
-    "through2": "2.0.3"
+    "mocha": "^3.2.0",
+    "through2": "^2.0.3"
+  },
+  "scripts": {
+    "test": "mocha",
+    "publish-module": "node ../../scripts/publish.js library"
   },
   "license": "Apache-2.0",
   "engines": {
-    "node": ">=0.12.0"
-  },
-  "scripts": {
-    "test": "mocha"
+    "node": ">=4.0.0"
   }
 }
 
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_package_no_path_templates.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_package_no_path_templates.baseline
index 433ed54781..ac4556299f 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_package_no_path_templates.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_package_no_path_templates.baseline
@@ -1,13 +1,29 @@
 ============== file: package.json ==============
 {
-  "url": "https://github.com/googleapis/googleapis",
+  "repository": "GoogleCloudPlatform/google-cloud-node",
   "name": "example",
   "version": "0.7.1",
   "author": "Google, Inc.",
   "description": "Google Fake API client for Node.js",
   "main": "src/index.js",
   "files": [
-    "src"
+    "src",
+    "AUTHORS",
+    "CONTRIBUTING",
+    "COPYING"
+  ],
+  "keywords": [
+    "google apis client",
+    "google api client",
+    "google apis",
+    "google api",
+    "google",
+    "google cloud platform",
+    "google cloud",
+    "cloud",
+    "google library",
+    "library",
+    "Google Fake API"
   ],
   "dependencies": {
     "google-proto-files": "^0.8.2",
@@ -16,15 +32,16 @@
     "extend": "^3.0.0"
   },
   "devDependencies": {
-    "mocha": "3.2.0",
-    "through2": "2.0.3"
+    "mocha": "^3.2.0",
+    "through2": "^2.0.3"
+  },
+  "scripts": {
+    "test": "mocha",
+    "publish-module": "node ../../scripts/publish.js library"
   },
   "license": "Apache-2.0",
   "engines": {
-    "node": ">=0.12.0"
-  },
-  "scripts": {
-    "test": "mocha"
+    "node": ">=4.0.0"
   }
 }
 
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_test_library.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_test_library.baseline
index 7253ad5a49..4408495e93 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_test_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_test_library.baseline
@@ -1,12 +1,12 @@
 ============== file: test/test.js ==============
 /*
- * Copyright 2016 Google Inc. All rights reserved.
+ * Copyright 2017, Google Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,7 +16,7 @@
  */
 
 var assert = require('assert');
-var libraryV1 = require('../src/').v1();
+var libraryV1 = require('../src/v1')();
 var through2 = require('through2');
 
 var FAKE_STATUS_CODE = 1;
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_test_no_path_templates.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_test_no_path_templates.baseline
index 2404938626..dfe7d84781 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_test_no_path_templates.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_test_no_path_templates.baseline
@@ -1,12 +1,12 @@
 ============== file: test/test.js ==============
 /*
- * Copyright 2016 Google Inc. All rights reserved.
+ * Copyright 2017, Google Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/src/test/java/com/google/api/codegen/testdata/nodejs_version_index_library.baseline b/src/test/java/com/google/api/codegen/testdata/nodejs_version_index_library.baseline
index 1a38866ab3..1e9c2ed3fc 100644
--- a/src/test/java/com/google/api/codegen/testdata/nodejs_version_index_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/nodejs_version_index_library.baseline
@@ -1,12 +1,12 @@
 ============== file: src/index.js ==============
 /*
- * Copyright 2016 Google Inc. All rights reserved.
+ * Copyright 2017, Google Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,5 +16,49 @@
  */
 'use strict';
 
-module.exports.v1 = require('./v1');
+var extend = require('extend');
+var gapic = {
+  v1: require('./v1')
+};
 
+const VERSION = require('../package.json').version;
+
+/**
+ * Create an libraryServiceClient with additional helpers for common
+ * tasks.
+ *
+ * This API represents a simple digital library.  It lets you manage Shelf
+ * resources and Book resources in the library. It defines the following
+ * resource model:
+ *
+ * - The API has a collection of {@link Shelf}
+ *   resources, named ``bookShelves/*``
+ *
+ * - Each Shelf has a collection of {@link Book}
+ *   resources, named `bookShelves/*/books/*`
+ *
+ * Check out [cloud docs!](https://cloud.google.com/library/example/link).
+ * This is [not a cloud link](http://www.google.com).
+ *
+ * Service comment may include special characters: <>&"`'@.
+ *
+ * @param {object=} options - [Configuration object](#/docs).
+ * @param {number=} options.port - The port on which to connect to
+ *     the remote host.
+ * @param {string=} options.servicePath - The domain name of the
+ *     API remote host.
+ */
+function libraryV1(options) {
+  // Define the header options.
+  options = extend({}, options, {
+    libName: 'gccl',
+    libVersion: VERSION
+  });
+
+  // Create the image annotator client with the provided options.
+  var client = gapic.v1(options).libraryServiceClient(options);
+  return client;
+}
+
+module.exports = libraryV1;
+module.exports.v1 = libraryV1;
diff --git a/src/test/java/com/google/api/codegen/testdata/php_main_library.baseline b/src/test/java/com/google/api/codegen/testdata/php_main_library.baseline
index 1e24c7da21..d132e21a67 100644
--- a/src/test/java/com/google/api/codegen/testdata/php_main_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/php_main_library.baseline
@@ -91,7 +91,7 @@ use google\tagger\v1\LabelerGrpcClient;
  * - Each Shelf has a collection of [Book][google.example.library.v1.Book]
  *   resources, named `bookShelves/*/books/*`
  *
- * Check out [cloud docs!](/library/example/link).
+ * Check out [cloud docs!](https://cloud.google.com/library/example/link).
  * This is [not a cloud link](http://www.google.com).
  *
  * Service comment may include special characters: <>&"`'@.
@@ -443,12 +443,10 @@ class LibraryServiceClient
         if (array_key_exists('operationsClient', $options)) {
             $this->operationsClient = $options['operationsClient'];
         } else {
-            $this->operationsClient = new OperationsClient([
-                'serviceAddress' => $options['serviceAddress'],
-                'scopes' => $options['scopes'],
-                'libName' => $options['libName'],
-                'libVersion' => $options['libVersion'],
-            ]);
+            $operationsClientOptions = $options;
+            unset($operationsClientOptions['timeoutMillis']);
+            unset($operationsClientOptions['retryingOverride']);
+            $this->operationsClient = new OperationsClient($operationsClientOptions);
         }
 
         $gapicVersion = $options['libVersion'] ?: self::getGapicVersion();
diff --git a/src/test/java/com/google/api/codegen/testdata/php_mock_service_library.baseline b/src/test/java/com/google/api/codegen/testdata/php_mock_service_library.baseline
index a42dedb80e..a722fcac0d 100644
--- a/src/test/java/com/google/api/codegen/testdata/php_mock_service_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/php_mock_service_library.baseline
@@ -23,15 +23,18 @@
 
 namespace Google\Tests\Example\Library\V1;
 
+use \Google\GAX\ApiException;
 use \Google\GAX\GrpcCredentialsHelper;
 use \Google\GAX\LongRunning\OperationsClient;
 use \Google\GAX\Testing\LongRunning\MockOperationsImpl;
 use \Google\GAX\Testing\MockStubTrait;
+use \Grpc;
 use \PHPUnit_Framework_TestCase;
 use \google\longrunning\GetOperationRequest;
 use \google\protobuf\Any;
 use \google\protobuf\EmptyC;
 use \google\tagger\v1\LabelerGrpcClient;
+use \stdClass;
 
 class MockLabelerImpl extends LabelerGrpcClient
 {
@@ -62,15 +65,18 @@ class MockLabelerImpl extends LabelerGrpcClient
 
 namespace Google\Tests\Example\Library\V1;
 
+use \Google\GAX\ApiException;
 use \Google\GAX\GrpcCredentialsHelper;
 use \Google\GAX\LongRunning\OperationsClient;
 use \Google\GAX\Testing\LongRunning\MockOperationsImpl;
 use \Google\GAX\Testing\MockStubTrait;
+use \Grpc;
 use \PHPUnit_Framework_TestCase;
 use \google\example\library\v1\LibraryServiceGrpcClient;
 use \google\longrunning\GetOperationRequest;
 use \google\protobuf\Any;
 use \google\protobuf\EmptyC;
+use \stdClass;
 
 class MockLibraryServiceImpl extends LibraryServiceGrpcClient
 {
diff --git a/src/test/java/com/google/api/codegen/testdata/php_test_library.baseline b/src/test/java/com/google/api/codegen/testdata/php_test_library.baseline
index a525ae1f42..1d285e5bf5 100644
--- a/src/test/java/com/google/api/codegen/testdata/php_test_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/php_test_library.baseline
@@ -24,10 +24,12 @@
 namespace Google\Tests\Example\Library\V1;
 
 use Google\Example\Library\V1\LibraryServiceClient;
+use \Google\GAX\ApiException;
 use \Google\GAX\GrpcCredentialsHelper;
 use \Google\GAX\LongRunning\OperationsClient;
 use \Google\GAX\Testing\LongRunning\MockOperationsImpl;
 use \Google\GAX\Testing\MockStubTrait;
+use \Grpc;
 use \PHPUnit_Framework_TestCase;
 use \google\example\library\v1\AddCommentsRequest;
 use \google\example\library\v1\Book;
@@ -74,6 +76,7 @@ use \google\tagger\v1\AddLabelResponse;
 use \google\tagger\v1\AddTagRequest;
 use \google\tagger\v1\AddTagResponse;
 use \google\tagger\v1\LabelerGrpcClient;
+use \stdClass;
 
 /**
  * @group library
@@ -153,6 +156,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function createShelfExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $shelf = new Shelf();
+
+        try {
+            $client->createShelf($shelf);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -191,6 +224,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function getShelfExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]");
+        $options = "options-1249474914";
+
+        try {
+            $client->getShelf($formattedName, $options);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -227,6 +291,33 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function listShelvesExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        try {
+            $client->listShelves();
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -237,8 +328,10 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
 
         $this->assertTrue($grpcStub->isExhausted());
 
-        // Add empty response to the grpc stub
-        $grpcStub->addResponse(new EmptyC());
+        // Mock response
+        $expectedResponse = new EmptyC();
+        $grpcStub->addResponse($expectedResponse);
+
         // Mock request
         $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]");
 
@@ -254,6 +347,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function deleteShelfExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]");
+
+        try {
+            $client->deleteShelf($formattedName);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -292,6 +415,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function mergeShelvesExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]");
+        $formattedOtherShelfName = LibraryServiceClient::formatShelfName("[SHELF_ID]");
+
+        try {
+            $client->mergeShelves($formattedName, $formattedOtherShelfName);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -332,6 +486,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function createBookExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]");
+        $book = new Book();
+
+        try {
+            $client->createBook($formattedName, $book);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -373,6 +558,40 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function publishSeriesExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $shelf = new Shelf();
+        $books = [];
+        $seriesString = "foobar";
+        $seriesUuid = new SeriesUuid();
+        $seriesUuid->setSeriesString($seriesString);
+
+        try {
+            $client->publishSeries($shelf, $books, $seriesUuid);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -411,6 +630,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function getBookExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+
+        try {
+            $client->getBook($formattedName);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -451,6 +700,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function listBooksExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatShelfName("[SHELF_ID]");
+
+        try {
+            $client->listBooks($formattedName);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -461,8 +740,10 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
 
         $this->assertTrue($grpcStub->isExhausted());
 
-        // Add empty response to the grpc stub
-        $grpcStub->addResponse(new EmptyC());
+        // Mock response
+        $expectedResponse = new EmptyC();
+        $grpcStub->addResponse($expectedResponse);
+
         // Mock request
         $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
 
@@ -478,6 +759,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function deleteBookExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+
+        try {
+            $client->deleteBook($formattedName);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -518,6 +829,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function updateBookExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+        $book = new Book();
+
+        try {
+            $client->updateBook($formattedName, $book);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -558,6 +900,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function moveBookExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+        $formattedOtherShelfName = LibraryServiceClient::formatShelfName("[SHELF_ID]");
+
+        try {
+            $client->moveBook($formattedName, $formattedOtherShelfName);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -594,6 +967,33 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function listStringsExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        try {
+            $client->listStrings();
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -604,8 +1004,10 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
 
         $this->assertTrue($grpcStub->isExhausted());
 
-        // Add empty response to the grpc stub
-        $grpcStub->addResponse(new EmptyC());
+        // Mock response
+        $expectedResponse = new EmptyC();
+        $grpcStub->addResponse($expectedResponse);
+
         // Mock request
         $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
         $comment = "95";
@@ -633,21 +1035,59 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
     /**
      * @test
      */
-    public function getBookFromArchiveTest()
+    public function addCommentsExceptionTest()
     {
         $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
         $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
 
         $this->assertTrue($grpcStub->isExhausted());
 
-        // Mock response
-        $name2 = "name2-1052831874";
-        $author = "author-1406328437";
-        $title = "title110371416";
-        $read = true;
-        $expectedResponse = new BookFromArchive();
-        $expectedResponse->setName($name2);
-        $expectedResponse->setAuthor($author);
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+        $comment = "95";
+        $stage = Stage::UNSET;
+        $alignment = Alignment::CHAR;
+        $commentsElement = new Comment();
+        $commentsElement->setComment($comment);
+        $commentsElement->setStage($stage);
+        $commentsElement->setAlignment($alignment);
+        $comments = [$commentsElement];
+
+        try {
+            $client->addComments($formattedName, $comments);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
+    /**
+     * @test
+     */
+    public function getBookFromArchiveTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        // Mock response
+        $name2 = "name2-1052831874";
+        $author = "author-1406328437";
+        $title = "title110371416";
+        $read = true;
+        $expectedResponse = new BookFromArchive();
+        $expectedResponse->setName($name2);
+        $expectedResponse->setAuthor($author);
         $expectedResponse->setTitle($title);
         $expectedResponse->setRead($read);
         $grpcStub->addResponse($expectedResponse);
@@ -668,6 +1108,36 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function getBookFromArchiveExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatArchivedBookName("[ARCHIVE_PATH]", "[BOOK_ID]");
+
+        try {
+            $client->getBookFromArchive($formattedName);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -708,6 +1178,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function getBookFromAnywhereExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+        $formattedAltBookName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+
+        try {
+            $client->getBookFromAnywhere($formattedName, $formattedAltBookName);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -718,8 +1219,10 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
 
         $this->assertTrue($grpcStub->isExhausted());
 
-        // Add empty response to the grpc stub
-        $grpcStub->addResponse(new EmptyC());
+        // Mock response
+        $expectedResponse = new EmptyC();
+        $grpcStub->addResponse($expectedResponse);
+
         // Mock request
         $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
         $indexName = "default index";
@@ -740,6 +1243,39 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function updateBookIndexExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+        $indexName = "default index";
+        $indexMapItem = "indexMapItem1918721251";
+        $indexMap = ["default_key" => $indexMapItem,];
+
+        try {
+            $client->updateBookIndex($formattedName, $indexName, $indexMap);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -783,6 +1319,38 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function findRelatedBooksExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $namesElement = "namesElement-249113339";
+        $names = [$namesElement];
+        $shelves = [];
+
+        try {
+            $client->findRelatedBooks($names, $shelves);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -815,6 +1383,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function addTagExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedResource = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+        $tag = "tag114586";
+
+        try {
+            $client->addTag($formattedResource, $tag);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -847,6 +1446,37 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function addLabelExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLabelerImpl']);
+        $client = $this->createClient('createLabelerStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedResource = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+        $label = "label102727412";
+
+        try {
+            $client->addLabel($formattedResource, $label);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -923,6 +1553,60 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($operationsStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function getBigBookExceptionTest()
+    {
+        $operationsStub = $this->createStub([$this, 'createMockOperationsStub']);
+        $operationsClient = new OperationsClient([
+            'serviceAddress' => '',
+            'scopes' => [],
+            'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) {
+                return $operationsStub;
+            }
+        ]);
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub, [
+            'operationsClient' => $operationsClient
+        ]);
+
+        $this->assertTrue($grpcStub->isExhausted());
+        $this->assertTrue($operationsStub->isExhausted());
+
+        // Mock response
+        $incompleteOperation = new Operation();
+        $incompleteOperation->setName('operations/getBigBookTest')->setDone(false);
+        $grpcStub->addResponse($incompleteOperation);
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $operationsStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+
+        $response = $client->getBigBook($formattedName);
+        $this->assertFalse($response->isDone());
+        $this->assertNull($response->getResult());
+
+        $expectedOperationsRequestObject = new GetOperationRequest();
+        $expectedOperationsRequestObject->setName('operations/getBigBookTest');
+
+        try {
+            $response->pollUntilComplete();
+            // If the pollUntilComplete() method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+        $this->assertTrue($operationsStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -991,6 +1675,60 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($operationsStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function getBigNothingExceptionTest()
+    {
+        $operationsStub = $this->createStub([$this, 'createMockOperationsStub']);
+        $operationsClient = new OperationsClient([
+            'serviceAddress' => '',
+            'scopes' => [],
+            'createOperationsStubFunction' => function ($hostname, $opts) use ($operationsStub) {
+                return $operationsStub;
+            }
+        ]);
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub, [
+            'operationsClient' => $operationsClient
+        ]);
+
+        $this->assertTrue($grpcStub->isExhausted());
+        $this->assertTrue($operationsStub->isExhausted());
+
+        // Mock response
+        $incompleteOperation = new Operation();
+        $incompleteOperation->setName('operations/getBigNothingTest')->setDone(false);
+        $grpcStub->addResponse($incompleteOperation);
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $operationsStub->addResponse(null, $status);
+
+        // Mock request
+        $formattedName = LibraryServiceClient::formatBookName("[SHELF_ID]", "[BOOK_ID]");
+
+        $response = $client->getBigNothing($formattedName);
+        $this->assertFalse($response->isDone());
+        $this->assertNull($response->getResult());
+
+        $expectedOperationsRequestObject = new GetOperationRequest();
+        $expectedOperationsRequestObject->setName('operations/getBigNothingTest');
+
+        try {
+            $response->pollUntilComplete();
+            // If the pollUntilComplete() method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+        $this->assertTrue($operationsStub->isExhausted());
+    }
+
     /**
      * @test
      */
@@ -1073,4 +1811,60 @@ class LibraryServiceClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($grpcStub->isExhausted());
     }
 
+    /**
+     * @test
+     */
+    public function testOptionalRequiredFlatteningParamsExceptionTest()
+    {
+        $grpcStub = $this->createStub([$this, 'createMockLibraryServiceImpl']);
+        $client = $this->createClient('createLibraryServiceStubFunction', $grpcStub);
+
+        $this->assertTrue($grpcStub->isExhausted());
+
+        $status = new stdClass();
+        $status->code = Grpc\STATUS_INTERNAL;
+        $status->details = 'internal error';
+        $grpcStub->addResponse(null, $status);
+
+        // Mock request
+        $requiredSingularInt32 = -72313594;
+        $requiredSingularInt64 = -72313499;
+        $requiredSingularFloat = -7514705.0;
+        $requiredSingularDouble = 1.9111005E8;
+        $requiredSingularBool = true;
+        $requiredSingularEnum = InnerEnum::ZERO;
+        $requiredSingularString = "requiredSingularString-1949894503";
+        $requiredSingularBytes = "-29";
+        $requiredSingularMessage = new InnerMessage();
+        $requiredSingularResourceName = "requiredSingularResourceName-1701575020";
+        $requiredSingularResourceNameOneof = "requiredSingularResourceNameOneof-25303726";
+        $requiredSingularFixed32 = 720656715;
+        $requiredSingularFixed64 = 720656810;
+        $requiredRepeatedInt32 = [];
+        $requiredRepeatedInt64 = [];
+        $requiredRepeatedFloat = [];
+        $requiredRepeatedDouble = [];
+        $requiredRepeatedBool = [];
+        $requiredRepeatedEnum = [];
+        $requiredRepeatedString = [];
+        $requiredRepeatedBytes = [];
+        $requiredRepeatedMessage = [];
+        $formattedRequiredRepeatedResourceName = [];
+        $formattedRequiredRepeatedResourceNameOneof = [];
+        $requiredRepeatedFixed32 = [];
+        $requiredRepeatedFixed64 = [];
+        $requiredMap = [];
+
+        try {
+            $client->testOptionalRequiredFlatteningParams($requiredSingularInt32, $requiredSingularInt64, $requiredSingularFloat, $requiredSingularDouble, $requiredSingularBool, $requiredSingularEnum, $requiredSingularString, $requiredSingularBytes, $requiredSingularMessage, $requiredSingularResourceName, $requiredSingularResourceNameOneof, $requiredSingularFixed32, $requiredSingularFixed64, $requiredRepeatedInt32, $requiredRepeatedInt64, $requiredRepeatedFloat, $requiredRepeatedDouble, $requiredRepeatedBool, $requiredRepeatedEnum, $requiredRepeatedString, $requiredRepeatedBytes, $requiredRepeatedMessage, $formattedRequiredRepeatedResourceName, $formattedRequiredRepeatedResourceNameOneof, $requiredRepeatedFixed32, $requiredRepeatedFixed64, $requiredMap);
+            // If the $client method call did not throw, fail the test
+            $this->fail("Expected an ApiException, but no exception was thrown.");
+        } catch (ApiException $ex) {
+            $this->assertEquals($status->code, $ex->getCode());
+            $this->assertEquals($status->details, $ex->getMessage());
+        }
+
+        $this->assertTrue($grpcStub->isExhausted());
+    }
+
 }
diff --git a/src/test/java/com/google/api/codegen/testdata/python_README_library.baseline b/src/test/java/com/google/api/codegen/testdata/python_README_library.baseline
index 846917b235..39a2632916 100644
--- a/src/test/java/com/google/api/codegen/testdata/python_README_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/python_README_library.baseline
@@ -1,44 +1,29 @@
 ============== file: README.rst ==============
-GAPIC library for the Google Example Library API
-================================================================================
+Python Client for Google Example Library API (`Alpha`_)
+==================================================================================================
 
-gapic-google-cloud-library-v1 uses google-gax_ (Google API extensions) to provide an
-easy-to-use client library for the `Google Example Library API`_ (v1) defined in the googleapis_ git repository
+`Google Example Library API`_: A simple Google Example Library API.
 
+- `Client Library Documentation`_
+- `Product Documentation`_
 
-.. _`googleapis`: https://github.com/googleapis/googleapis/tree/master/google/library
-.. _`google-gax`: https://github.com/googleapis/gax-python
-.. _`Google Example Library API`: https://developers.google.com/apis-explorer/?hl=en_US#p/library_example/v1/
+.. _Alpha: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
+.. _Google Example Library API: https://cloud.google.com/library
+.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/library-usage
+.. _Product Documentation:  https://cloud.google.com/library
 
-Getting started
----------------
+Quick Start
+-----------
 
-gapic-google-cloud-library-v1 will allow you to connect to the
-Google Example Library API and access all its methods. In order to do this, you need
-to set up authentication as well as install the library locally.
+In order to use this library, you first need to go through the following steps:
 
+1. `Select or create a Cloud Platform project.`_
+2. `Enable the Google Example Library API.`_
+3. `Setup Authentication.`_
 
-Setup Authentication
-~~~~~~~~~~~~~~~~~~~~
-
-To authenticate all your API calls, first install and setup the `Google Cloud SDK`_.
-Once done, you can then run the following command in your terminal:
-
-.. code-block:: console
-
-    $ gcloud beta auth application-default login
-
-or
-
-.. code-block:: console
-
-    $ gcloud auth login
-
-Please see `gcloud beta auth application-default login`_ document for the difference between these commands.
-
-.. _Google Cloud SDK: https://cloud.google.com/sdk/
-.. _gcloud beta auth application-default login: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login
-
+.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
+.. _Enable the Google Example Library API.:  https://cloud.google.com/library
+.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/stable/google-cloud-auth
 
 Installation
 ~~~~~~~~~~~~
@@ -55,7 +40,7 @@ dependencies.
 
 
 Mac/Linux
-~~~~~~~~~~
+^^^^^^^^^
 
 .. code-block:: console
 
@@ -66,7 +51,7 @@ Mac/Linux
 
 
 Windows
-~~~~~~~
+^^^^^^^
 
 .. code-block:: console
 
@@ -75,6 +60,30 @@ Windows
     \Scripts\activate
     \Scripts\pip.exe install gapic-google-cloud-library-v1
 
+Preview
+~~~~~~~
+
+LibraryServiceClient
+^^^^^^^^^^^^^^^^^^^^^^
+
+.. code:: py
+
+  from google.cloud.gapic.example.library.v1 import library_service_client
+  from google.cloud.proto.example.library.v1 import library_pb2
+  client = library_service_client.LibraryServiceClient()
+  name = client.book_path('[SHELF_ID]', '[BOOK_ID]')
+  book = library_pb2.Book()
+  response = client.update_book(name, book)
+
+Next Steps
+~~~~~~~~~~
 
-At this point you are all set to continue.
+-  Read the `Client Library Documentation`_ for Google Example Library API
+   API to see other available methods on the client.
+-  Read the `Google Example Library API Product documentation`_ to learn
+   more about the product and see How-to Guides.
+-  View this `repository’s main README`_ to see the full list of Cloud
+   APIs that we cover.
 
+.. _Google Example Library API Product documentation:  https://cloud.google.com/library
+.. _repository’s main README: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
diff --git a/src/test/java/com/google/api/codegen/testdata/python_README_no_path_templates.baseline b/src/test/java/com/google/api/codegen/testdata/python_README_no_path_templates.baseline
index a8a1d894b4..250e8886e0 100644
--- a/src/test/java/com/google/api/codegen/testdata/python_README_no_path_templates.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/python_README_no_path_templates.baseline
@@ -1,44 +1,29 @@
 ============== file: README.rst ==============
-GAPIC library for the Google Fake API
-================================================================================
+Python Client for Google Fake API (`Beta`_)
+==================================================================================================
 
-gapic-google-cloud-library-v1 uses google-gax_ (Google API extensions) to provide an
-easy-to-use client library for the `Google Fake API`_ (v1) defined in the googleapis_ git repository
+`Google Fake API`_: Tests no path templates
 
+- `Client Library Documentation`_
+- `Product Documentation`_
 
-.. _`googleapis`: https://github.com/googleapis/googleapis/tree/master/google/library
-.. _`google-gax`: https://github.com/googleapis/gax-python
-.. _`Google Fake API`: https://developers.google.com/apis-explorer/?hl=en_US#p/no_path_templates/v1/
+.. _Beta: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
+.. _Google Fake API: https://cloud.google.com/library
+.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/library-usage
+.. _Product Documentation:  https://cloud.google.com/library
 
-Getting started
----------------
+Quick Start
+-----------
 
-gapic-google-cloud-library-v1 will allow you to connect to the
-Google Fake API and access all its methods. In order to do this, you need
-to set up authentication as well as install the library locally.
+In order to use this library, you first need to go through the following steps:
 
+1. `Select or create a Cloud Platform project.`_
+2. `Enable the Google Fake API.`_
+3. `Setup Authentication.`_
 
-Setup Authentication
-~~~~~~~~~~~~~~~~~~~~
-
-To authenticate all your API calls, first install and setup the `Google Cloud SDK`_.
-Once done, you can then run the following command in your terminal:
-
-.. code-block:: console
-
-    $ gcloud beta auth application-default login
-
-or
-
-.. code-block:: console
-
-    $ gcloud auth login
-
-Please see `gcloud beta auth application-default login`_ document for the difference between these commands.
-
-.. _Google Cloud SDK: https://cloud.google.com/sdk/
-.. _gcloud beta auth application-default login: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login
-
+.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
+.. _Enable the Google Fake API.:  https://cloud.google.com/library
+.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/stable/google-cloud-auth
 
 Installation
 ~~~~~~~~~~~~
@@ -55,7 +40,7 @@ dependencies.
 
 
 Mac/Linux
-~~~~~~~~~~
+^^^^^^^^^
 
 .. code-block:: console
 
@@ -66,7 +51,7 @@ Mac/Linux
 
 
 Windows
-~~~~~~~
+^^^^^^^
 
 .. code-block:: console
 
@@ -75,6 +60,15 @@ Windows
     \Scripts\activate
     \Scripts\pip.exe install gapic-google-cloud-library-v1
 
+Next Steps
+~~~~~~~~~~
 
-At this point you are all set to continue.
+-  Read the `Client Library Documentation`_ for Google Fake API
+   API to see other available methods on the client.
+-  Read the `Google Fake API Product documentation`_ to learn
+   more about the product and see How-to Guides.
+-  View this `repository’s main README`_ to see the full list of Cloud
+   APIs that we cover.
 
+.. _Google Fake API Product documentation:  https://cloud.google.com/library
+.. _repository’s main README: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
diff --git a/src/test/java/com/google/api/codegen/testdata/python_doc_README_library.baseline b/src/test/java/com/google/api/codegen/testdata/python_doc_README_library.baseline
index 846917b235..39a2632916 100644
--- a/src/test/java/com/google/api/codegen/testdata/python_doc_README_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/python_doc_README_library.baseline
@@ -1,44 +1,29 @@
 ============== file: README.rst ==============
-GAPIC library for the Google Example Library API
-================================================================================
+Python Client for Google Example Library API (`Alpha`_)
+==================================================================================================
 
-gapic-google-cloud-library-v1 uses google-gax_ (Google API extensions) to provide an
-easy-to-use client library for the `Google Example Library API`_ (v1) defined in the googleapis_ git repository
+`Google Example Library API`_: A simple Google Example Library API.
 
+- `Client Library Documentation`_
+- `Product Documentation`_
 
-.. _`googleapis`: https://github.com/googleapis/googleapis/tree/master/google/library
-.. _`google-gax`: https://github.com/googleapis/gax-python
-.. _`Google Example Library API`: https://developers.google.com/apis-explorer/?hl=en_US#p/library_example/v1/
+.. _Alpha: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
+.. _Google Example Library API: https://cloud.google.com/library
+.. _Client Library Documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/library-usage
+.. _Product Documentation:  https://cloud.google.com/library
 
-Getting started
----------------
+Quick Start
+-----------
 
-gapic-google-cloud-library-v1 will allow you to connect to the
-Google Example Library API and access all its methods. In order to do this, you need
-to set up authentication as well as install the library locally.
+In order to use this library, you first need to go through the following steps:
 
+1. `Select or create a Cloud Platform project.`_
+2. `Enable the Google Example Library API.`_
+3. `Setup Authentication.`_
 
-Setup Authentication
-~~~~~~~~~~~~~~~~~~~~
-
-To authenticate all your API calls, first install and setup the `Google Cloud SDK`_.
-Once done, you can then run the following command in your terminal:
-
-.. code-block:: console
-
-    $ gcloud beta auth application-default login
-
-or
-
-.. code-block:: console
-
-    $ gcloud auth login
-
-Please see `gcloud beta auth application-default login`_ document for the difference between these commands.
-
-.. _Google Cloud SDK: https://cloud.google.com/sdk/
-.. _gcloud beta auth application-default login: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login
-
+.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
+.. _Enable the Google Example Library API.:  https://cloud.google.com/library
+.. _Setup Authentication.: https://googlecloudplatform.github.io/google-cloud-python/stable/google-cloud-auth
 
 Installation
 ~~~~~~~~~~~~
@@ -55,7 +40,7 @@ dependencies.
 
 
 Mac/Linux
-~~~~~~~~~~
+^^^^^^^^^
 
 .. code-block:: console
 
@@ -66,7 +51,7 @@ Mac/Linux
 
 
 Windows
-~~~~~~~
+^^^^^^^
 
 .. code-block:: console
 
@@ -75,6 +60,30 @@ Windows
     \Scripts\activate
     \Scripts\pip.exe install gapic-google-cloud-library-v1
 
+Preview
+~~~~~~~
+
+LibraryServiceClient
+^^^^^^^^^^^^^^^^^^^^^^
+
+.. code:: py
+
+  from google.cloud.gapic.example.library.v1 import library_service_client
+  from google.cloud.proto.example.library.v1 import library_pb2
+  client = library_service_client.LibraryServiceClient()
+  name = client.book_path('[SHELF_ID]', '[BOOK_ID]')
+  book = library_pb2.Book()
+  response = client.update_book(name, book)
+
+Next Steps
+~~~~~~~~~~
 
-At this point you are all set to continue.
+-  Read the `Client Library Documentation`_ for Google Example Library API
+   API to see other available methods on the client.
+-  Read the `Google Example Library API Product documentation`_ to learn
+   more about the product and see How-to Guides.
+-  View this `repository’s main README`_ to see the full list of Cloud
+   APIs that we cover.
 
+.. _Google Example Library API Product documentation:  https://cloud.google.com/library
+.. _repository’s main README: https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/README.rst
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_Gemfile_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_Gemfile_library.baseline
index d7289bd560..45ef455faa 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_Gemfile_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_Gemfile_library.baseline
@@ -2,3 +2,12 @@
 source 'https://rubygems.org'
 
 gemspec
+
+gem "rake", "~> 11.0"
+gem "gcloud-jsondoc",
+    git: "https://github.com/GoogleCloudPlatform/google-cloud-ruby.git",
+    branch: "gcloud-jsondoc"
+
+# TEMP: rainbow (a dependency of rubocop) version 2.2 seems to have a problem,
+# so pinning to 2.1 for now.
+gem "rainbow", "~> 2.1.0"
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_README_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_README_library.baseline
index 253db828a4..49b7dce9a1 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_README_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_README_library.baseline
@@ -1,46 +1,38 @@
 ============== file: README.md ==============
-Google Example Library API for Ruby
-=================================================
-
-Google Example Library API uses [Google API extensions][google-gax] to provide an
-easy-to-use client library for the [Google Example Library API][] (v1) defined in the [googleapis][] git repository
-
-
-[googleapis]: https://github.com/googleapis/googleapis/tree/master/google/library
-[google-gax]: https://github.com/googleapis/gax-ruby
-[Google Example Library API]: https://developers.google.com/apis-explorer/?hl=en_US#p/library_example/v1/
-
-Getting started
----------------
-
-library will allow you to connect to the [Google Example Library API][] and access all its methods.
-
-In order to achieve so, you need to set up authentication, as well as install the library locally.
-
-
-Setup Authentication
---------------------
-
-To authenticate all of your API calls, first install and setup the [Google Cloud SDK][].
-Once done, you can then run the following command in your terminal:
-
-    $ gcloud beta auth application-default login
-
-or
-
-    $ gcloud auth login
-
-Please see the [gcloud beta auth application-default login][] to find documentation showing the difference between these commands.
-
-[Google Cloud SDK]: https://cloud.google.com/sdk/
-[gcloud beta auth application-default login]: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login
-
-
-Installation
--------------------
-
-Install this library using gem:
-
-    $ [sudo] gem install library
-
-At this point you are all set to continue.
+# Ruby Client for Google Example Library API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
+
+[Google Example Library API][Product Documentation]: A simple Google Example Library API.
+- [Client Library Documentation][]
+- [Product Documentation][]
+
+## Quick Start
+In order to use this library, you first need to go through the following steps:
+
+1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
+2. [Enable the Google Example Library API.](https://console.cloud.google.com/apis/api/library)
+3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
+
+### Installation
+```
+$ gem install library
+```
+
+### Preview
+#### LibraryServiceClient
+```rb
+require "library/v1"
+
+library_service_client = Library::V1::LibraryServiceClient.new
+formatted_name = Library::V1::LibraryServiceClient.book_path("testShelf-" + Time.new.to_i.to_s, project_id)
+rating = :GOOD
+book = Google::Example::Library::V1::Book.new(rating: rating)
+response = library_service_client.update_book(formatted_name, book)
+```
+
+### Next Steps
+- Read the [Client Library Documentation][] for Google Example Library API to see other available methods on the client.
+- Read the [Google Example Library API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
+- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md) to see the full list of Cloud APIs that we cover.
+
+[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/library/latest/google/library
+[Product Documentation]: https://cloud.google.com/library
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_doc_Gemfile_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_doc_Gemfile_library.baseline
index d7289bd560..45ef455faa 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_doc_Gemfile_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_doc_Gemfile_library.baseline
@@ -2,3 +2,12 @@
 source 'https://rubygems.org'
 
 gemspec
+
+gem "rake", "~> 11.0"
+gem "gcloud-jsondoc",
+    git: "https://github.com/GoogleCloudPlatform/google-cloud-ruby.git",
+    branch: "gcloud-jsondoc"
+
+# TEMP: rainbow (a dependency of rubocop) version 2.2 seems to have a problem,
+# so pinning to 2.1 for now.
+gem "rainbow", "~> 2.1.0"
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_doc_README_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_doc_README_library.baseline
index 253db828a4..49b7dce9a1 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_doc_README_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_doc_README_library.baseline
@@ -1,46 +1,38 @@
 ============== file: README.md ==============
-Google Example Library API for Ruby
-=================================================
-
-Google Example Library API uses [Google API extensions][google-gax] to provide an
-easy-to-use client library for the [Google Example Library API][] (v1) defined in the [googleapis][] git repository
-
-
-[googleapis]: https://github.com/googleapis/googleapis/tree/master/google/library
-[google-gax]: https://github.com/googleapis/gax-ruby
-[Google Example Library API]: https://developers.google.com/apis-explorer/?hl=en_US#p/library_example/v1/
-
-Getting started
----------------
-
-library will allow you to connect to the [Google Example Library API][] and access all its methods.
-
-In order to achieve so, you need to set up authentication, as well as install the library locally.
-
-
-Setup Authentication
---------------------
-
-To authenticate all of your API calls, first install and setup the [Google Cloud SDK][].
-Once done, you can then run the following command in your terminal:
-
-    $ gcloud beta auth application-default login
-
-or
-
-    $ gcloud auth login
-
-Please see the [gcloud beta auth application-default login][] to find documentation showing the difference between these commands.
-
-[Google Cloud SDK]: https://cloud.google.com/sdk/
-[gcloud beta auth application-default login]: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login
-
-
-Installation
--------------------
-
-Install this library using gem:
-
-    $ [sudo] gem install library
-
-At this point you are all set to continue.
+# Ruby Client for Google Example Library API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
+
+[Google Example Library API][Product Documentation]: A simple Google Example Library API.
+- [Client Library Documentation][]
+- [Product Documentation][]
+
+## Quick Start
+In order to use this library, you first need to go through the following steps:
+
+1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
+2. [Enable the Google Example Library API.](https://console.cloud.google.com/apis/api/library)
+3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
+
+### Installation
+```
+$ gem install library
+```
+
+### Preview
+#### LibraryServiceClient
+```rb
+require "library/v1"
+
+library_service_client = Library::V1::LibraryServiceClient.new
+formatted_name = Library::V1::LibraryServiceClient.book_path("testShelf-" + Time.new.to_i.to_s, project_id)
+rating = :GOOD
+book = Google::Example::Library::V1::Book.new(rating: rating)
+response = library_service_client.update_book(formatted_name, book)
+```
+
+### Next Steps
+- Read the [Client Library Documentation][] for Google Example Library API to see other available methods on the client.
+- Read the [Google Example Library API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
+- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md) to see the full list of Cloud APIs that we cover.
+
+[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/library/latest/google/library
+[Product Documentation]: https://cloud.google.com/library
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_doc_gemspec_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_doc_gemspec_library.baseline
index b79e4c585c..861a86ec80 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_doc_gemspec_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_doc_gemspec_library.baseline
@@ -2,34 +2,31 @@
 # -*- ruby -*-
 # encoding: utf-8
 
-Gem::Specification.new do |s|
-  s.name          = "library"
-  s.version       = "0.6.8"
-
-  s.authors       = ["Google, Inc."]
-  s.description   = "Google Example Library API client for Ruby."
-  s.email         = "googleapis-packages@google.com"
-  s.files         = Dir.glob(File.join("lib", "**", "*.rb"))
-  s.files        += Dir.glob(File.join('lib', '**', '*.json'))
-  s.files        += %w(Rakefile README.md LICENSE)
-  s.homepage      = "https://github.com/googleapis/googleapis"
-  s.license       = "Apache-2.0"
-  s.platform      = Gem::Platform::RUBY
-  s.require_paths = ["lib"]
-  s.required_ruby_version = ">= 2.0.0"
-  s.requirements << "libgrpc ~> 1.0 needs to be installed"
-  s.summary       = "GRPC library for Google Example Library API"
-
-  s.add_dependency "grpc", "~> 1.0"
-  s.add_dependency "googleauth", "~> 0.5.1"
-  s.add_dependency "google-gax", "~> 0.8.0"
-  s.add_dependency "google-common-protos", "~> 1.3.1"
-  s.add_dependency "google-some-other-package-v1", "~> 0.2.1"
-
-  s.add_development_dependency "bundler", "~> 1.9"
-  s.add_development_dependency "rake", "~> 10.4"
-  s.add_development_dependency "rubocop", "~> 0.32"
-  s.add_development_dependency "simplecov", "~> 0.9"
-  s.add_development_dependency "minitest", "~> 5.10"
+Gem::Specification.new do |gem|
+  gem.name          = "library"
+  gem.version       = "0.6.8"
+
+  gem.authors       = ["Google, Inc."]
+  gem.email         = "googleapis-packages@google.com"
+  gem.description   = "library is the official library for Google Example Library API."
+  gem.summary       = "API Client library for Google Example Library API"
+  gem.homepage      = "https://github.com/googleapis/googleapis"
+  gem.license       = "Apache-2.0"
+
+  gem.platform      = Gem::Platform::RUBY
+
+  gem.files         = `git ls-files -- lib/*`.split("\n") +
+                      ["README.md", "LICENSE", ".yardopts"]
+  gem.require_paths = ["lib"]
+
+  gem.required_ruby_version = ">= 2.0.0"
+
+  gem.add_dependency "google-gax", "~> 0.8.0"
+  gem.add_dependency "google-common-protos", "~> 1.3.1"
+  gem.add_dependency "google-some-other-package-v1", "~> 0.2.1"
+
+  gem.add_development_dependency "minitest", "~> 5.10"
+  gem.add_development_dependency "rubocop", "<= 0.35.1"
+  gem.add_development_dependency "simplecov", "~> 0.9"
 end
 
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_doc_gitignore_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_doc_gitignore_library.baseline
new file mode 100644
index 0000000000..9b3326aaac
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_doc_gitignore_library.baseline
@@ -0,0 +1,14 @@
+============== file: .gitignore ==============
+Gemfile.lock
+coverage/*
+doc/*
+pkg/*
+html/*
+jsondoc/*
+
+# Ignore YARD stuffs
+.yardoc
+
+# IDE settings
+.idea
+*.iml
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_doc_main_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_doc_main_library.baseline
index 616f068a13..f545bbb4ac 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_doc_main_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_doc_main_library.baseline
@@ -430,11 +430,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #   Shelf = Google::Example::Library::V1::Shelf
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   shelf = Shelf.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   shelf = Google::Example::Library::V1::Shelf.new
       #   response = library_service_client.create_shelf(shelf)
 
       def create_shelf \
@@ -463,10 +460,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #   options_ = ''
       #   response = library_service_client.get_shelf(formatted_name, options_)
 
@@ -499,9 +494,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #
       #   # Iterate over all results.
       #   library_service_client.list_shelves.each do |element|
@@ -532,10 +525,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #   library_service_client.delete_shelf(formatted_name)
 
       def delete_shelf \
@@ -564,11 +555,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
-      #   formatted_other_shelf_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #   response = library_service_client.merge_shelves(formatted_name, formatted_other_shelf_name)
 
       def merge_shelves \
@@ -596,12 +585,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   Book = Google::Example::Library::V1::Book
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
-      #   book = Book.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   book = Google::Example::Library::V1::Book.new
       #   response = library_service_client.create_book(formatted_name, book)
 
       def create_book \
@@ -635,15 +621,11 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #   SeriesUuid = Google::Example::Library::V1::SeriesUuid
-      #   Shelf = Google::Example::Library::V1::Shelf
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   shelf = Shelf.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   shelf = Google::Example::Library::V1::Shelf.new
       #   books = []
       #   series_string = "foobar"
-      #   series_uuid = SeriesUuid.new(series_string: series_string)
+      #   series_uuid = Google::Example::Library::V1::SeriesUuid.new(series_string: series_string)
       #   response = library_service_client.publish_series(shelf, books, series_uuid)
 
       def publish_series \
@@ -675,10 +657,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   response = library_service_client.get_book(formatted_name)
 
       def get_book \
@@ -714,10 +694,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #
       #   # Iterate over all results.
       #   library_service_client.list_books(formatted_name).each do |element|
@@ -756,10 +734,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   library_service_client.delete_book(formatted_name)
 
       def delete_book \
@@ -790,12 +766,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   Book = Google::Example::Library::V1::Book
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      #   book = Book.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   book = Google::Example::Library::V1::Book.new
       #   response = library_service_client.update_book(formatted_name, book)
 
       def update_book \
@@ -827,11 +800,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      #   formatted_other_shelf_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #   response = library_service_client.move_book(formatted_name, formatted_other_shelf_name)
 
       def move_book \
@@ -866,9 +837,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #
       #   # Iterate over all results.
       #   library_service_client.list_strings.each do |element|
@@ -905,17 +874,12 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   Alignment = Google::Example::Library::V1::SomeMessage2::SomeMessage3::Alignment
-      #   Comment = Google::Example::Library::V1::Comment
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #   Stage = Google::Example::Library::V1::Comment::Stage
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   comment = ''
-      #   stage = Stage::UNSET
-      #   alignment = Alignment::CHAR
-      #   comments_element = Comment.new(
+      #   stage = :UNSET
+      #   alignment = :CHAR
+      #   comments_element = Google::Example::Library::V1::Comment.new(
       #     comment: comment,
       #     stage: stage,
       #     alignment: alignment
@@ -947,10 +911,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
       #   response = library_service_client.get_book_from_archive(formatted_name)
 
       def get_book_from_archive \
@@ -977,11 +939,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      #   formatted_alt_book_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   formatted_alt_book_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   response = library_service_client.get_book_from_anywhere(formatted_name, formatted_alt_book_name)
 
       def get_book_from_anywhere \
@@ -1010,10 +970,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   index_name = "default index"
       #   index_map_item = ''
       #   index_map = { "default_key" => index_map_item }
@@ -1046,9 +1004,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   library_service_client.stream_shelves.each do |element|
       #     # Process element.
       #   end
@@ -1073,9 +1029,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   name = ''
       #   library_service_client.stream_books(name).each do |element|
       #     # Process element.
@@ -1111,12 +1065,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   DiscussBookRequest = Google::Example::Library::V1::DiscussBookRequest
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   name = ''
-      #   request = DiscussBookRequest.new(name: name)
+      #   request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
       #   requests = [request]
       #   library_service_client.discuss_book(requests).each do |element|
       #     # Process element.
@@ -1145,12 +1096,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   DiscussBookRequest = Google::Example::Library::V1::DiscussBookRequest
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   name = ''
-      #   request = DiscussBookRequest.new(name: name)
+      #   request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
       #   requests = [request]
       #   response = library_service_client.monolog_about_book(requests)
 
@@ -1178,9 +1126,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   names_element = ''
       #   names = [names_element]
       #   shelves = []
@@ -1227,10 +1173,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_resource = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   tag = ''
       #   response = library_service_client.add_tag(formatted_resource, tag)
 
@@ -1261,10 +1205,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_resource = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   label = ''
       #   response = library_service_client.add_label(formatted_resource, label)
 
@@ -1291,10 +1233,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #
       #   # Register a callback during the method call.
       #   operation = library_service_client.get_big_book(formatted_name) do |op|
@@ -1352,10 +1292,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #
       #   # Register a callback during the method call.
       #   operation = library_service_client.get_big_nothing(formatted_name) do |op|
@@ -1465,20 +1403,16 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   InnerEnum = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerEnum
-      #   InnerMessage = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerMessage
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   required_singular_int32 = 0
       #   required_singular_int64 = 0
       #   required_singular_float = 0.0
       #   required_singular_double = 0.0
       #   required_singular_bool = false
-      #   required_singular_enum = InnerEnum::ZERO
+      #   required_singular_enum = :ZERO
       #   required_singular_string = ''
       #   required_singular_bytes = ''
-      #   required_singular_message = InnerMessage.new
+      #   required_singular_message = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerMessage.new
       #   required_singular_resource_name = ''
       #   required_singular_resource_name_oneof = ''
       #   required_singular_fixed32 = 0
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_doc_rubocop_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_doc_rubocop_library.baseline
new file mode 100644
index 0000000000..3113cd4443
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_doc_rubocop_library.baseline
@@ -0,0 +1,54 @@
+============== file: .rubocop.yml ==============
+AllCops:
+  Exclude:
+    - "library.gemspec"
+    - "lib/google/library/**/*"
+    - "lib/library/v1/**/*"
+    - "Rakefile"
+    - "test/**/*"
+
+Documentation:
+  Enabled: false
+
+Style/StringLiterals:
+  EnforcedStyle: double_quotes
+Style/MethodDefParentheses:
+  EnforcedStyle: require_no_parentheses
+Style/NumericLiterals:
+  Enabled: false
+Style/SpaceAroundOperators:
+  Enabled: false
+Metrics/ClassLength:
+  Enabled: false
+Style/EmptyLines:
+  Enabled: false
+Style/EmptyElse:
+  Enabled: false
+Style/HashSyntax:
+  Exclude:
+    - "lib/library/v1/**/*"
+Metrics/LineLength:
+  Exclude:
+    - "lib/library/v1/**/*"
+Metrics/CyclomaticComplexity:
+  Max: 10
+Metrics/PerceivedComplexity:
+  Max: 10
+Metrics/AbcSize:
+  Max: 25
+  Exclude:
+    - "lib/library/v1/**/*"
+Metrics/MethodLength:
+  Max: 20
+  Exclude:
+    - "lib/library/v1/**/*"
+Metrics/ParameterLists:
+  Enabled: false
+Style/RescueModifier:
+  Enabled: false
+Style/ClassVars:
+  Enabled: false
+Style/TrivialAccessors:
+  Enabled: false
+Style/FileName:
+  Enabled: false
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_doc_smoke_test_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_doc_smoke_test_library.baseline
new file mode 100644
index 0000000000..07e5ae17aa
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_doc_smoke_test_library.baseline
@@ -0,0 +1,35 @@
+============== file: test/library/v1/library_service_smoke_test.rb ==============
+# Copyright 2017, Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# AUTO GENERATED BY GAPIC
+
+require "minitest/autorun"
+require "minitest/spec"
+require "library/v1/library_service_client"
+
+describe "LibraryServiceSmokeTest" do
+  it "runs one smoke test with update_book" do
+    unless ENV["SMOKE_TEST_PROJECT"]
+      fail "Usage: SMOKE_TEST_PROJECT= ruby #{$0}"
+    end
+    project_id = ENV["SMOKE_TEST_PROJECT"].freeze
+
+    library_service_client = Library::V1::LibraryServiceClient.new
+    formatted_name = Library::V1::LibraryServiceClient.book_path("testShelf-" + Time.new.to_i.to_s, project_id)
+    rating = :GOOD
+    book = Google::Example::Library::V1::Book.new(rating: rating)
+    response = library_service_client.update_book(formatted_name, book)
+  end
+end
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_doc_test_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_doc_test_library.baseline
new file mode 100644
index 0000000000..b59f59db92
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_doc_test_library.baseline
@@ -0,0 +1,1929 @@
+============== file: test/library/v1/library_service_client_test.rb ==============
+# Copyright 2017, Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require "minitest/autorun"
+require "minitest/spec"
+
+require "google/gax"
+
+require "library/v1/library_service_client"
+require "library_services_pb"
+require "tagger_services_pb"
+require "google/longrunning/operations_pb"
+
+class CustomTestError < StandardError; end
+
+# Mock for the GRPC::ClientStub class.
+class MockGrpcClientStub
+
+  # @param expected_symbol [Symbol] the symbol of the grpc method to be mocked.
+  # @param mock_method [Proc] The method that is being mocked.
+  def initialize(expected_symbol, mock_method)
+    @expected_symbol = expected_symbol
+    @mock_method = mock_method
+  end
+
+  # This overrides the Object#method method to return the mocked method when the mocked method
+  # is being requested. For methods that aren't being tested, this method returns a proc that
+  # will raise an error when called. This is to assure that only the mocked grpc method is being
+  # called.
+  #
+  # @param symbol [Symbol] The symbol of the method being requested.
+  # @return [Proc] The proc of the requested method. If the requested method is not being mocked
+  #   the proc returned will raise when called.
+  def method(symbol)
+    return @mock_method if symbol == @expected_symbol
+
+    # The requested method is not being tested, raise if it called.
+    proc do
+      raise "The method #{symbol} was unexpectedly called during the " \
+        "test for #{@expected_symbol}."
+    end
+  end
+end
+
+describe Library::V1::LibraryServiceClient do
+
+  describe 'create_shelf' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#create_shelf."
+
+    it 'invokes create_shelf without error' do
+      # Create request parameters
+      shelf = Google::Example::Library::V1::Shelf.new
+
+      # Create expected grpc response
+      name = "name3373707"
+      theme = "theme110327241"
+      internal_theme = "internalTheme792518087"
+      expected_response = Google::Example::Library::V1::Shelf.new(
+        name: name,
+        theme: theme,
+        internal_theme: internal_theme
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(shelf, request.shelf)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:create_shelf, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.create_shelf(shelf)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes create_shelf with error' do
+      # Create request parameters
+      shelf = Google::Example::Library::V1::Shelf.new
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(shelf, request.shelf)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:create_shelf, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.create_shelf(shelf)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'get_shelf' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_shelf."
+
+    it 'invokes get_shelf without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      options_ = ''
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      theme = "theme110327241"
+      internal_theme = "internalTheme792518087"
+      expected_response = Google::Example::Library::V1::Shelf.new(
+        name: name_2,
+        theme: theme,
+        internal_theme: internal_theme
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(options_, request.options)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:get_shelf, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.get_shelf(formatted_name, options_)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes get_shelf with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      options_ = ''
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(options_, request.options)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:get_shelf, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.get_shelf(formatted_name, options_)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'list_shelves' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#list_shelves."
+
+    it 'invokes list_shelves without error' do
+      # Create expected grpc response
+      next_page_token = ""
+      shelves_element = Google::Example::Library::V1::Shelf.new
+      shelves = [shelves_element]
+      expected_response = Google::Example::Library::V1::ListShelvesResponse.new(next_page_token: next_page_token, shelves: shelves)
+
+      # Mock Grpc layer
+      mock_method = proc do
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:list_shelves, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.list_shelves
+
+        # Verify the response
+        assert(response.instance_of?(Google::Gax::PagedEnumerable))
+        assert_equal(expected_response, response.page.response)
+        assert_nil(response.next_page)
+        assert_equal(expected_response.shelves.to_a, response.to_a)
+      end
+    end
+
+    it 'invokes list_shelves with error' do
+      # Mock Grpc layer
+      mock_method = proc do
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:list_shelves, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.list_shelves
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'delete_shelf' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#delete_shelf."
+
+    it 'invokes delete_shelf without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        nil
+      end
+      mock_stub = MockGrpcClientStub.new(:delete_shelf, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.delete_shelf(formatted_name)
+
+        # Verify the response
+        assert_nil(response)
+      end
+    end
+
+    it 'invokes delete_shelf with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:delete_shelf, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.delete_shelf(formatted_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'merge_shelves' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#merge_shelves."
+
+    it 'invokes merge_shelves without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      theme = "theme110327241"
+      internal_theme = "internalTheme792518087"
+      expected_response = Google::Example::Library::V1::Shelf.new(
+        name: name_2,
+        theme: theme,
+        internal_theme: internal_theme
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(formatted_other_shelf_name, request.other_shelf_name)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:merge_shelves, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.merge_shelves(formatted_name, formatted_other_shelf_name)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes merge_shelves with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(formatted_other_shelf_name, request.other_shelf_name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:merge_shelves, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.merge_shelves(formatted_name, formatted_other_shelf_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'create_book' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#create_book."
+
+    it 'invokes create_book without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      book = Google::Example::Library::V1::Book.new
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      author = "author-1406328437"
+      title = "title110371416"
+      read = true
+      expected_response = Google::Example::Library::V1::Book.new(
+        name: name_2,
+        author: author,
+        title: title,
+        read: read
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(book, request.book)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:create_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.create_book(formatted_name, book)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes create_book with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      book = Google::Example::Library::V1::Book.new
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(book, request.book)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:create_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.create_book(formatted_name, book)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'publish_series' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#publish_series."
+
+    it 'invokes publish_series without error' do
+      # Create request parameters
+      shelf = Google::Example::Library::V1::Shelf.new
+      books = []
+      series_string = "foobar"
+      series_uuid = Google::Example::Library::V1::SeriesUuid.new(series_string: series_string)
+
+      # Create expected grpc response
+      book_names_element = "bookNamesElement1491670575"
+      book_names = [book_names_element]
+      expected_response = Google::Example::Library::V1::PublishSeriesResponse.new(book_names: book_names)
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(shelf, request.shelf)
+        assert_equal(books, request.books)
+        assert_equal(series_uuid, request.series_uuid)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:publish_series, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.publish_series(
+          shelf,
+          books,
+          series_uuid
+        )
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes publish_series with error' do
+      # Create request parameters
+      shelf = Google::Example::Library::V1::Shelf.new
+      books = []
+      series_string = "foobar"
+      series_uuid = Google::Example::Library::V1::SeriesUuid.new(series_string: series_string)
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(shelf, request.shelf)
+        assert_equal(books, request.books)
+        assert_equal(series_uuid, request.series_uuid)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:publish_series, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.publish_series(
+            shelf,
+            books,
+            series_uuid
+          )
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'get_book' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_book."
+
+    it 'invokes get_book without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      author = "author-1406328437"
+      title = "title110371416"
+      read = true
+      expected_response = Google::Example::Library::V1::Book.new(
+        name: name_2,
+        author: author,
+        title: title,
+        read: read
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:get_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.get_book(formatted_name)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes get_book with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:get_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.get_book(formatted_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'list_books' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#list_books."
+
+    it 'invokes list_books without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+
+      # Create expected grpc response
+      next_page_token = ""
+      books_element = Google::Example::Library::V1::Book.new
+      books = [books_element]
+      expected_response = Google::Example::Library::V1::ListBooksResponse.new(next_page_token: next_page_token, books: books)
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:list_books, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.list_books(formatted_name)
+
+        # Verify the response
+        assert(response.instance_of?(Google::Gax::PagedEnumerable))
+        assert_equal(expected_response, response.page.response)
+        assert_nil(response.next_page)
+        assert_equal(expected_response.books.to_a, response.to_a)
+      end
+    end
+
+    it 'invokes list_books with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:list_books, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.list_books(formatted_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'delete_book' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#delete_book."
+
+    it 'invokes delete_book without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        nil
+      end
+      mock_stub = MockGrpcClientStub.new(:delete_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.delete_book(formatted_name)
+
+        # Verify the response
+        assert_nil(response)
+      end
+    end
+
+    it 'invokes delete_book with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:delete_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.delete_book(formatted_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'update_book' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#update_book."
+
+    it 'invokes update_book without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      book = Google::Example::Library::V1::Book.new
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      author = "author-1406328437"
+      title = "title110371416"
+      read = true
+      expected_response = Google::Example::Library::V1::Book.new(
+        name: name_2,
+        author: author,
+        title: title,
+        read: read
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(book, request.book)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:update_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.update_book(formatted_name, book)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes update_book with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      book = Google::Example::Library::V1::Book.new
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(book, request.book)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:update_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.update_book(formatted_name, book)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'move_book' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#move_book."
+
+    it 'invokes move_book without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      author = "author-1406328437"
+      title = "title110371416"
+      read = true
+      expected_response = Google::Example::Library::V1::Book.new(
+        name: name_2,
+        author: author,
+        title: title,
+        read: read
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(formatted_other_shelf_name, request.other_shelf_name)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:move_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.move_book(formatted_name, formatted_other_shelf_name)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes move_book with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(formatted_other_shelf_name, request.other_shelf_name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:move_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.move_book(formatted_name, formatted_other_shelf_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'list_strings' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#list_strings."
+
+    it 'invokes list_strings without error' do
+      # Create expected grpc response
+      next_page_token = ""
+      strings_element = "stringsElement474465855"
+      strings = [strings_element]
+      expected_response = Google::Example::Library::V1::ListStringsResponse.new(next_page_token: next_page_token, strings: strings)
+
+      # Mock Grpc layer
+      mock_method = proc do
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:list_strings, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.list_strings
+
+        # Verify the response
+        assert(response.instance_of?(Google::Gax::PagedEnumerable))
+        assert_equal(expected_response, response.page.response)
+        assert_nil(response.next_page)
+        assert_equal(expected_response.strings.to_a, response.to_a)
+      end
+    end
+
+    it 'invokes list_strings with error' do
+      # Mock Grpc layer
+      mock_method = proc do
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:list_strings, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.list_strings
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'add_comments' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#add_comments."
+
+    it 'invokes add_comments without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      comment = ''
+      stage = :UNSET
+      alignment = :CHAR
+      comments_element = Google::Example::Library::V1::Comment.new(
+        comment: comment,
+        stage: stage,
+        alignment: alignment
+      )
+      comments = [comments_element]
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(comments, request.comments)
+        nil
+      end
+      mock_stub = MockGrpcClientStub.new(:add_comments, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.add_comments(formatted_name, comments)
+
+        # Verify the response
+        assert_nil(response)
+      end
+    end
+
+    it 'invokes add_comments with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      comment = ''
+      stage = :UNSET
+      alignment = :CHAR
+      comments_element = Google::Example::Library::V1::Comment.new(
+        comment: comment,
+        stage: stage,
+        alignment: alignment
+      )
+      comments = [comments_element]
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(comments, request.comments)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:add_comments, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.add_comments(formatted_name, comments)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'get_book_from_archive' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_book_from_archive."
+
+    it 'invokes get_book_from_archive without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      author = "author-1406328437"
+      title = "title110371416"
+      read = true
+      expected_response = Google::Example::Library::V1::BookFromArchive.new(
+        name: name_2,
+        author: author,
+        title: title,
+        read: read
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:get_book_from_archive, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.get_book_from_archive(formatted_name)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes get_book_from_archive with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:get_book_from_archive, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.get_book_from_archive(formatted_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'get_book_from_anywhere' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_book_from_anywhere."
+
+    it 'invokes get_book_from_anywhere without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_alt_book_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      author = "author-1406328437"
+      title = "title110371416"
+      read = true
+      expected_response = Google::Example::Library::V1::BookFromAnywhere.new(
+        name: name_2,
+        author: author,
+        title: title,
+        read: read
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(formatted_alt_book_name, request.alt_book_name)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:get_book_from_anywhere, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.get_book_from_anywhere(formatted_name, formatted_alt_book_name)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes get_book_from_anywhere with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_alt_book_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(formatted_alt_book_name, request.alt_book_name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:get_book_from_anywhere, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.get_book_from_anywhere(formatted_name, formatted_alt_book_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'update_book_index' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#update_book_index."
+
+    it 'invokes update_book_index without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      index_name = "default index"
+      index_map_item = ''
+      index_map = { "default_key" => index_map_item }
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(index_name, request.index_name)
+        assert_equal(index_map, request.index_map)
+        nil
+      end
+      mock_stub = MockGrpcClientStub.new(:update_book_index, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.update_book_index(
+          formatted_name,
+          index_name,
+          index_map
+        )
+
+        # Verify the response
+        assert_nil(response)
+      end
+    end
+
+    it 'invokes update_book_index with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      index_name = "default index"
+      index_map_item = ''
+      index_map = { "default_key" => index_map_item }
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        assert_equal(index_name, request.index_name)
+        assert_equal(index_map, request.index_map)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:update_book_index, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.update_book_index(
+            formatted_name,
+            index_name,
+            index_map
+          )
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'stream_shelves' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#stream_shelves."
+
+    it 'invokes stream_shelves without error' do
+      # Create request parameters
+      request = Google::Example::Library::V1::StreamShelvesRequest.new
+
+      # Create expected grpc response
+      expected_response = Google::Example::Library::V1::StreamShelvesResponse.new
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        [expected_response]
+      end
+      mock_stub = MockGrpcClientStub.new(:stream_shelves, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.stream_shelves(request)
+
+        # Verify the response
+        assert_equal(1, response.count)
+        assert_equal(expected_response, response.first)
+      end
+    end
+
+    it 'invokes stream_shelves with error' do
+      # Create request parameters
+      request = Google::Example::Library::V1::StreamShelvesRequest.new
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:stream_shelves, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.stream_shelves(request)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'stream_books' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#stream_books."
+
+    it 'invokes stream_books without error' do
+      # Create request parameters
+      name = ''
+      request = Google::Example::Library::V1::StreamBooksRequest.new(name: name)
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      author = "author-1406328437"
+      title = "title110371416"
+      read = true
+      expected_response = Google::Example::Library::V1::Book.new(
+        name: name_2,
+        author: author,
+        title: title,
+        read: read
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(name, request.name)
+        [expected_response]
+      end
+      mock_stub = MockGrpcClientStub.new(:stream_books, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.stream_books(request)
+
+        # Verify the response
+        assert_equal(1, response.count)
+        assert_equal(expected_response, response.first)
+      end
+    end
+
+    it 'invokes stream_books with error' do
+      # Create request parameters
+      name = ''
+      request = Google::Example::Library::V1::StreamBooksRequest.new(name: name)
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:stream_books, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.stream_books(request)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'discuss_book' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#discuss_book."
+
+    it 'invokes discuss_book without error' do
+      # Create request parameters
+      name = ''
+      request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
+
+      # Create expected grpc response
+      user_name = "userName339340927"
+      comment = "95"
+      expected_response = Google::Example::Library::V1::Comment.new(user_name: user_name, comment: comment)
+
+      # Mock Grpc layer
+      mock_method = proc do |requests|
+        request = requests.first
+        assert_equal(name, request.name)
+        [expected_response]
+      end
+      mock_stub = MockGrpcClientStub.new(:discuss_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.discuss_book([request])
+
+        # Verify the response
+        assert_equal(1, response.count)
+        assert_equal(expected_response, response.first)
+      end
+    end
+
+    it 'invokes discuss_book with error' do
+      # Create request parameters
+      name = ''
+      request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
+
+      # Mock Grpc layer
+      mock_method = proc do |requests|
+        request = requests.first
+        assert_equal(name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:discuss_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.discuss_book([request])
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'monolog_about_book' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#monolog_about_book."
+
+    it 'invokes monolog_about_book without error' do
+      # Create request parameters
+      name = ''
+      request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
+
+      # Create expected grpc response
+      user_name = "userName339340927"
+      comment = "95"
+      expected_response = Google::Example::Library::V1::Comment.new(user_name: user_name, comment: comment)
+
+      # Mock Grpc layer
+      mock_method = proc do |requests|
+        request = requests.first
+        assert_equal(name, request.name)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:monolog_about_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.monolog_about_book([request])
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes monolog_about_book with error' do
+      # Create request parameters
+      name = ''
+      request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
+
+      # Mock Grpc layer
+      mock_method = proc do |requests|
+        request = requests.first
+        assert_equal(name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:monolog_about_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.monolog_about_book([request])
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'find_related_books' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#find_related_books."
+
+    it 'invokes find_related_books without error' do
+      # Create request parameters
+      names_element = ''
+      names = [names_element]
+      shelves = []
+
+      # Create expected grpc response
+      next_page_token = ""
+      names_element_2 = "namesElement21120252792"
+      names_2 = [names_element_2]
+      expected_response = Google::Example::Library::V1::FindRelatedBooksResponse.new(next_page_token: next_page_token, names: names_2)
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(names, request.names)
+        assert_equal(shelves, request.shelves)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:find_related_books, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.find_related_books(names, shelves)
+
+        # Verify the response
+        assert(response.instance_of?(Google::Gax::PagedEnumerable))
+        assert_equal(expected_response, response.page.response)
+        assert_nil(response.next_page)
+        assert_equal(expected_response.names.to_a, response.to_a)
+      end
+    end
+
+    it 'invokes find_related_books with error' do
+      # Create request parameters
+      names_element = ''
+      names = [names_element]
+      shelves = []
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(names, request.names)
+        assert_equal(shelves, request.shelves)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:find_related_books, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.find_related_books(names, shelves)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'add_tag' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#add_tag."
+
+    it 'invokes add_tag without error' do
+      # Create request parameters
+      formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      tag = ''
+
+      # Create expected grpc response
+      expected_response = Google::Tagger::V1::AddTagResponse.new
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_resource, request.resource)
+        assert_equal(tag, request.tag)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:add_tag, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.add_tag(formatted_resource, tag)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes add_tag with error' do
+      # Create request parameters
+      formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      tag = ''
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_resource, request.resource)
+        assert_equal(tag, request.tag)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:add_tag, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.add_tag(formatted_resource, tag)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'add_label' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#add_label."
+
+    it 'invokes add_label without error' do
+      # Create request parameters
+      formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      label = ''
+
+      # Create expected grpc response
+      expected_response = Google::Tagger::V1::AddLabelResponse.new
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_resource, request.resource)
+        assert_equal(label, request.label)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:add_label, mock_method)
+
+      Google::Tagger::V1::Labeler::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.add_label(formatted_resource, label)
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes add_label with error' do
+      # Create request parameters
+      formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      label = ''
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_resource, request.resource)
+        assert_equal(label, request.label)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:add_label, mock_method)
+
+      Google::Tagger::V1::Labeler::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.add_label(formatted_resource, label)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'get_big_book' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_big_book."
+
+    it 'invokes get_big_book without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Create expected grpc response
+      name_2 = "name2-1052831874"
+      author = "author-1406328437"
+      title = "title110371416"
+      read = true
+      expected_response = Google::Example::Library::V1::Book.new(
+        name: name_2,
+        author: author,
+        title: title,
+        read: read
+      )
+      result = Google::Protobuf::Any.new
+      result.pack(expected_response)
+      operation = Google::Longrunning::Operation.new(
+        name: 'operations/get_big_book_test',
+        done: true,
+        response: result
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        operation
+      end
+      mock_stub = MockGrpcClientStub.new(:get_big_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.get_big_book(formatted_name)
+
+        # Verify the response
+        assert_equal(expected_response, response.response)
+      end
+    end
+
+    it 'invokes get_big_book and returns an operation error.' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Create expected grpc response
+      operation_error = Google::Rpc::Status.new(
+        message: 'Operation error for Library::V1::LibraryServiceClient#get_big_book.'
+      )
+      operation = Google::Longrunning::Operation.new(
+        name: 'operations/get_big_book_test',
+        done: true,
+        error: operation_error
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        operation
+      end
+      mock_stub = MockGrpcClientStub.new(:get_big_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.get_big_book(formatted_name)
+
+        # Verify the response
+        assert(response.error?)
+        assert_equal(operation_error, response.error)
+      end
+    end
+
+    it 'invokes get_big_book with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:get_big_book, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.get_big_book(formatted_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'get_big_nothing' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_big_nothing."
+
+    it 'invokes get_big_nothing without error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Create expected grpc response
+      expected_response = Google::Protobuf::Empty.new
+      result = Google::Protobuf::Any.new
+      result.pack(expected_response)
+      operation = Google::Longrunning::Operation.new(
+        name: 'operations/get_big_nothing_test',
+        done: true,
+        response: result
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        operation
+      end
+      mock_stub = MockGrpcClientStub.new(:get_big_nothing, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.get_big_nothing(formatted_name)
+
+        # Verify the response
+        assert_equal(expected_response, response.response)
+      end
+    end
+
+    it 'invokes get_big_nothing and returns an operation error.' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Create expected grpc response
+      operation_error = Google::Rpc::Status.new(
+        message: 'Operation error for Library::V1::LibraryServiceClient#get_big_nothing.'
+      )
+      operation = Google::Longrunning::Operation.new(
+        name: 'operations/get_big_nothing_test',
+        done: true,
+        error: operation_error
+      )
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        operation
+      end
+      mock_stub = MockGrpcClientStub.new(:get_big_nothing, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.get_big_nothing(formatted_name)
+
+        # Verify the response
+        assert(response.error?)
+        assert_equal(operation_error, response.error)
+      end
+    end
+
+    it 'invokes get_big_nothing with error' do
+      # Create request parameters
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(formatted_name, request.name)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:get_big_nothing, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.get_big_nothing(formatted_name)
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+
+  describe 'test_optional_required_flattening_params' do
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#test_optional_required_flattening_params."
+
+    it 'invokes test_optional_required_flattening_params without error' do
+      # Create request parameters
+      required_singular_int32 = 0
+      required_singular_int64 = 0
+      required_singular_float = 0.0
+      required_singular_double = 0.0
+      required_singular_bool = false
+      required_singular_enum = :ZERO
+      required_singular_string = ''
+      required_singular_bytes = ''
+      required_singular_message = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerMessage.new
+      required_singular_resource_name = ''
+      required_singular_resource_name_oneof = ''
+      required_singular_fixed32 = 0
+      required_singular_fixed64 = 0
+      required_repeated_int32 = []
+      required_repeated_int64 = []
+      required_repeated_float = []
+      required_repeated_double = []
+      required_repeated_bool = []
+      required_repeated_enum = []
+      required_repeated_string = []
+      required_repeated_bytes = []
+      required_repeated_message = []
+      formatted_required_repeated_resource_name = []
+      formatted_required_repeated_resource_name_oneof = []
+      required_repeated_fixed32 = []
+      required_repeated_fixed64 = []
+      required_map = {}
+
+      # Create expected grpc response
+      expected_response = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsResponse.new
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(required_singular_int32, request.required_singular_int32)
+        assert_equal(required_singular_int64, request.required_singular_int64)
+        assert_equal(required_singular_float, request.required_singular_float)
+        assert_equal(required_singular_double, request.required_singular_double)
+        assert_equal(required_singular_bool, request.required_singular_bool)
+        assert_equal(required_singular_enum, request.required_singular_enum)
+        assert_equal(required_singular_string, request.required_singular_string)
+        assert_equal(required_singular_bytes, request.required_singular_bytes)
+        assert_equal(required_singular_message, request.required_singular_message)
+        assert_equal(required_singular_resource_name, request.required_singular_resource_name)
+        assert_equal(required_singular_resource_name_oneof, request.required_singular_resource_name_oneof)
+        assert_equal(required_singular_fixed32, request.required_singular_fixed32)
+        assert_equal(required_singular_fixed64, request.required_singular_fixed64)
+        assert_equal(required_repeated_int32, request.required_repeated_int32)
+        assert_equal(required_repeated_int64, request.required_repeated_int64)
+        assert_equal(required_repeated_float, request.required_repeated_float)
+        assert_equal(required_repeated_double, request.required_repeated_double)
+        assert_equal(required_repeated_bool, request.required_repeated_bool)
+        assert_equal(required_repeated_enum, request.required_repeated_enum)
+        assert_equal(required_repeated_string, request.required_repeated_string)
+        assert_equal(required_repeated_bytes, request.required_repeated_bytes)
+        assert_equal(required_repeated_message, request.required_repeated_message)
+        assert_equal(formatted_required_repeated_resource_name, request.required_repeated_resource_name)
+        assert_equal(formatted_required_repeated_resource_name_oneof, request.required_repeated_resource_name_oneof)
+        assert_equal(required_repeated_fixed32, request.required_repeated_fixed32)
+        assert_equal(required_repeated_fixed64, request.required_repeated_fixed64)
+        assert_equal(required_map, request.required_map)
+        expected_response
+      end
+      mock_stub = MockGrpcClientStub.new(:test_optional_required_flattening_params, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        response = client.test_optional_required_flattening_params(
+          required_singular_int32,
+          required_singular_int64,
+          required_singular_float,
+          required_singular_double,
+          required_singular_bool,
+          required_singular_enum,
+          required_singular_string,
+          required_singular_bytes,
+          required_singular_message,
+          required_singular_resource_name,
+          required_singular_resource_name_oneof,
+          required_singular_fixed32,
+          required_singular_fixed64,
+          required_repeated_int32,
+          required_repeated_int64,
+          required_repeated_float,
+          required_repeated_double,
+          required_repeated_bool,
+          required_repeated_enum,
+          required_repeated_string,
+          required_repeated_bytes,
+          required_repeated_message,
+          formatted_required_repeated_resource_name,
+          formatted_required_repeated_resource_name_oneof,
+          required_repeated_fixed32,
+          required_repeated_fixed64,
+          required_map
+        )
+
+        # Verify the response
+        assert_equal(expected_response, response)
+      end
+    end
+
+    it 'invokes test_optional_required_flattening_params with error' do
+      # Create request parameters
+      required_singular_int32 = 0
+      required_singular_int64 = 0
+      required_singular_float = 0.0
+      required_singular_double = 0.0
+      required_singular_bool = false
+      required_singular_enum = :ZERO
+      required_singular_string = ''
+      required_singular_bytes = ''
+      required_singular_message = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerMessage.new
+      required_singular_resource_name = ''
+      required_singular_resource_name_oneof = ''
+      required_singular_fixed32 = 0
+      required_singular_fixed64 = 0
+      required_repeated_int32 = []
+      required_repeated_int64 = []
+      required_repeated_float = []
+      required_repeated_double = []
+      required_repeated_bool = []
+      required_repeated_enum = []
+      required_repeated_string = []
+      required_repeated_bytes = []
+      required_repeated_message = []
+      formatted_required_repeated_resource_name = []
+      formatted_required_repeated_resource_name_oneof = []
+      required_repeated_fixed32 = []
+      required_repeated_fixed64 = []
+      required_map = {}
+
+      # Mock Grpc layer
+      mock_method = proc do |request|
+        assert_equal(required_singular_int32, request.required_singular_int32)
+        assert_equal(required_singular_int64, request.required_singular_int64)
+        assert_equal(required_singular_float, request.required_singular_float)
+        assert_equal(required_singular_double, request.required_singular_double)
+        assert_equal(required_singular_bool, request.required_singular_bool)
+        assert_equal(required_singular_enum, request.required_singular_enum)
+        assert_equal(required_singular_string, request.required_singular_string)
+        assert_equal(required_singular_bytes, request.required_singular_bytes)
+        assert_equal(required_singular_message, request.required_singular_message)
+        assert_equal(required_singular_resource_name, request.required_singular_resource_name)
+        assert_equal(required_singular_resource_name_oneof, request.required_singular_resource_name_oneof)
+        assert_equal(required_singular_fixed32, request.required_singular_fixed32)
+        assert_equal(required_singular_fixed64, request.required_singular_fixed64)
+        assert_equal(required_repeated_int32, request.required_repeated_int32)
+        assert_equal(required_repeated_int64, request.required_repeated_int64)
+        assert_equal(required_repeated_float, request.required_repeated_float)
+        assert_equal(required_repeated_double, request.required_repeated_double)
+        assert_equal(required_repeated_bool, request.required_repeated_bool)
+        assert_equal(required_repeated_enum, request.required_repeated_enum)
+        assert_equal(required_repeated_string, request.required_repeated_string)
+        assert_equal(required_repeated_bytes, request.required_repeated_bytes)
+        assert_equal(required_repeated_message, request.required_repeated_message)
+        assert_equal(formatted_required_repeated_resource_name, request.required_repeated_resource_name)
+        assert_equal(formatted_required_repeated_resource_name_oneof, request.required_repeated_resource_name_oneof)
+        assert_equal(required_repeated_fixed32, request.required_repeated_fixed32)
+        assert_equal(required_repeated_fixed64, request.required_repeated_fixed64)
+        assert_equal(required_map, request.required_map)
+        raise custom_error
+      end
+      mock_stub = MockGrpcClientStub.new(:test_optional_required_flattening_params, mock_method)
+
+      Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
+        client = Library::V1::LibraryServiceClient.new
+
+        # Call method
+        err = assert_raises Google::Gax::GaxError do
+          client.test_optional_required_flattening_params(
+            required_singular_int32,
+            required_singular_int64,
+            required_singular_float,
+            required_singular_double,
+            required_singular_bool,
+            required_singular_enum,
+            required_singular_string,
+            required_singular_bytes,
+            required_singular_message,
+            required_singular_resource_name,
+            required_singular_resource_name_oneof,
+            required_singular_fixed32,
+            required_singular_fixed64,
+            required_repeated_int32,
+            required_repeated_int64,
+            required_repeated_float,
+            required_repeated_double,
+            required_repeated_bool,
+            required_repeated_enum,
+            required_repeated_string,
+            required_repeated_bytes,
+            required_repeated_message,
+            formatted_required_repeated_resource_name,
+            formatted_required_repeated_resource_name_oneof,
+            required_repeated_fixed32,
+            required_repeated_fixed64,
+            required_map
+          )
+        end
+
+        # Verify the GaxError wrapped the custom error that was raised.
+        assert_match(custom_error.message, err.message)
+      end
+    end
+  end
+end
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_doc_yardopts_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_doc_yardopts_library.baseline
new file mode 100644
index 0000000000..e355f5ca70
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_doc_yardopts_library.baseline
@@ -0,0 +1,9 @@
+============== file: .yardopts ==============
+--no-private
+--title=Google Example Library API
+--exclude lib/library/v1
+--markup markdown
+
+./lib/**/*.rb
+-
+README.md
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_gemspec_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_gemspec_library.baseline
index b79e4c585c..861a86ec80 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_gemspec_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_gemspec_library.baseline
@@ -2,34 +2,31 @@
 # -*- ruby -*-
 # encoding: utf-8
 
-Gem::Specification.new do |s|
-  s.name          = "library"
-  s.version       = "0.6.8"
-
-  s.authors       = ["Google, Inc."]
-  s.description   = "Google Example Library API client for Ruby."
-  s.email         = "googleapis-packages@google.com"
-  s.files         = Dir.glob(File.join("lib", "**", "*.rb"))
-  s.files        += Dir.glob(File.join('lib', '**', '*.json'))
-  s.files        += %w(Rakefile README.md LICENSE)
-  s.homepage      = "https://github.com/googleapis/googleapis"
-  s.license       = "Apache-2.0"
-  s.platform      = Gem::Platform::RUBY
-  s.require_paths = ["lib"]
-  s.required_ruby_version = ">= 2.0.0"
-  s.requirements << "libgrpc ~> 1.0 needs to be installed"
-  s.summary       = "GRPC library for Google Example Library API"
-
-  s.add_dependency "grpc", "~> 1.0"
-  s.add_dependency "googleauth", "~> 0.5.1"
-  s.add_dependency "google-gax", "~> 0.8.0"
-  s.add_dependency "google-common-protos", "~> 1.3.1"
-  s.add_dependency "google-some-other-package-v1", "~> 0.2.1"
-
-  s.add_development_dependency "bundler", "~> 1.9"
-  s.add_development_dependency "rake", "~> 10.4"
-  s.add_development_dependency "rubocop", "~> 0.32"
-  s.add_development_dependency "simplecov", "~> 0.9"
-  s.add_development_dependency "minitest", "~> 5.10"
+Gem::Specification.new do |gem|
+  gem.name          = "library"
+  gem.version       = "0.6.8"
+
+  gem.authors       = ["Google, Inc."]
+  gem.email         = "googleapis-packages@google.com"
+  gem.description   = "library is the official library for Google Example Library API."
+  gem.summary       = "API Client library for Google Example Library API"
+  gem.homepage      = "https://github.com/googleapis/googleapis"
+  gem.license       = "Apache-2.0"
+
+  gem.platform      = Gem::Platform::RUBY
+
+  gem.files         = `git ls-files -- lib/*`.split("\n") +
+                      ["README.md", "LICENSE", ".yardopts"]
+  gem.require_paths = ["lib"]
+
+  gem.required_ruby_version = ">= 2.0.0"
+
+  gem.add_dependency "google-gax", "~> 0.8.0"
+  gem.add_dependency "google-common-protos", "~> 1.3.1"
+  gem.add_dependency "google-some-other-package-v1", "~> 0.2.1"
+
+  gem.add_development_dependency "minitest", "~> 5.10"
+  gem.add_development_dependency "rubocop", "<= 0.35.1"
+  gem.add_development_dependency "simplecov", "~> 0.9"
 end
 
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_gitignore_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_gitignore_library.baseline
new file mode 100644
index 0000000000..1d760dcffc
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_gitignore_library.baseline
@@ -0,0 +1,14 @@
+============== file: .gitignore ==============
+Gemfile.lock
+coverage/*
+doc/*
+pkg/*
+html/*
+jsondoc/*
+
+# Ignore YARD stuffs
+.yardoc
+
+# IDE settings
+.idea
+*.iml
\ No newline at end of file
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_main_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_main_library.baseline
index 616f068a13..f545bbb4ac 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_main_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_main_library.baseline
@@ -430,11 +430,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #   Shelf = Google::Example::Library::V1::Shelf
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   shelf = Shelf.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   shelf = Google::Example::Library::V1::Shelf.new
       #   response = library_service_client.create_shelf(shelf)
 
       def create_shelf \
@@ -463,10 +460,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #   options_ = ''
       #   response = library_service_client.get_shelf(formatted_name, options_)
 
@@ -499,9 +494,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #
       #   # Iterate over all results.
       #   library_service_client.list_shelves.each do |element|
@@ -532,10 +525,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #   library_service_client.delete_shelf(formatted_name)
 
       def delete_shelf \
@@ -564,11 +555,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
-      #   formatted_other_shelf_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #   response = library_service_client.merge_shelves(formatted_name, formatted_other_shelf_name)
 
       def merge_shelves \
@@ -596,12 +585,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   Book = Google::Example::Library::V1::Book
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
-      #   book = Book.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   book = Google::Example::Library::V1::Book.new
       #   response = library_service_client.create_book(formatted_name, book)
 
       def create_book \
@@ -635,15 +621,11 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #   SeriesUuid = Google::Example::Library::V1::SeriesUuid
-      #   Shelf = Google::Example::Library::V1::Shelf
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   shelf = Shelf.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   shelf = Google::Example::Library::V1::Shelf.new
       #   books = []
       #   series_string = "foobar"
-      #   series_uuid = SeriesUuid.new(series_string: series_string)
+      #   series_uuid = Google::Example::Library::V1::SeriesUuid.new(series_string: series_string)
       #   response = library_service_client.publish_series(shelf, books, series_uuid)
 
       def publish_series \
@@ -675,10 +657,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   response = library_service_client.get_book(formatted_name)
 
       def get_book \
@@ -714,10 +694,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #
       #   # Iterate over all results.
       #   library_service_client.list_books(formatted_name).each do |element|
@@ -756,10 +734,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   library_service_client.delete_book(formatted_name)
 
       def delete_book \
@@ -790,12 +766,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   Book = Google::Example::Library::V1::Book
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      #   book = Book.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   book = Google::Example::Library::V1::Book.new
       #   response = library_service_client.update_book(formatted_name, book)
 
       def update_book \
@@ -827,11 +800,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      #   formatted_other_shelf_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       #   response = library_service_client.move_book(formatted_name, formatted_other_shelf_name)
 
       def move_book \
@@ -866,9 +837,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #
       #   # Iterate over all results.
       #   library_service_client.list_strings.each do |element|
@@ -905,17 +874,12 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   Alignment = Google::Example::Library::V1::SomeMessage2::SomeMessage3::Alignment
-      #   Comment = Google::Example::Library::V1::Comment
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #   Stage = Google::Example::Library::V1::Comment::Stage
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   comment = ''
-      #   stage = Stage::UNSET
-      #   alignment = Alignment::CHAR
-      #   comments_element = Comment.new(
+      #   stage = :UNSET
+      #   alignment = :CHAR
+      #   comments_element = Google::Example::Library::V1::Comment.new(
       #     comment: comment,
       #     stage: stage,
       #     alignment: alignment
@@ -947,10 +911,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
       #   response = library_service_client.get_book_from_archive(formatted_name)
 
       def get_book_from_archive \
@@ -977,11 +939,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      #   formatted_alt_book_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   formatted_alt_book_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   response = library_service_client.get_book_from_anywhere(formatted_name, formatted_alt_book_name)
 
       def get_book_from_anywhere \
@@ -1010,10 +970,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   index_name = "default index"
       #   index_map_item = ''
       #   index_map = { "default_key" => index_map_item }
@@ -1046,9 +1004,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   library_service_client.stream_shelves.each do |element|
       #     # Process element.
       #   end
@@ -1073,9 +1029,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   name = ''
       #   library_service_client.stream_books(name).each do |element|
       #     # Process element.
@@ -1111,12 +1065,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   DiscussBookRequest = Google::Example::Library::V1::DiscussBookRequest
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   name = ''
-      #   request = DiscussBookRequest.new(name: name)
+      #   request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
       #   requests = [request]
       #   library_service_client.discuss_book(requests).each do |element|
       #     # Process element.
@@ -1145,12 +1096,9 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   DiscussBookRequest = Google::Example::Library::V1::DiscussBookRequest
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   name = ''
-      #   request = DiscussBookRequest.new(name: name)
+      #   request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
       #   requests = [request]
       #   response = library_service_client.monolog_about_book(requests)
 
@@ -1178,9 +1126,7 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   names_element = ''
       #   names = [names_element]
       #   shelves = []
@@ -1227,10 +1173,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_resource = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   tag = ''
       #   response = library_service_client.add_tag(formatted_resource, tag)
 
@@ -1261,10 +1205,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_resource = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #   label = ''
       #   response = library_service_client.add_label(formatted_resource, label)
 
@@ -1291,10 +1233,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #
       #   # Register a callback during the method call.
       #   operation = library_service_client.get_big_book(formatted_name) do |op|
@@ -1352,10 +1292,8 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
-      #   formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      #   library_service_client = Library::V1::LibraryServiceClient.new
+      #   formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       #
       #   # Register a callback during the method call.
       #   operation = library_service_client.get_big_nothing(formatted_name) do |op|
@@ -1465,20 +1403,16 @@ module Library
       # @example
       #   require "library/v1"
       #
-      #   InnerEnum = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerEnum
-      #   InnerMessage = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerMessage
-      #   LibraryServiceClient = Library::V1::LibraryServiceClient
-      #
-      #   library_service_client = LibraryServiceClient.new
+      #   library_service_client = Library::V1::LibraryServiceClient.new
       #   required_singular_int32 = 0
       #   required_singular_int64 = 0
       #   required_singular_float = 0.0
       #   required_singular_double = 0.0
       #   required_singular_bool = false
-      #   required_singular_enum = InnerEnum::ZERO
+      #   required_singular_enum = :ZERO
       #   required_singular_string = ''
       #   required_singular_bytes = ''
-      #   required_singular_message = InnerMessage.new
+      #   required_singular_message = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerMessage.new
       #   required_singular_resource_name = ''
       #   required_singular_resource_name_oneof = ''
       #   required_singular_fixed32 = 0
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_rubocop_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_rubocop_library.baseline
new file mode 100644
index 0000000000..3113cd4443
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_rubocop_library.baseline
@@ -0,0 +1,54 @@
+============== file: .rubocop.yml ==============
+AllCops:
+  Exclude:
+    - "library.gemspec"
+    - "lib/google/library/**/*"
+    - "lib/library/v1/**/*"
+    - "Rakefile"
+    - "test/**/*"
+
+Documentation:
+  Enabled: false
+
+Style/StringLiterals:
+  EnforcedStyle: double_quotes
+Style/MethodDefParentheses:
+  EnforcedStyle: require_no_parentheses
+Style/NumericLiterals:
+  Enabled: false
+Style/SpaceAroundOperators:
+  Enabled: false
+Metrics/ClassLength:
+  Enabled: false
+Style/EmptyLines:
+  Enabled: false
+Style/EmptyElse:
+  Enabled: false
+Style/HashSyntax:
+  Exclude:
+    - "lib/library/v1/**/*"
+Metrics/LineLength:
+  Exclude:
+    - "lib/library/v1/**/*"
+Metrics/CyclomaticComplexity:
+  Max: 10
+Metrics/PerceivedComplexity:
+  Max: 10
+Metrics/AbcSize:
+  Max: 25
+  Exclude:
+    - "lib/library/v1/**/*"
+Metrics/MethodLength:
+  Max: 20
+  Exclude:
+    - "lib/library/v1/**/*"
+Metrics/ParameterLists:
+  Enabled: false
+Style/RescueModifier:
+  Enabled: false
+Style/ClassVars:
+  Enabled: false
+Style/TrivialAccessors:
+  Enabled: false
+Style/FileName:
+  Enabled: false
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_smoke_test_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_smoke_test_library.baseline
index 188d0335c8..07e5ae17aa 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_smoke_test_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_smoke_test_library.baseline
@@ -26,16 +26,10 @@ describe "LibraryServiceSmokeTest" do
     end
     project_id = ENV["SMOKE_TEST_PROJECT"].freeze
 
-    Book = Google::Example::Library::V1::Book
-    FieldMask = Google::Protobuf::FieldMask
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    Rating = Google::Example::Library::V1::Book::Rating
-    UpdateBookRequest = Google::Example::Library::V1::UpdateBookRequest
-
-    library_service_client = LibraryServiceClient.new
-    formatted_name = LibraryServiceClient.book_path("testShelf-" + Time.new.to_i.to_s, project_id)
-    rating = Rating::GOOD
-    book = Book.new(rating: rating)
+    library_service_client = Library::V1::LibraryServiceClient.new
+    formatted_name = Library::V1::LibraryServiceClient.book_path("testShelf-" + Time.new.to_i.to_s, project_id)
+    rating = :GOOD
+    book = Google::Example::Library::V1::Book.new(rating: rating)
     response = library_service_client.update_book(formatted_name, book)
   end
 end
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_test_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_test_library.baseline
index 4f372ef2b3..b59f59db92 100644
--- a/src/test/java/com/google/api/codegen/testdata/ruby_test_library.baseline
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_test_library.baseline
@@ -57,20 +57,17 @@ end
 describe Library::V1::LibraryServiceClient do
 
   describe 'create_shelf' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#create_shelf."
-
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    Shelf = Google::Example::Library::V1::Shelf
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#create_shelf."
 
     it 'invokes create_shelf without error' do
       # Create request parameters
-      shelf = Shelf.new
+      shelf = Google::Example::Library::V1::Shelf.new
 
       # Create expected grpc response
       name = "name3373707"
       theme = "theme110327241"
       internal_theme = "internalTheme792518087"
-      expected_response = Shelf.new(
+      expected_response = Google::Example::Library::V1::Shelf.new(
         name: name,
         theme: theme,
         internal_theme: internal_theme
@@ -84,7 +81,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:create_shelf, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.create_shelf(shelf)
@@ -96,7 +93,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes create_shelf with error' do
       # Create request parameters
-      shelf = Shelf.new
+      shelf = Google::Example::Library::V1::Shelf.new
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -106,7 +103,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:create_shelf, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -120,21 +117,18 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'get_shelf' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#get_shelf."
-
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    Shelf = Google::Example::Library::V1::Shelf
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_shelf."
 
     it 'invokes get_shelf without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       options_ = ''
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       theme = "theme110327241"
       internal_theme = "internalTheme792518087"
-      expected_response = Shelf.new(
+      expected_response = Google::Example::Library::V1::Shelf.new(
         name: name_2,
         theme: theme,
         internal_theme: internal_theme
@@ -149,7 +143,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_shelf, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.get_shelf(formatted_name, options_)
@@ -161,7 +155,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes get_shelf with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
       options_ = ''
 
       # Mock Grpc layer
@@ -173,7 +167,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_shelf, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -187,18 +181,14 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'list_shelves' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#list_shelves."
-
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    ListShelvesResponse = Google::Example::Library::V1::ListShelvesResponse
-    Shelf = Google::Example::Library::V1::Shelf
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#list_shelves."
 
     it 'invokes list_shelves without error' do
       # Create expected grpc response
       next_page_token = ""
-      shelves_element = Shelf.new
+      shelves_element = Google::Example::Library::V1::Shelf.new
       shelves = [shelves_element]
-      expected_response = ListShelvesResponse.new(next_page_token: next_page_token, shelves: shelves)
+      expected_response = Google::Example::Library::V1::ListShelvesResponse.new(next_page_token: next_page_token, shelves: shelves)
 
       # Mock Grpc layer
       mock_method = proc do
@@ -207,7 +197,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:list_shelves, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.list_shelves
@@ -228,7 +218,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:list_shelves, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -242,14 +232,11 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'delete_shelf' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#delete_shelf."
-
-    Empty = Google::Protobuf::Empty
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#delete_shelf."
 
     it 'invokes delete_shelf without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -259,7 +246,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:delete_shelf, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.delete_shelf(formatted_name)
@@ -271,7 +258,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes delete_shelf with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -281,7 +268,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:delete_shelf, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -295,21 +282,18 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'merge_shelves' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#merge_shelves."
-
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    Shelf = Google::Example::Library::V1::Shelf
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#merge_shelves."
 
     it 'invokes merge_shelves without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
-      formatted_other_shelf_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       theme = "theme110327241"
       internal_theme = "internalTheme792518087"
-      expected_response = Shelf.new(
+      expected_response = Google::Example::Library::V1::Shelf.new(
         name: name_2,
         theme: theme,
         internal_theme: internal_theme
@@ -324,7 +308,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:merge_shelves, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.merge_shelves(formatted_name, formatted_other_shelf_name)
@@ -336,8 +320,8 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes merge_shelves with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
-      formatted_other_shelf_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -348,7 +332,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:merge_shelves, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -362,22 +346,19 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'create_book' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#create_book."
-
-    Book = Google::Example::Library::V1::Book
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#create_book."
 
     it 'invokes create_book without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
-      book = Book.new
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      book = Google::Example::Library::V1::Book.new
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       author = "author-1406328437"
       title = "title110371416"
       read = true
-      expected_response = Book.new(
+      expected_response = Google::Example::Library::V1::Book.new(
         name: name_2,
         author: author,
         title: title,
@@ -393,7 +374,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:create_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.create_book(formatted_name, book)
@@ -405,8 +386,8 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes create_book with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
-      book = Book.new
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
+      book = Google::Example::Library::V1::Book.new
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -417,7 +398,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:create_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -431,24 +412,19 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'publish_series' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#publish_series."
-
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    PublishSeriesResponse = Google::Example::Library::V1::PublishSeriesResponse
-    SeriesUuid = Google::Example::Library::V1::SeriesUuid
-    Shelf = Google::Example::Library::V1::Shelf
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#publish_series."
 
     it 'invokes publish_series without error' do
       # Create request parameters
-      shelf = Shelf.new
+      shelf = Google::Example::Library::V1::Shelf.new
       books = []
       series_string = "foobar"
-      series_uuid = SeriesUuid.new(series_string: series_string)
+      series_uuid = Google::Example::Library::V1::SeriesUuid.new(series_string: series_string)
 
       # Create expected grpc response
       book_names_element = "bookNamesElement1491670575"
       book_names = [book_names_element]
-      expected_response = PublishSeriesResponse.new(book_names: book_names)
+      expected_response = Google::Example::Library::V1::PublishSeriesResponse.new(book_names: book_names)
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -460,7 +436,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:publish_series, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.publish_series(
@@ -476,10 +452,10 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes publish_series with error' do
       # Create request parameters
-      shelf = Shelf.new
+      shelf = Google::Example::Library::V1::Shelf.new
       books = []
       series_string = "foobar"
-      series_uuid = SeriesUuid.new(series_string: series_string)
+      series_uuid = Google::Example::Library::V1::SeriesUuid.new(series_string: series_string)
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -491,7 +467,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:publish_series, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -509,21 +485,18 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'get_book' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#get_book."
-
-    Book = Google::Example::Library::V1::Book
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_book."
 
     it 'invokes get_book without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       author = "author-1406328437"
       title = "title110371416"
       read = true
-      expected_response = Book.new(
+      expected_response = Google::Example::Library::V1::Book.new(
         name: name_2,
         author: author,
         title: title,
@@ -538,7 +511,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.get_book(formatted_name)
@@ -550,7 +523,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes get_book with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -560,7 +533,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -574,21 +547,17 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'list_books' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#list_books."
-
-    Book = Google::Example::Library::V1::Book
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    ListBooksResponse = Google::Example::Library::V1::ListBooksResponse
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#list_books."
 
     it 'invokes list_books without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
 
       # Create expected grpc response
       next_page_token = ""
-      books_element = Book.new
+      books_element = Google::Example::Library::V1::Book.new
       books = [books_element]
-      expected_response = ListBooksResponse.new(next_page_token: next_page_token, books: books)
+      expected_response = Google::Example::Library::V1::ListBooksResponse.new(next_page_token: next_page_token, books: books)
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -598,7 +567,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:list_books, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.list_books(formatted_name)
@@ -613,7 +582,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes list_books with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -623,7 +592,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:list_books, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -637,14 +606,11 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'delete_book' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#delete_book."
-
-    Empty = Google::Protobuf::Empty
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#delete_book."
 
     it 'invokes delete_book without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -654,7 +620,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:delete_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.delete_book(formatted_name)
@@ -666,7 +632,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes delete_book with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -676,7 +642,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:delete_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -690,22 +656,19 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'update_book' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#update_book."
-
-    Book = Google::Example::Library::V1::Book
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#update_book."
 
     it 'invokes update_book without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      book = Book.new
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      book = Google::Example::Library::V1::Book.new
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       author = "author-1406328437"
       title = "title110371416"
       read = true
-      expected_response = Book.new(
+      expected_response = Google::Example::Library::V1::Book.new(
         name: name_2,
         author: author,
         title: title,
@@ -721,7 +684,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:update_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.update_book(formatted_name, book)
@@ -733,8 +696,8 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes update_book with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      book = Book.new
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      book = Google::Example::Library::V1::Book.new
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -745,7 +708,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:update_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -759,22 +722,19 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'move_book' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#move_book."
-
-    Book = Google::Example::Library::V1::Book
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#move_book."
 
     it 'invokes move_book without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      formatted_other_shelf_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       author = "author-1406328437"
       title = "title110371416"
       read = true
-      expected_response = Book.new(
+      expected_response = Google::Example::Library::V1::Book.new(
         name: name_2,
         author: author,
         title: title,
@@ -790,7 +750,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:move_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.move_book(formatted_name, formatted_other_shelf_name)
@@ -802,8 +762,8 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes move_book with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      formatted_other_shelf_name = LibraryServiceClient.shelf_path("[SHELF_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_other_shelf_name = Library::V1::LibraryServiceClient.shelf_path("[SHELF_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -814,7 +774,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:move_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -828,17 +788,14 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'list_strings' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#list_strings."
-
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    ListStringsResponse = Google::Example::Library::V1::ListStringsResponse
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#list_strings."
 
     it 'invokes list_strings without error' do
       # Create expected grpc response
       next_page_token = ""
       strings_element = "stringsElement474465855"
       strings = [strings_element]
-      expected_response = ListStringsResponse.new(next_page_token: next_page_token, strings: strings)
+      expected_response = Google::Example::Library::V1::ListStringsResponse.new(next_page_token: next_page_token, strings: strings)
 
       # Mock Grpc layer
       mock_method = proc do
@@ -847,7 +804,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:list_strings, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.list_strings
@@ -868,7 +825,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:list_strings, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -882,21 +839,15 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'add_comments' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#add_comments."
-
-    Alignment = Google::Example::Library::V1::SomeMessage2::SomeMessage3::Alignment
-    Comment = Google::Example::Library::V1::Comment
-    Empty = Google::Protobuf::Empty
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    Stage = Google::Example::Library::V1::Comment::Stage
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#add_comments."
 
     it 'invokes add_comments without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       comment = ''
-      stage = Stage::UNSET
-      alignment = Alignment::CHAR
-      comments_element = Comment.new(
+      stage = :UNSET
+      alignment = :CHAR
+      comments_element = Google::Example::Library::V1::Comment.new(
         comment: comment,
         stage: stage,
         alignment: alignment
@@ -912,7 +863,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:add_comments, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.add_comments(formatted_name, comments)
@@ -924,11 +875,11 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes add_comments with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       comment = ''
-      stage = Stage::UNSET
-      alignment = Alignment::CHAR
-      comments_element = Comment.new(
+      stage = :UNSET
+      alignment = :CHAR
+      comments_element = Google::Example::Library::V1::Comment.new(
         comment: comment,
         stage: stage,
         alignment: alignment
@@ -944,7 +895,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:add_comments, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -958,21 +909,18 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'get_book_from_archive' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#get_book_from_archive."
-
-    BookFromArchive = Google::Example::Library::V1::BookFromArchive
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_book_from_archive."
 
     it 'invokes get_book_from_archive without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       author = "author-1406328437"
       title = "title110371416"
       read = true
-      expected_response = BookFromArchive.new(
+      expected_response = Google::Example::Library::V1::BookFromArchive.new(
         name: name_2,
         author: author,
         title: title,
@@ -987,7 +935,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_book_from_archive, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.get_book_from_archive(formatted_name)
@@ -999,7 +947,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes get_book_from_archive with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.archived_book_path("[ARCHIVE_PATH]", "[BOOK_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1009,7 +957,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_book_from_archive, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1023,22 +971,19 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'get_book_from_anywhere' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#get_book_from_anywhere."
-
-    BookFromAnywhere = Google::Example::Library::V1::BookFromAnywhere
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_book_from_anywhere."
 
     it 'invokes get_book_from_anywhere without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      formatted_alt_book_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_alt_book_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       author = "author-1406328437"
       title = "title110371416"
       read = true
-      expected_response = BookFromAnywhere.new(
+      expected_response = Google::Example::Library::V1::BookFromAnywhere.new(
         name: name_2,
         author: author,
         title: title,
@@ -1054,7 +999,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_book_from_anywhere, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.get_book_from_anywhere(formatted_name, formatted_alt_book_name)
@@ -1066,8 +1011,8 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes get_book_from_anywhere with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
-      formatted_alt_book_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_alt_book_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1078,7 +1023,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_book_from_anywhere, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1092,14 +1037,11 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'update_book_index' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#update_book_index."
-
-    Empty = Google::Protobuf::Empty
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#update_book_index."
 
     it 'invokes update_book_index without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       index_name = "default index"
       index_map_item = ''
       index_map = { "default_key" => index_map_item }
@@ -1114,7 +1056,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:update_book_index, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.update_book_index(
@@ -1130,7 +1072,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes update_book_index with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       index_name = "default index"
       index_map_item = ''
       index_map = { "default_key" => index_map_item }
@@ -1145,7 +1087,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:update_book_index, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1163,18 +1105,14 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'stream_shelves' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#stream_shelves."
-
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    StreamShelvesRequest = Google::Example::Library::V1::StreamShelvesRequest
-    StreamShelvesResponse = Google::Example::Library::V1::StreamShelvesResponse
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#stream_shelves."
 
     it 'invokes stream_shelves without error' do
       # Create request parameters
-      request = StreamShelvesRequest.new
+      request = Google::Example::Library::V1::StreamShelvesRequest.new
 
       # Create expected grpc response
-      expected_response = StreamShelvesResponse.new
+      expected_response = Google::Example::Library::V1::StreamShelvesResponse.new
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1183,7 +1121,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:stream_shelves, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.stream_shelves(request)
@@ -1196,7 +1134,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes stream_shelves with error' do
       # Create request parameters
-      request = StreamShelvesRequest.new
+      request = Google::Example::Library::V1::StreamShelvesRequest.new
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1205,7 +1143,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:stream_shelves, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1219,23 +1157,19 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'stream_books' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#stream_books."
-
-    Book = Google::Example::Library::V1::Book
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    StreamBooksRequest = Google::Example::Library::V1::StreamBooksRequest
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#stream_books."
 
     it 'invokes stream_books without error' do
       # Create request parameters
       name = ''
-      request = StreamBooksRequest.new(name: name)
+      request = Google::Example::Library::V1::StreamBooksRequest.new(name: name)
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       author = "author-1406328437"
       title = "title110371416"
       read = true
-      expected_response = Book.new(
+      expected_response = Google::Example::Library::V1::Book.new(
         name: name_2,
         author: author,
         title: title,
@@ -1250,7 +1184,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:stream_books, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.stream_books(request)
@@ -1264,7 +1198,7 @@ describe Library::V1::LibraryServiceClient do
     it 'invokes stream_books with error' do
       # Create request parameters
       name = ''
-      request = StreamBooksRequest.new(name: name)
+      request = Google::Example::Library::V1::StreamBooksRequest.new(name: name)
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1274,7 +1208,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:stream_books, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1288,21 +1222,17 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'discuss_book' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#discuss_book."
-
-    Comment = Google::Example::Library::V1::Comment
-    DiscussBookRequest = Google::Example::Library::V1::DiscussBookRequest
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#discuss_book."
 
     it 'invokes discuss_book without error' do
       # Create request parameters
       name = ''
-      request = DiscussBookRequest.new(name: name)
+      request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
 
       # Create expected grpc response
       user_name = "userName339340927"
       comment = "95"
-      expected_response = Comment.new(user_name: user_name, comment: comment)
+      expected_response = Google::Example::Library::V1::Comment.new(user_name: user_name, comment: comment)
 
       # Mock Grpc layer
       mock_method = proc do |requests|
@@ -1313,7 +1243,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:discuss_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.discuss_book([request])
@@ -1327,7 +1257,7 @@ describe Library::V1::LibraryServiceClient do
     it 'invokes discuss_book with error' do
       # Create request parameters
       name = ''
-      request = DiscussBookRequest.new(name: name)
+      request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
 
       # Mock Grpc layer
       mock_method = proc do |requests|
@@ -1338,7 +1268,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:discuss_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1352,21 +1282,17 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'monolog_about_book' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#monolog_about_book."
-
-    Comment = Google::Example::Library::V1::Comment
-    DiscussBookRequest = Google::Example::Library::V1::DiscussBookRequest
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#monolog_about_book."
 
     it 'invokes monolog_about_book without error' do
       # Create request parameters
       name = ''
-      request = DiscussBookRequest.new(name: name)
+      request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
 
       # Create expected grpc response
       user_name = "userName339340927"
       comment = "95"
-      expected_response = Comment.new(user_name: user_name, comment: comment)
+      expected_response = Google::Example::Library::V1::Comment.new(user_name: user_name, comment: comment)
 
       # Mock Grpc layer
       mock_method = proc do |requests|
@@ -1377,7 +1303,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:monolog_about_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.monolog_about_book([request])
@@ -1390,7 +1316,7 @@ describe Library::V1::LibraryServiceClient do
     it 'invokes monolog_about_book with error' do
       # Create request parameters
       name = ''
-      request = DiscussBookRequest.new(name: name)
+      request = Google::Example::Library::V1::DiscussBookRequest.new(name: name)
 
       # Mock Grpc layer
       mock_method = proc do |requests|
@@ -1401,7 +1327,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:monolog_about_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1415,10 +1341,7 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'find_related_books' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#find_related_books."
-
-    FindRelatedBooksResponse = Google::Example::Library::V1::FindRelatedBooksResponse
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#find_related_books."
 
     it 'invokes find_related_books without error' do
       # Create request parameters
@@ -1430,7 +1353,7 @@ describe Library::V1::LibraryServiceClient do
       next_page_token = ""
       names_element_2 = "namesElement21120252792"
       names_2 = [names_element_2]
-      expected_response = FindRelatedBooksResponse.new(next_page_token: next_page_token, names: names_2)
+      expected_response = Google::Example::Library::V1::FindRelatedBooksResponse.new(next_page_token: next_page_token, names: names_2)
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1441,7 +1364,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:find_related_books, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.find_related_books(names, shelves)
@@ -1469,7 +1392,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:find_related_books, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1483,18 +1406,15 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'add_tag' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#add_tag."
-
-    AddTagResponse = Google::Tagger::V1::AddTagResponse
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#add_tag."
 
     it 'invokes add_tag without error' do
       # Create request parameters
-      formatted_resource = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       tag = ''
 
       # Create expected grpc response
-      expected_response = AddTagResponse.new
+      expected_response = Google::Tagger::V1::AddTagResponse.new
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1505,7 +1425,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:add_tag, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.add_tag(formatted_resource, tag)
@@ -1517,7 +1437,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes add_tag with error' do
       # Create request parameters
-      formatted_resource = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       tag = ''
 
       # Mock Grpc layer
@@ -1529,7 +1449,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:add_tag, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1543,18 +1463,15 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'add_label' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#add_label."
-
-    AddLabelResponse = Google::Tagger::V1::AddLabelResponse
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#add_label."
 
     it 'invokes add_label without error' do
       # Create request parameters
-      formatted_resource = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       label = ''
 
       # Create expected grpc response
-      expected_response = AddLabelResponse.new
+      expected_response = Google::Tagger::V1::AddLabelResponse.new
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1565,7 +1482,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:add_label, mock_method)
 
       Google::Tagger::V1::Labeler::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.add_label(formatted_resource, label)
@@ -1577,7 +1494,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes add_label with error' do
       # Create request parameters
-      formatted_resource = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_resource = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
       label = ''
 
       # Mock Grpc layer
@@ -1589,7 +1506,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:add_label, mock_method)
 
       Google::Tagger::V1::Labeler::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1603,21 +1520,18 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'get_big_book' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#get_big_book."
-
-    Book = Google::Example::Library::V1::Book
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_big_book."
 
     it 'invokes get_big_book without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Create expected grpc response
       name_2 = "name2-1052831874"
       author = "author-1406328437"
       title = "title110371416"
       read = true
-      expected_response = Book.new(
+      expected_response = Google::Example::Library::V1::Book.new(
         name: name_2,
         author: author,
         title: title,
@@ -1639,7 +1553,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_big_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.get_big_book(formatted_name)
@@ -1651,11 +1565,11 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes get_big_book and returns an operation error.' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Create expected grpc response
       operation_error = Google::Rpc::Status.new(
-        message: 'Operation error for LibraryServiceClient#get_big_book.'
+        message: 'Operation error for Library::V1::LibraryServiceClient#get_big_book.'
       )
       operation = Google::Longrunning::Operation.new(
         name: 'operations/get_big_book_test',
@@ -1671,7 +1585,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_big_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.get_big_book(formatted_name)
@@ -1684,7 +1598,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes get_big_book with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1694,7 +1608,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_big_book, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1708,17 +1622,14 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'get_big_nothing' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#get_big_nothing."
-
-    Empty = Google::Protobuf::Empty
-    LibraryServiceClient = Library::V1::LibraryServiceClient
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#get_big_nothing."
 
     it 'invokes get_big_nothing without error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Create expected grpc response
-      expected_response = Empty.new
+      expected_response = Google::Protobuf::Empty.new
       result = Google::Protobuf::Any.new
       result.pack(expected_response)
       operation = Google::Longrunning::Operation.new(
@@ -1735,7 +1646,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_big_nothing, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.get_big_nothing(formatted_name)
@@ -1747,11 +1658,11 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes get_big_nothing and returns an operation error.' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Create expected grpc response
       operation_error = Google::Rpc::Status.new(
-        message: 'Operation error for LibraryServiceClient#get_big_nothing.'
+        message: 'Operation error for Library::V1::LibraryServiceClient#get_big_nothing.'
       )
       operation = Google::Longrunning::Operation.new(
         name: 'operations/get_big_nothing_test',
@@ -1767,7 +1678,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_big_nothing, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.get_big_nothing(formatted_name)
@@ -1780,7 +1691,7 @@ describe Library::V1::LibraryServiceClient do
 
     it 'invokes get_big_nothing with error' do
       # Create request parameters
-      formatted_name = LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
+      formatted_name = Library::V1::LibraryServiceClient.book_path("[SHELF_ID]", "[BOOK_ID]")
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1790,7 +1701,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:get_big_nothing, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
@@ -1804,12 +1715,7 @@ describe Library::V1::LibraryServiceClient do
   end
 
   describe 'test_optional_required_flattening_params' do
-    custom_error = CustomTestError.new "Custom test error for LibraryServiceClient#test_optional_required_flattening_params."
-
-    InnerEnum = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerEnum
-    InnerMessage = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerMessage
-    LibraryServiceClient = Library::V1::LibraryServiceClient
-    TestOptionalRequiredFlatteningParamsResponse = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsResponse
+    custom_error = CustomTestError.new "Custom test error for Library::V1::LibraryServiceClient#test_optional_required_flattening_params."
 
     it 'invokes test_optional_required_flattening_params without error' do
       # Create request parameters
@@ -1818,10 +1724,10 @@ describe Library::V1::LibraryServiceClient do
       required_singular_float = 0.0
       required_singular_double = 0.0
       required_singular_bool = false
-      required_singular_enum = InnerEnum::ZERO
+      required_singular_enum = :ZERO
       required_singular_string = ''
       required_singular_bytes = ''
-      required_singular_message = InnerMessage.new
+      required_singular_message = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerMessage.new
       required_singular_resource_name = ''
       required_singular_resource_name_oneof = ''
       required_singular_fixed32 = 0
@@ -1842,7 +1748,7 @@ describe Library::V1::LibraryServiceClient do
       required_map = {}
 
       # Create expected grpc response
-      expected_response = TestOptionalRequiredFlatteningParamsResponse.new
+      expected_response = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsResponse.new
 
       # Mock Grpc layer
       mock_method = proc do |request|
@@ -1851,7 +1757,7 @@ describe Library::V1::LibraryServiceClient do
         assert_equal(required_singular_float, request.required_singular_float)
         assert_equal(required_singular_double, request.required_singular_double)
         assert_equal(required_singular_bool, request.required_singular_bool)
-        assert_equal(InnerEnum.lookup(required_singular_enum), request.required_singular_enum)
+        assert_equal(required_singular_enum, request.required_singular_enum)
         assert_equal(required_singular_string, request.required_singular_string)
         assert_equal(required_singular_bytes, request.required_singular_bytes)
         assert_equal(required_singular_message, request.required_singular_message)
@@ -1878,7 +1784,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:test_optional_required_flattening_params, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         response = client.test_optional_required_flattening_params(
@@ -1923,10 +1829,10 @@ describe Library::V1::LibraryServiceClient do
       required_singular_float = 0.0
       required_singular_double = 0.0
       required_singular_bool = false
-      required_singular_enum = InnerEnum::ZERO
+      required_singular_enum = :ZERO
       required_singular_string = ''
       required_singular_bytes = ''
-      required_singular_message = InnerMessage.new
+      required_singular_message = Google::Example::Library::V1::TestOptionalRequiredFlatteningParamsRequest::InnerMessage.new
       required_singular_resource_name = ''
       required_singular_resource_name_oneof = ''
       required_singular_fixed32 = 0
@@ -1953,7 +1859,7 @@ describe Library::V1::LibraryServiceClient do
         assert_equal(required_singular_float, request.required_singular_float)
         assert_equal(required_singular_double, request.required_singular_double)
         assert_equal(required_singular_bool, request.required_singular_bool)
-        assert_equal(InnerEnum.lookup(required_singular_enum), request.required_singular_enum)
+        assert_equal(required_singular_enum, request.required_singular_enum)
         assert_equal(required_singular_string, request.required_singular_string)
         assert_equal(required_singular_bytes, request.required_singular_bytes)
         assert_equal(required_singular_message, request.required_singular_message)
@@ -1980,7 +1886,7 @@ describe Library::V1::LibraryServiceClient do
       mock_stub = MockGrpcClientStub.new(:test_optional_required_flattening_params, mock_method)
 
       Google::Example::Library::V1::LibraryService::Stub.stub(:new, mock_stub) do
-        client = LibraryServiceClient.new
+        client = Library::V1::LibraryServiceClient.new
 
         # Call method
         err = assert_raises Google::Gax::GaxError do
diff --git a/src/test/java/com/google/api/codegen/testdata/ruby_yardopts_library.baseline b/src/test/java/com/google/api/codegen/testdata/ruby_yardopts_library.baseline
new file mode 100644
index 0000000000..e355f5ca70
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/testdata/ruby_yardopts_library.baseline
@@ -0,0 +1,9 @@
+============== file: .yardopts ==============
+--no-private
+--title=Google Example Library API
+--exclude lib/library/v1
+--markup markdown
+
+./lib/**/*.rb
+-
+README.md
diff --git a/src/test/java/com/google/api/codegen/transformer/ruby/RubyModelTypeNameConverterTest.java b/src/test/java/com/google/api/codegen/transformer/ruby/RubyModelTypeNameConverterTest.java
index 449678f6a1..56a2788778 100644
--- a/src/test/java/com/google/api/codegen/transformer/ruby/RubyModelTypeNameConverterTest.java
+++ b/src/test/java/com/google/api/codegen/transformer/ruby/RubyModelTypeNameConverterTest.java
@@ -38,6 +38,6 @@ public void testGetEnumValue() {
             converter
                 .getEnumValue(type, value)
                 .getValueAndSaveTypeNicknameIn(new RubyTypeTable(packageName)))
-        .isEqualTo("Rating::GOOD");
+        .isEqualTo(":GOOD");
   }
 }
diff --git a/src/test/java/com/google/api/codegen/util/py/PythonTypeTableTest.java b/src/test/java/com/google/api/codegen/util/py/PythonTypeTableTest.java
new file mode 100644
index 0000000000..cb922a0009
--- /dev/null
+++ b/src/test/java/com/google/api/codegen/util/py/PythonTypeTableTest.java
@@ -0,0 +1,59 @@
+/* Copyright 2017 Google Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.api.codegen.util.py;
+
+import com.google.api.codegen.util.TypeAlias;
+import com.google.common.truth.Truth;
+import java.util.Map;
+import org.junit.Test;
+
+public class PythonTypeTableTest {
+
+  @Test
+  public void testDisambiguate_movePackage() {
+    PythonTypeTable typeTable = new PythonTypeTable("foo.bar");
+    Truth.assertThat(typeTable.getAndSaveNicknameFor(TypeAlias.create("a.c.D", "c.D")))
+        .isEqualTo("c.D");
+    Truth.assertThat(typeTable.getAndSaveNicknameFor(TypeAlias.create("b.c.E", "c.E")))
+        .isEqualTo("b_c.E");
+    Map imports = typeTable.getImports();
+    Truth.assertThat(imports.get("a.c.D").getNickname()).isEqualTo("a_c.D");
+    Truth.assertThat(imports.get("b.c.E").getNickname()).isEqualTo("b_c.E");
+  }
+
+  @Test
+  public void testDisambiguate_move2Packages() {
+    PythonTypeTable typeTable = new PythonTypeTable("foo.bar");
+    Truth.assertThat(typeTable.getAndSaveNicknameFor(TypeAlias.create("a.c.d.E", "c_d.E")))
+        .isEqualTo("c_d.E");
+    Truth.assertThat(typeTable.getAndSaveNicknameFor(TypeAlias.create("b.c.d.F", "c_d.F")))
+        .isEqualTo("b_c_d.F");
+    Map imports = typeTable.getImports();
+    Truth.assertThat(imports.get("a.c.d.E").getNickname()).isEqualTo("a_c_d.E");
+    Truth.assertThat(imports.get("b.c.d.F").getNickname()).isEqualTo("b_c_d.F");
+  }
+
+  @Test
+  public void testDisambiguate_move3Packages() {
+    PythonTypeTable typeTable = new PythonTypeTable("foo.bar");
+    Truth.assertThat(typeTable.getAndSaveNicknameFor(TypeAlias.create("a.c.d.e.F", "c_d_e.F")))
+        .isEqualTo("c_d_e.F");
+    Truth.assertThat(typeTable.getAndSaveNicknameFor(TypeAlias.create("b.c.d.e.G", "c_d_e.G")))
+        .isEqualTo("b_c_d_e.G");
+    Map imports = typeTable.getImports();
+    Truth.assertThat(imports.get("a.c.d.e.F").getNickname()).isEqualTo("a_c_d_e.F");
+    Truth.assertThat(imports.get("b.c.d.e.G").getNickname()).isEqualTo("b_c_d_e.G");
+  }
+}