diff --git a/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel index f90d35bd99..503561e307 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel +++ b/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel @@ -15,9 +15,11 @@ java_library( deps = [ "//:service_config_java_proto", "//src/main/java/com/google/api/generator/engine/ast", + "//src/main/java/com/google/api/generator/engine/writer", "//src/main/java/com/google/api/generator/gapic:status_java_proto", "//src/main/java/com/google/api/generator/gapic/model", "//src/main/java/com/google/api/generator/gapic/utils", + "//src/main/java/com/google/api/generator/gapic/composer/samplecode", "@com_google_api_api_common//jar", "@com_google_api_gax_java//gax", "@com_google_api_gax_java//gax-grpc:gax_grpc", diff --git a/src/main/java/com/google/api/generator/gapic/composer/ClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ClassComposer.java index 131020c562..7f8b5e860d 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ClassComposer.java @@ -16,9 +16,11 @@ import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.Message; +import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.model.Service; import java.util.Map; public interface ClassComposer { - GapicClass generate(Service service, Map messageTypes); + GapicClass generate( + Service service, Map resourceNames, Map messageTypes); } diff --git a/src/main/java/com/google/api/generator/gapic/composer/Composer.java b/src/main/java/com/google/api/generator/gapic/composer/Composer.java index 02e1dc9bcc..b4281f483c 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/Composer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/Composer.java @@ -60,8 +60,8 @@ public static List generateServiceClasses( @Nonnull Map resourceNames, @Nonnull Map messageTypes) { List clazzes = new ArrayList<>(); - clazzes.addAll(generateStubClasses(service, serviceConfig, messageTypes)); - clazzes.addAll(generateClientSettingsClasses(service, messageTypes)); + clazzes.addAll(generateStubClasses(service, serviceConfig, messageTypes, resourceNames)); + clazzes.addAll(generateClientSettingsClasses(service, messageTypes, resourceNames)); clazzes.addAll(generateMocksAndTestClasses(service, resourceNames, messageTypes)); // TODO(miraleung): Generate test classes. return clazzes; @@ -76,29 +76,38 @@ public static List generateResourceNameHelperClasses( } public static List generateStubClasses( - Service service, GapicServiceConfig serviceConfig, Map messageTypes) { + Service service, + GapicServiceConfig serviceConfig, + Map messageTypes, + Map resourceNames) { List clazzes = new ArrayList<>(); - clazzes.add(ServiceStubClassComposer.instance().generate(service, messageTypes)); + clazzes.add(ServiceStubClassComposer.instance().generate(service, resourceNames, messageTypes)); clazzes.add( ServiceStubSettingsClassComposer.instance().generate(service, serviceConfig, messageTypes)); - clazzes.add(GrpcServiceCallableFactoryClassComposer.instance().generate(service, messageTypes)); - clazzes.add(GrpcServiceStubClassComposer.instance().generate(service, messageTypes)); + clazzes.add( + GrpcServiceCallableFactoryClassComposer.instance() + .generate(service, resourceNames, messageTypes)); + clazzes.add( + GrpcServiceStubClassComposer.instance().generate(service, resourceNames, messageTypes)); return clazzes; } public static List generateClientSettingsClasses( - Service service, Map messageTypes) { + Service service, Map messageTypes, Map resourceNames) { List clazzes = new ArrayList<>(); - clazzes.add(ServiceClientClassComposer.instance().generate(service, messageTypes)); - clazzes.add(ServiceSettingsClassComposer.instance().generate(service, messageTypes)); + clazzes.add( + ServiceClientClassComposer.instance().generate(service, resourceNames, messageTypes)); + clazzes.add( + ServiceSettingsClassComposer.instance().generate(service, resourceNames, messageTypes)); return clazzes; } public static List generateMocksAndTestClasses( Service service, Map resourceNames, Map messageTypes) { List clazzes = new ArrayList<>(); - clazzes.add(MockServiceClassComposer.instance().generate(service, messageTypes)); - clazzes.add(MockServiceImplClassComposer.instance().generate(service, messageTypes)); + clazzes.add(MockServiceClassComposer.instance().generate(service, resourceNames, messageTypes)); + clazzes.add( + MockServiceImplClassComposer.instance().generate(service, resourceNames, messageTypes)); clazzes.add( ServiceClientTestClassComposer.instance().generate(service, resourceNames, messageTypes)); return clazzes; diff --git a/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposer.java index 5d1f054e2f..1bcfdc8b6a 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposer.java @@ -42,6 +42,7 @@ import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.Message; +import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.model.Service; import com.google.common.base.Preconditions; import com.google.longrunning.Operation; @@ -64,7 +65,8 @@ public static GrpcServiceCallableFactoryClassComposer instance() { } @Override - public GapicClass generate(Service service, Map ignore) { + public GapicClass generate( + Service service, Map resourceNames, Map ignore) { Map types = createTypes(service); String className = String.format("Grpc%sCallableFactory", service.name()); GapicClass.Kind kind = Kind.STUB; diff --git a/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposer.java index 2fe59e9a7d..c952e9fc0b 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposer.java @@ -51,6 +51,7 @@ import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.Message; import com.google.api.generator.gapic.model.Method; +import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.model.Service; import com.google.api.generator.gapic.utils.JavaStyle; import com.google.common.base.Preconditions; @@ -112,7 +113,8 @@ public static GrpcServiceStubClassComposer instance() { } @Override - public GapicClass generate(Service service, Map ignore) { + public GapicClass generate( + Service service, Map resourceNames, Map ignore) { String pakkage = service.pakkage() + ".stub"; Map types = createDynamicTypes(service, pakkage); String className = getThisClassName(service.name()); diff --git a/src/main/java/com/google/api/generator/gapic/composer/MockServiceClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/MockServiceClassComposer.java index 5e1a5057f5..8677431d00 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/MockServiceClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/MockServiceClassComposer.java @@ -33,6 +33,7 @@ import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.Message; +import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.model.Service; import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; @@ -55,7 +56,8 @@ public static MockServiceClassComposer instance() { } @Override - public GapicClass generate(Service service, Map ignore) { + public GapicClass generate( + Service service, Map resourceNames, Map ignore) { Map types = createTypes(service); String className = String.format(MOCK_SERVICE_NAME_PATTERN, service.name()); GapicClass.Kind kind = Kind.TEST; diff --git a/src/main/java/com/google/api/generator/gapic/composer/MockServiceImplClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/MockServiceImplClassComposer.java index 000e133a1a..6240f9db43 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/MockServiceImplClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/MockServiceImplClassComposer.java @@ -42,6 +42,7 @@ import com.google.api.generator.gapic.model.Message; import com.google.api.generator.gapic.model.Method; import com.google.api.generator.gapic.model.Method.Stream; +import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.model.Service; import com.google.api.generator.gapic.utils.JavaStyle; import com.google.longrunning.Operation; @@ -94,7 +95,8 @@ public static MockServiceImplClassComposer instance() { } @Override - public GapicClass generate(Service service, Map ignore) { + public GapicClass generate( + Service service, Map resourceNames, Map ignore) { Map types = createDynamicTypes(service); String className = String.format(MOCK_SERVICE_IMPL_NAME_PATTERN, service.name()); GapicClass.Kind kind = Kind.TEST; diff --git a/src/main/java/com/google/api/generator/gapic/composer/SampleCodeHelperComposer.java b/src/main/java/com/google/api/generator/gapic/composer/SampleCodeHelperComposer.java new file mode 100644 index 0000000000..95305eecee --- /dev/null +++ b/src/main/java/com/google/api/generator/gapic/composer/SampleCodeHelperComposer.java @@ -0,0 +1,384 @@ +// Copyright 2020 Google LLC +// +// 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.generator.gapic.composer; + +import com.google.api.generator.engine.ast.AssignmentExpr; +import com.google.api.generator.engine.ast.CommentStatement; +import com.google.api.generator.engine.ast.Expr; +import com.google.api.generator.engine.ast.ExprStatement; +import com.google.api.generator.engine.ast.ForStatement; +import com.google.api.generator.engine.ast.LineComment; +import com.google.api.generator.engine.ast.MethodInvocationExpr; +import com.google.api.generator.engine.ast.Statement; +import com.google.api.generator.engine.ast.TryCatchStatement; +import com.google.api.generator.engine.ast.TypeNode; +import com.google.api.generator.engine.ast.Variable; +import com.google.api.generator.engine.ast.VariableExpr; +import com.google.api.generator.gapic.model.Method; +import com.google.api.generator.gapic.model.MethodArgument; +import com.google.api.generator.gapic.model.ResourceName; +import com.google.api.generator.gapic.utils.JavaStyle; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public final class SampleCodeHelperComposer { + private static String RESPONSE_VAR_NAME = "response"; + private static String REQUEST_VAR_NAME = "request"; + private static String ASYNC_NAME_PATTERN = "%sAsync"; + + public static TryCatchStatement composeRpcMethodSampleCode( + Method method, + List arguments, + TypeNode clientType, + Map resourceNames) { + // Default Unary RPC method. + if (arguments.isEmpty()) { + return composeUnaryRpcDefaultMethodSampleCode(method, clientType, resourceNames); + } + // Paged Unary RPC method. + if (method.isPaged()) { + return composePagedUnaryRpcMethodSampleCode(method, arguments, clientType, resourceNames); + } + // Long run operation Unary RPC method. + if (method.hasLro()) { + return composeLroUnaryRpcMethodSampleCode(method, arguments, clientType, resourceNames); + } + // Pure Unary RPC method. + return composeUnaryRpcMethodSampleCode(method, arguments, clientType, resourceNames); + } + + private static TryCatchStatement composeUnaryRpcMethodSampleCode( + Method method, + List arguments, + TypeNode clientType, + Map resourceNames) { + // TODO(summerji): Add unit tests. + // Assign each method arguments with default value. + List bodyStatements = + arguments.stream() + .map( + methodArg -> + ExprStatement.withExpr( + assignMethodArgumentWithDefaultValue(methodArg, resourceNames))) + .collect(Collectors.toList()); + // Invoke current method based on return type. + // e.g. if return void, echoClient.echo(..); or, + // e.g. if return other type, EchoResponse response = echoClient.echo(...); + if (method.outputType().equals(TypeNode.VOID)) { + bodyStatements.add( + ExprStatement.withExpr( + MethodInvocationExpr.builder() + .setExprReferenceExpr( + createVariableDeclExpr(getClientName(clientType), clientType)) + .setMethodName(method.name()) + .setReturnType(clientType) + .build())); + } else { + bodyStatements.add( + ExprStatement.withExpr( + createAssignExprForVariableWithClientMethod( + RESPONSE_VAR_NAME, method.outputType(), clientType, method.name(), arguments))); + } + + return TryCatchStatement.builder() + .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) + .setTryBody(bodyStatements) + .setIsSampleCode(true) + .build(); + } + + private static TryCatchStatement composeLroUnaryRpcMethodSampleCode( + Method method, + List arguments, + TypeNode clientType, + Map resourceNames) { + // TODO(summerji): compose sample code for unary lro rpc method. + // TODO(summerji): Add unit tests. + // Assign each method arguments with default value. + List bodyStatements = + arguments.stream() + .map( + methodArg -> + ExprStatement.withExpr( + assignMethodArgumentWithDefaultValue(methodArg, resourceNames))) + .collect(Collectors.toList()); + // Assign response variable with get method. + // e.g EchoResponse response = echoClient.waitAsync().get(); + Expr getResponseMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr( + MethodInvocationExpr.builder() + .setExprReferenceExpr(createVariableExpr(getClientName(clientType), clientType)) + .setMethodName(getLroMethodName(method.name())) + .setArguments(mapMethodArgumentsToVariableExprs(arguments)) + .build()) + .setMethodName("get") + .setReturnType(method.outputType()) + .build(); + bodyStatements.add( + ExprStatement.withExpr( + AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(RESPONSE_VAR_NAME, method.outputType())) + .setValueExpr(getResponseMethodExpr) + .build())); + return TryCatchStatement.builder() + .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) + .setTryBody(bodyStatements) + .setIsSampleCode(true) + .build(); + } + + private static TryCatchStatement composePagedUnaryRpcMethodSampleCode( + Method method, + List arguments, + TypeNode clientType, + Map resourceNames) { + // TODO(summerji): Add unit test. + // Assign each method arguments with default value. + List bodyStatements = + arguments.stream() + .map( + methodArg -> + ExprStatement.withExpr( + assignMethodArgumentWithDefaultValue(methodArg, resourceNames))) + .collect(Collectors.toList()); + // For loop client on iterateAll method. + // e.g. for (LoggingServiceV2Client loggingServiceV2Client : + // loggingServiceV2Client.ListLogs(parent).iterateAll()) { + // //doThingsWith(element);} + bodyStatements.add( + ForStatement.builder() + .setLocalVariableExpr(createVariableDeclExpr(getClientName(clientType), clientType)) + .setCollectionExpr(createIteratorAllMethodExpr(method, clientType, arguments)) + .setBody(Arrays.asList(createLineCommentStatement("doThingsWith(element);"))) + .build()); + return TryCatchStatement.builder() + .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) + .setTryBody(bodyStatements) + .setIsSampleCode(true) + .build(); + } + + private static TryCatchStatement composeUnaryRpcDefaultMethodSampleCode( + Method method, TypeNode clientType, Map resourceNames) { + // TODO(summerji): compose sample code for unary default rpc method. + // TODO(summerji): Add unit tests. + // If variant method signatures exists, use the first one. + List arguments = + !method.methodSignatures().isEmpty() + ? method.methodSignatures().get(0) + : Collections.emptyList(); + // Assign each method arguments with default value. + List bodyStatements = + arguments.stream() + .map( + methodArg -> + ExprStatement.withExpr( + assignMethodArgumentWithDefaultValue(methodArg, resourceNames))) + .collect(Collectors.toList()); + // Assign request variables with set argument attributes. + // e.g EchoRequest + bodyStatements.add( + ExprStatement.withExpr(createRequestBuilderExpr(method.inputType(), arguments))); + + if (method.isPaged()) { + // For loop on invoke client method's iterator with comment. + // e.g. for (EchoClient echoClient : echoClient.PagedExpand(request).iterateAll()) {//..} + bodyStatements.add( + ForStatement.builder() + .setLocalVariableExpr(createVariableDeclExpr(getClientName(clientType), clientType)) + .setCollectionExpr(createIteratorAllMethodExpr(method, clientType, arguments)) + .setBody(Arrays.asList(createLineCommentStatement("doThingsWith(element);"))) + .build()); + } else if (method.hasLro()) { + // Create response variable by invoke client's async method. + // e.g Operation response = EchoClient.waitAsync(request).get(); + Expr getResponseMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr( + MethodInvocationExpr.builder() + .setStaticReferenceType(clientType) + .setMethodName(getLroMethodName(method.name())) + .setArguments( + Arrays.asList(createVariableExpr(REQUEST_VAR_NAME, method.inputType()))) + .build()) + .setMethodName("get") + .setReturnType(method.outputType()) + .build(); + bodyStatements.add( + ExprStatement.withExpr( + AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(RESPONSE_VAR_NAME, method.outputType())) + .setValueExpr(getResponseMethodExpr) + .build())); + } else { + // Create response variable by invoke client's method by passing request. + // e.g. EchoResponse response = echoClient.Echo(request); + Expr invokeMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(createVariableExpr(getClientName(clientType), clientType)) + .setMethodName(method.name()) + .setArguments(createVariableExpr("request", method.inputType())) + .setReturnType(method.outputType()) + .build(); + bodyStatements.add( + ExprStatement.withExpr( + AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(RESPONSE_VAR_NAME, method.outputType())) + .setValueExpr(invokeMethodExpr) + .build())); + } + + return TryCatchStatement.builder() + .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) + .setTryBody(bodyStatements) + .setIsSampleCode(true) + .build(); + } + + // ==================================Helpers===================================================// + + // Assign client variable expr with create client. + // e.g EchoClient echoClient = EchoClient.create() + private static AssignmentExpr assignClientVariableWithCreateMethodExpr(TypeNode clientType) { + return AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(getClientName(clientType), clientType)) + .setValueExpr( + MethodInvocationExpr.builder() + .setStaticReferenceType(clientType) + .setReturnType(clientType) + .setMethodName("create") + .build()) + .build(); + } + + // Create request variable by set attributes. + // e.g. EchoRequest request = EchoRequest.newBuilder().setParent(parent).build(); + private static Expr createRequestBuilderExpr( + TypeNode requestType, List arguments) { + MethodInvocationExpr newBuilderExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(requestType) + .setMethodName("newBuilder") + .build(); + for (MethodArgument arg : arguments) { + newBuilderExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(newBuilderExpr) + .setMethodName(String.format("set%s", JavaStyle.toUpperCamelCase(arg.name()))) + .setArguments( + VariableExpr.withVariable( + Variable.builder().setName(arg.name()).setType(arg.type()).build())) + .build(); + } + MethodInvocationExpr requestBuildExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(newBuilderExpr) + .setMethodName("build") + .setReturnType(requestType) + .build(); + return AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr("request", requestType)) + .setValueExpr(requestBuildExpr) + .build(); + } + + private static Expr assignMethodArgumentWithDefaultValue( + MethodArgument argument, Map resourceNames) { + return AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(argument.name(), argument.type())) + .setValueExpr(DefaultValueComposer.createDefaultValue(argument, resourceNames)) + .build(); + } + + private static Expr createAssignExprForVariableWithClientMethod( + String variableName, + TypeNode variableType, + TypeNode clientType, + String methodName, + List arguments) { + VariableExpr varExpr = createVariableExpr(variableName, variableType); + MethodInvocationExpr clientMethodInvocationExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(createVariableExpr(getClientName(clientType), clientType)) + .setMethodName(methodName) + .setArguments(mapMethodArgumentsToVariableExprs(arguments)) + .setReturnType(variableType) + .build(); + return AssignmentExpr.builder() + .setVariableExpr(varExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(clientMethodInvocationExpr) + .build(); + } + + private static List mapMethodArgumentsToVariableExprs(List arguments) { + return arguments.stream() + .map(arg -> createVariableExpr(arg.name(), arg.type())) + .collect(Collectors.toList()); + } + + private static Expr createIteratorAllMethodExpr( + Method method, TypeNode clientType, List arguments) { + // e.g echoClient.echo(name).iterateAll() + return MethodInvocationExpr.builder() + .setExprReferenceExpr( + MethodInvocationExpr.builder() + .setExprReferenceExpr(createVariableExpr(getClientName(clientType), clientType)) + .setMethodName(method.name()) + .setArguments( + !arguments.isEmpty() + ? mapMethodArgumentsToVariableExprs(arguments) + : Arrays.asList(createVariableExpr("request", method.inputType()))) + .build()) + .setMethodName("iterateAll") + .setReturnType(clientType) + .build(); + } + + private static String getClientName(TypeNode clientType) { + return JavaStyle.toLowerCamelCase(clientType.reference().name()); + } + + private static String getLroMethodName(String methodName) { + return JavaStyle.toLowerCamelCase(String.format(ASYNC_NAME_PATTERN, methodName)); + } + + private static CommentStatement createLineCommentStatement(String content) { + return CommentStatement.withComment(LineComment.withComment(content)); + } + + private static VariableExpr createVariableExpr(String variableName, TypeNode type) { + return createVariableExpr(variableName, type, false); + } + + private static VariableExpr createVariableDeclExpr(String variableName, TypeNode type) { + return createVariableExpr(variableName, type, true); + } + + private static VariableExpr createVariableExpr( + String variableName, TypeNode type, boolean isDecl) { + return VariableExpr.builder() + .setVariable(createVariable(variableName, type)) + .setIsDecl(isDecl) + .build(); + } + + private static Variable createVariable(String varName, TypeNode type) { + return Variable.builder().setName(varName).setType(type).build(); + } +} diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java index 02ff960025..7b3a425580 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java @@ -62,6 +62,7 @@ import com.google.api.generator.gapic.model.Method; import com.google.api.generator.gapic.model.Method.Stream; import com.google.api.generator.gapic.model.MethodArgument; +import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.model.Service; import com.google.api.generator.gapic.utils.JavaStyle; import com.google.common.annotations.VisibleForTesting; @@ -109,7 +110,8 @@ public static ServiceClientClassComposer instance() { } @Override - public GapicClass generate(Service service, Map messageTypes) { + public GapicClass generate( + Service service, Map resourceNames, Map messageTypes) { Map types = createTypes(service, messageTypes); String className = String.format("%sClient", service.name()); GapicClass.Kind kind = Kind.MAIN; @@ -119,14 +121,18 @@ public GapicClass generate(Service service, Map messageTypes) { ClassDefinition classDef = ClassDefinition.builder() .setHeaderCommentStatements( - ServiceClientCommentComposer.createClassHeaderComments(service)) + ServiceClientCommentComposer.createClassHeaderComments( + service, + types.get(getClientClassName(service.name())), + types.get(getSettingsName(service.name())))) .setPackageString(pakkage) .setAnnotations(createClassAnnotations(types)) .setScope(ScopeNode.PUBLIC) .setName(className) .setImplementsTypes(createClassImplements(types)) .setStatements(createFieldDeclarations(service, types, hasLroClient)) - .setMethods(createClassMethods(service, messageTypes, types, hasLroClient)) + .setMethods( + createClassMethods(service, messageTypes, types, resourceNames, hasLroClient)) .setNestedClasses(createNestedPagingClasses(service, messageTypes, types)) .build(); return GapicClass.create(kind, classDef); @@ -149,12 +155,19 @@ private static List createClassMethods( Service service, Map messageTypes, Map types, + Map resourceNames, boolean hasLroClient) { List methods = new ArrayList<>(); methods.addAll(createStaticCreatorMethods(service, types)); methods.addAll(createConstructorMethods(service, types, hasLroClient)); methods.addAll(createGetterMethods(service, types, hasLroClient)); - methods.addAll(createServiceMethods(service, messageTypes, types)); + methods.addAll( + createServiceMethods( + service, + messageTypes, + types, + types.get(getClientClassName(service.name())), + resourceNames)); methods.addAll(createBackgroundResourceMethods(service, types)); return methods; } @@ -466,12 +479,17 @@ private static List createGetterMethods( } private static List createServiceMethods( - Service service, Map messageTypes, Map types) { + Service service, + Map messageTypes, + Map types, + TypeNode clientType, + Map resourceNames) { List javaMethods = new ArrayList<>(); for (Method method : service.methods()) { if (method.stream().equals(Stream.NONE)) { - javaMethods.addAll(createMethodVariants(method, messageTypes, types)); - javaMethods.add(createMethodDefaultMethod(method, types)); + javaMethods.addAll( + createMethodVariants(method, messageTypes, types, clientType, resourceNames)); + javaMethods.add(createMethodDefaultMethod(method, types, clientType, resourceNames)); } if (method.hasLro()) { javaMethods.add(createLroCallableMethod(service.name(), method, types)); @@ -485,7 +503,11 @@ private static List createServiceMethods( } private static List createMethodVariants( - Method method, Map messageTypes, Map types) { + Method method, + Map messageTypes, + Map types, + TypeNode clientType, + Map resourceNames) { List javaMethods = new ArrayList<>(); String methodName = JavaStyle.toLowerCamelCase(method.name()); TypeNode methodInputType = method.inputType(); @@ -549,7 +571,8 @@ private static List createMethodVariants( javaMethods.add( MethodDefinition.builder() .setHeaderCommentStatements( - ServiceClientCommentComposer.createRpcMethodHeaderComment(method, signature)) + ServiceClientCommentComposer.createRpcMethodHeaderComment( + method, signature, clientType, resourceNames)) .setScope(ScopeNode.PUBLIC) .setIsFinal(true) .setReturnType(methodOutputType) @@ -564,7 +587,10 @@ private static List createMethodVariants( } private static MethodDefinition createMethodDefaultMethod( - Method method, Map types) { + Method method, + Map types, + TypeNode clientType, + Map resourceNames) { String methodName = JavaStyle.toLowerCamelCase(method.name()); TypeNode methodInputType = method.inputType(); TypeNode methodOutputType = @@ -608,7 +634,8 @@ private static MethodDefinition createMethodDefaultMethod( .build(); return MethodDefinition.builder() .setHeaderCommentStatements( - ServiceClientCommentComposer.createRpcMethodHeaderComment(method)) + ServiceClientCommentComposer.createRpcMethodHeaderComment( + method, clientType, resourceNames)) .setScope(ScopeNode.PUBLIC) .setIsFinal(true) .setReturnType(methodOutputType) @@ -1505,6 +1532,10 @@ private static String getClientClassName(String serviceName) { return String.format("%sClient", serviceName); } + private static String getSettingsName(String serviceName) { + return String.format("%sSettings", serviceName); + } + private static List getGenericsForCallable( CallableMethodKind kind, Method method, Map types) { if (kind.equals(CallableMethodKind.LRO)) { diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index dfe76dffa2..8f3101a5a3 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -19,16 +19,22 @@ import com.google.api.generator.engine.ast.TypeNode; import com.google.api.generator.gapic.model.Method; import com.google.api.generator.gapic.model.MethodArgument; +import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.model.Service; import com.google.api.generator.gapic.utils.JavaStyle; import com.google.common.base.Strings; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; class ServiceClientCommentComposer { + // Name Pattern. + private static final String SETTINGS_NAME_PATTERN = "%sSettings"; + private static final String CLASS_NAME_PATTERN = "%sClient"; + // Tokens. private static final String COLON = ":"; private static final String EMPTY_STRING = ""; @@ -103,7 +109,10 @@ class ServiceClientCommentComposer { "Returns the OperationsClient that can be used to query the status of a long-running" + " operation returned by another API method call."); - static List createClassHeaderComments(Service service) { + static List createClassHeaderComments( + Service service, TypeNode clientType, TypeNode settingsType) { + String settingsName = JavaStyle.toLowerCamelCase(getSettingsName(service.name())); + String clientName = JavaStyle.toLowerCamelCase(getClientClassName(service.name())); JavaDocComment.Builder classHeaderJavadocBuilder = JavaDocComment.builder(); if (service.hasDescription()) { classHeaderJavadocBuilder = @@ -134,9 +143,13 @@ static List createClassHeaderComments(Service service) { SERVICE_DESCRIPTION_CUSTOMIZE_SUMMARY_PATTERN, String.format("%sSettings", JavaStyle.toUpperCamelCase(service.name())))); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_CREDENTIALS_SUMMARY_STRING); - // TODO(summerji): Add credentials' customization sample code here. + classHeaderJavadocBuilder.addSampleCode( + ServiceClientSampleCodeComposer.composeClassHeaderCredentialsSampleCode( + clientType, settingsType)); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_ENDPOINT_SUMMARY_STRING); - // TODO(summerji): Add endpoint customization sample code here. + classHeaderJavadocBuilder.addSampleCode( + ServiceClientSampleCodeComposer.composeClassHeaderEndpointSampleCode( + clientType, settingsType)); return Arrays.asList( CommentComposer.AUTO_GENERATED_CLASS_COMMENT, @@ -151,7 +164,10 @@ static CommentStatement createCreateMethodStubArgComment( } static List createRpcMethodHeaderComment( - Method method, List methodArguments) { + Method method, + List methodArguments, + TypeNode clientType, + Map resourceNames) { JavaDocComment.Builder methodJavadocBuilder = JavaDocComment.builder(); if (method.hasDescription()) { @@ -160,7 +176,9 @@ static List createRpcMethodHeaderComment( } methodJavadocBuilder.addParagraph(METHOD_DESCRIPTION_SAMPLE_CODE_SUMMARY_STRING); - // TODO(summerji): Add sample code here. + methodJavadocBuilder.addSampleCode( + ServiceClientSampleCodeComposer.composeRpcMethodHeaderSampleCode( + method, methodArguments, clientType, resourceNames)); if (methodArguments.isEmpty()) { methodJavadocBuilder.addParam( @@ -181,8 +199,9 @@ static List createRpcMethodHeaderComment( CommentStatement.withComment(methodJavadocBuilder.build())); } - static List createRpcMethodHeaderComment(Method method) { - return createRpcMethodHeaderComment(method, Collections.emptyList()); + static List createRpcMethodHeaderComment( + Method method, TypeNode clientType, Map resourceNames) { + return createRpcMethodHeaderComment(method, Collections.emptyList(), clientType, resourceNames); } static CommentStatement createMethodNoArgComment(String serviceName) { @@ -254,4 +273,12 @@ private static JavaDocComment.Builder processProtobufComment( return commentBuilder; } + + private static String getSettingsName(String serviceName) { + return String.format(SETTINGS_NAME_PATTERN, serviceName); + } + + private static String getClientClassName(String serviceName) { + return String.format(CLASS_NAME_PATTERN, serviceName); + } } diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java new file mode 100644 index 0000000000..2bcd681235 --- /dev/null +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -0,0 +1,179 @@ +// Copyright 2020 Google LLC +// +// 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.generator.gapic.composer; + +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.api.generator.engine.ast.AssignmentExpr; +import com.google.api.generator.engine.ast.ConcreteReference; +import com.google.api.generator.engine.ast.Expr; +import com.google.api.generator.engine.ast.ExprStatement; +import com.google.api.generator.engine.ast.MethodInvocationExpr; +import com.google.api.generator.engine.ast.Statement; +import com.google.api.generator.engine.ast.StringObjectValue; +import com.google.api.generator.engine.ast.TypeNode; +import com.google.api.generator.engine.ast.ValueExpr; +import com.google.api.generator.engine.ast.Variable; +import com.google.api.generator.engine.ast.VariableExpr; +import com.google.api.generator.engine.writer.JavaWriterVisitor; +import com.google.api.generator.gapic.composer.samplecode.SampleCodeJavaFormatter; +import com.google.api.generator.gapic.composer.samplecode.SampleCodeWriter; +import com.google.api.generator.gapic.model.Method; +import com.google.api.generator.gapic.model.MethodArgument; +import com.google.api.generator.gapic.model.ResourceName; +import com.google.api.generator.gapic.utils.JavaStyle; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class ServiceClientSampleCodeComposer { + // TODO(summerji): Add unit tests for ServiceClientSampleCodeComposer. + // TODO(summerji): Refactor signatures as sample code context. + + public static String composeClassHeaderCredentialsSampleCode( + TypeNode clientType, TypeNode settingsType) { + // Initialize clientSettings with builder() method. + // e.g. EchoSettings echoSettings = + // EchoSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create("myCredentials")).build(); + String settingsName = JavaStyle.toLowerCamelCase(settingsType.reference().name()); + String clientName = JavaStyle.toLowerCamelCase(clientType.reference().name()); + VariableExpr settingsVarExpr = createVariableExpr(settingsName, settingsType); + MethodInvocationExpr newBuilderMethodExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(settingsType) + .setMethodName("newBuilder") + .build(); + TypeNode fixedCredentialProvideType = + TypeNode.withReference(ConcreteReference.withClazz(FixedCredentialsProvider.class)); + MethodInvocationExpr credentialArgExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(fixedCredentialProvideType) + .setArguments(ValueExpr.withValue(StringObjectValue.withValue("myCredentials"))) + .setMethodName("create") + .build(); + MethodInvocationExpr credentialsMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(newBuilderMethodExpr) + .setArguments(credentialArgExpr) + .setMethodName("setCredentialsProvider") + .build(); + MethodInvocationExpr buildMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(credentialsMethodExpr) + .setReturnType(settingsType) + .setMethodName("build") + .build(); + Expr initSettingsVarExpr = + AssignmentExpr.builder() + .setVariableExpr(settingsVarExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(buildMethodExpr) + .build(); + + // Initialized client with create() method. + // e.g. EchoClient echoClient = EchoClient.create(echoSettings); + VariableExpr clientVarExpr = createVariableExpr(clientName, clientType); + MethodInvocationExpr createMethodExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(clientType) + .setArguments(settingsVarExpr) + .setMethodName("create") + .setReturnType(clientType) + .build(); + Expr initClientVarExpr = + AssignmentExpr.builder() + .setVariableExpr(clientVarExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(createMethodExpr) + .build(); + + return writeSampleCode(Arrays.asList(initSettingsVarExpr, initClientVarExpr)); + } + + public static String composeClassHeaderEndpointSampleCode( + TypeNode clientType, TypeNode settingsType) { + // Initialize client settings with builder() method. + // e.g. EchoSettings echoSettings = EchoSettings.newBuilder().setEndpoint("myEndpoint").build(); + String settingsName = JavaStyle.toLowerCamelCase(settingsType.reference().name()); + String clientName = JavaStyle.toLowerCamelCase(clientType.reference().name()); + VariableExpr settingsVarExpr = createVariableExpr(settingsName, settingsType); + MethodInvocationExpr newBuilderMethodExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(settingsType) + .setMethodName("newBuilder") + .build(); + MethodInvocationExpr credentialsMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(newBuilderMethodExpr) + .setArguments(ValueExpr.withValue(StringObjectValue.withValue("myEndpoint"))) + .setMethodName("setEndpoint") + .build(); + MethodInvocationExpr buildMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(credentialsMethodExpr) + .setReturnType(settingsType) + .setMethodName("build") + .build(); + + Expr initSettingsVarExpr = + AssignmentExpr.builder() + .setVariableExpr(settingsVarExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(buildMethodExpr) + .build(); + + // Initialize client with create() method. + // e.g. EchoClient echoClient = EchoClient.create(echoSettings); + VariableExpr clientVarExpr = createVariableExpr(clientName, clientType); + MethodInvocationExpr createMethodExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(clientType) + .setArguments(settingsVarExpr) + .setMethodName("create") + .setReturnType(clientType) + .build(); + Expr initClientVarExpr = + AssignmentExpr.builder() + .setVariableExpr(clientVarExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(createMethodExpr) + .build(); + + return writeSampleCode(Arrays.asList(initSettingsVarExpr, initClientVarExpr)); + } + + public static String composeRpcMethodHeaderSampleCode( + Method method, + List arguments, + TypeNode clientType, + Map resourceNames) { + return SampleCodeWriter.write( + SampleCodeHelperComposer.composeRpcMethodSampleCode( + method, arguments, clientType, resourceNames)); + } + + // ======================================== Helpers ==========================================// + // TODO(summerji): Use writeSampleCode method in new class once PR#499 merged. + private static String writeSampleCode(List exprs) { + List statements = + exprs.stream().map(e -> ExprStatement.withExpr(e)).collect(Collectors.toList()); + JavaWriterVisitor visitor = new JavaWriterVisitor(); + for (Statement statement : statements) { + statement.accept(visitor); + } + return SampleCodeJavaFormatter.format(visitor.write()); + } + + private static VariableExpr createVariableExpr(String variableName, TypeNode type) { + return VariableExpr.withVariable( + Variable.builder().setName(variableName).setType(type).build()); + } +} diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposer.java index 45f625f32f..2c8e9b8db7 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposer.java @@ -54,6 +54,7 @@ import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.Message; import com.google.api.generator.gapic.model.Method; +import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.model.Service; import com.google.api.generator.gapic.utils.JavaStyle; import com.google.common.base.Preconditions; @@ -92,7 +93,8 @@ public static ServiceSettingsClassComposer instance() { } @Override - public GapicClass generate(Service service, Map ignore) { + public GapicClass generate( + Service service, Map resourceNames, Map ignore) { String pakkage = service.pakkage(); Map types = createDynamicTypes(service); String className = getThisClassName(service.name()); diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubClassComposer.java index ce1f79727e..4aa3b1e53f 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubClassComposer.java @@ -35,6 +35,7 @@ import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.Message; import com.google.api.generator.gapic.model.Method; +import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.model.Service; import com.google.api.generator.gapic.utils.JavaStyle; import com.google.longrunning.Operation; @@ -57,7 +58,8 @@ public static ServiceStubClassComposer instance() { } @Override - public GapicClass generate(Service service, Map messageTypes) { + public GapicClass generate( + Service service, Map resourceNames, Map messageTypes) { Map types = createTypes(service, messageTypes); String className = String.format("%sStub", service.name()); GapicClass.Kind kind = Kind.STUB; diff --git a/src/test/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposerTest.java b/src/test/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposerTest.java index bc1f8d0c09..c1187dd0f8 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposerTest.java +++ b/src/test/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposerTest.java @@ -59,7 +59,8 @@ public void generateServiceClasses() { Service echoProtoService = services.get(0); GapicClass clazz = - GrpcServiceCallableFactoryClassComposer.instance().generate(echoProtoService, messageTypes); + GrpcServiceCallableFactoryClassComposer.instance() + .generate(echoProtoService, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); diff --git a/src/test/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposerTest.java b/src/test/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposerTest.java index 47c7767d45..03527dd8f8 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposerTest.java +++ b/src/test/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposerTest.java @@ -55,7 +55,8 @@ public void generateGrpcServiceStubClass_simple() { echoFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames); Service echoProtoService = services.get(0); GapicClass clazz = - GrpcServiceStubClassComposer.instance().generate(echoProtoService, messageTypes); + GrpcServiceStubClassComposer.instance() + .generate(echoProtoService, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); @@ -82,7 +83,8 @@ public void generateGrpcServiceStubClass_httpBindings() { outputResourceNames); Service testingProtoService = services.get(0); GapicClass clazz = - GrpcServiceStubClassComposer.instance().generate(testingProtoService, messageTypes); + GrpcServiceStubClassComposer.instance() + .generate(testingProtoService, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); @@ -115,7 +117,8 @@ public void generateGrpcServiceStubClass_httpBindingsWithSubMessageFields() { outputResourceNames); Service service = services.get(0); - GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(service, messageTypes); + GapicClass clazz = + GrpcServiceStubClassComposer.instance().generate(service, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); diff --git a/src/test/java/com/google/api/generator/gapic/composer/MockServiceClassComposerTest.java b/src/test/java/com/google/api/generator/gapic/composer/MockServiceClassComposerTest.java index 61785acb7b..e8dfb79704 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/MockServiceClassComposerTest.java +++ b/src/test/java/com/google/api/generator/gapic/composer/MockServiceClassComposerTest.java @@ -58,7 +58,8 @@ public void generateServiceClasses() { echoFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames); Service echoProtoService = services.get(0); - GapicClass clazz = MockServiceClassComposer.instance().generate(echoProtoService, messageTypes); + GapicClass clazz = + MockServiceClassComposer.instance().generate(echoProtoService, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); diff --git a/src/test/java/com/google/api/generator/gapic/composer/MockServiceImplClassComposerTest.java b/src/test/java/com/google/api/generator/gapic/composer/MockServiceImplClassComposerTest.java index 624126bb96..a5bdd6fd3b 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/MockServiceImplClassComposerTest.java +++ b/src/test/java/com/google/api/generator/gapic/composer/MockServiceImplClassComposerTest.java @@ -59,7 +59,8 @@ public void generateServiceClasses() { Service echoProtoService = services.get(0); GapicClass clazz = - MockServiceImplClassComposer.instance().generate(echoProtoService, messageTypes); + MockServiceImplClassComposer.instance() + .generate(echoProtoService, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); diff --git a/src/test/java/com/google/api/generator/gapic/composer/ServiceClientClassComposerTest.java b/src/test/java/com/google/api/generator/gapic/composer/ServiceClientClassComposerTest.java index 1a882a6a30..79b9ee7043 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/ServiceClientClassComposerTest.java +++ b/src/test/java/com/google/api/generator/gapic/composer/ServiceClientClassComposerTest.java @@ -53,7 +53,8 @@ public void generateServiceClasses() { Service echoProtoService = services.get(0); GapicClass clazz = - ServiceClientClassComposer.instance().generate(echoProtoService, messageTypes); + ServiceClientClassComposer.instance() + .generate(echoProtoService, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); @@ -76,7 +77,8 @@ public void generateServiceClasses_methodSignatureHasNestedFields() { fileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames); Service protoService = services.get(0); - GapicClass clazz = ServiceClientClassComposer.instance().generate(protoService, messageTypes); + GapicClass clazz = + ServiceClientClassComposer.instance().generate(protoService, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); diff --git a/src/test/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposerTest.java b/src/test/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposerTest.java index bd7b41eb16..5f32693747 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposerTest.java +++ b/src/test/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposerTest.java @@ -59,7 +59,8 @@ public void generateServiceClasses() { Service echoProtoService = services.get(0); GapicClass clazz = - ServiceSettingsClassComposer.instance().generate(echoProtoService, messageTypes); + ServiceSettingsClassComposer.instance() + .generate(echoProtoService, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); diff --git a/src/test/java/com/google/api/generator/gapic/composer/ServiceStubClassComposerTest.java b/src/test/java/com/google/api/generator/gapic/composer/ServiceStubClassComposerTest.java index 2e7a390b0b..62ac11c04e 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/ServiceStubClassComposerTest.java +++ b/src/test/java/com/google/api/generator/gapic/composer/ServiceStubClassComposerTest.java @@ -58,7 +58,8 @@ public void generateServiceClasses() { echoFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames); Service echoProtoService = services.get(0); - GapicClass clazz = ServiceStubClassComposer.instance().generate(echoProtoService, messageTypes); + GapicClass clazz = + ServiceStubClassComposer.instance().generate(echoProtoService, resourceNames, messageTypes); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden index 20a193853e..077c35e156 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden @@ -63,7 +63,20 @@ import javax.annotation.Generated; * *

To customize credentials: * + *

{@code
+ * EchoSettings echoSettings =
+ *     EchoSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * EchoClient echoClient = EchoClient.create(echoSettings);
+ * }
+ * *

To customize the endpoint: + * + *

{@code
+ * EchoSettings echoSettings = EchoSettings.newBuilder().setEndpoint("myEndpoint").build();
+ * EchoClient echoClient = EchoClient.create(echoSettings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") @@ -132,6 +145,13 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   ResourceName parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]");
+   *   EchoResponse response = echoClient.Echo(parent);
+   * }
+   * }
+ * * @param parent * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -147,6 +167,13 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   Status error = Status.newBuilder().build();
+   *   EchoResponse response = echoClient.Echo(error);
+   * }
+   * }
+ * * @param error * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -159,6 +186,13 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   FoobarName name = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]");
+   *   EchoResponse response = echoClient.Echo(name);
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -172,6 +206,13 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   String content = "content951530617";
+   *   EchoResponse response = echoClient.Echo(content);
+   * }
+   * }
+ * * @param content * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -184,6 +225,13 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   String name = "name3373707";
+   *   EchoResponse response = echoClient.Echo(name);
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -196,6 +244,13 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   String parent = "parent-995424086";
+   *   EchoResponse response = echoClient.Echo(parent);
+   * }
+   * }
+ * * @param parent * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -208,6 +263,14 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   String content = "content951530617";
+   *   Severity severity = Severity.forNumber(0);
+   *   EchoResponse response = echoClient.Echo(content, severity);
+   * }
+   * }
+ * * @param content * @param severity * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -222,6 +285,14 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   ResourceName parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]");
+   *   EchoRequest request = EchoRequest.newBuilder().setParent(parent).build();
+   *   EchoResponse response = echoClient.Echo(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -263,6 +334,15 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   PagedExpandRequest request = PagedExpandRequest.newBuilder().build();
+   *   for (EchoClient echoClient : echoClient.PagedExpand(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -287,6 +367,13 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   Duration ttl = Duration.newBuilder().build();
+   *   Operation response = echoClient.waitAsync(ttl).get();
+   * }
+   * }
+ * * @param ttl * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -299,6 +386,13 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   Timestamp end_time = Timestamp.newBuilder().build();
+   *   Operation response = echoClient.waitAsync(end_time).get();
+   * }
+   * }
+ * * @param end_time * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -311,6 +405,14 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   Duration ttl = Duration.newBuilder().build();
+   *   WaitRequest request = WaitRequest.newBuilder().setTtl(ttl).build();
+   *   Operation response = EchoClient.waitAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -334,6 +436,13 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   BlockRequest request = BlockRequest.newBuilder().build();
+   *   BlockResponse response = echoClient.Block(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden index 0f48757f2b..9cea5ba67a 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden @@ -53,7 +53,21 @@ import javax.annotation.Generated; * *

To customize credentials: * + *

{@code
+ * IdentitySettings identitySettings =
+ *     IdentitySettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * IdentityClient identityClient = IdentityClient.create(identitySettings);
+ * }
+ * *

To customize the endpoint: + * + *

{@code
+ * IdentitySettings identitySettings =
+ *     IdentitySettings.newBuilder().setEndpoint("myEndpoint").build();
+ * IdentityClient identityClient = IdentityClient.create(identitySettings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") @@ -111,6 +125,15 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   String parent = "parent-995424086";
+   *   String display_name = "display_name1615086568";
+   *   String email = "email96619420";
+   *   User response = identityClient.CreateUser(parent, display_name, email);
+   * }
+   * }
+ * * @param parent * @param display_name * @param email @@ -130,6 +153,21 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   String parent = "parent-995424086";
+   *   String display_name = "display_name1615086568";
+   *   String email = "email96619420";
+   *   int age = 96511;
+   *   String nickname = "nickname70690926";
+   *   boolean enable_notifications = true;
+   *   double height_feet = -1032737338;
+   *   User response =
+   *       identityClient.CreateUser(
+   *           parent, display_name, email, age, nickname, enable_notifications, height_feet);
+   * }
+   * }
+ * * @param parent * @param display_name * @param email @@ -164,6 +202,21 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   String parent = "parent-995424086";
+   *   String display_name = "display_name1615086568";
+   *   String email = "email96619420";
+   *   CreateUserRequest request =
+   *       CreateUserRequest.newBuilder()
+   *           .setParent(parent)
+   *           .setDisplayName(display_name)
+   *           .setEmail(email)
+   *           .build();
+   *   User response = identityClient.CreateUser(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -181,6 +234,13 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   UserName name = UserName.of("[USER]");
+   *   User response = identityClient.GetUser(name);
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -194,6 +254,13 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   String name = "name3373707";
+   *   User response = identityClient.GetUser(name);
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -206,6 +273,14 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   UserName name = UserName.of("[USER]");
+   *   GetUserRequest request = GetUserRequest.newBuilder().setName(name).build();
+   *   User response = identityClient.GetUser(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -223,6 +298,13 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   UpdateUserRequest request = UpdateUserRequest.newBuilder().build();
+   *   User response = identityClient.UpdateUser(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -240,6 +322,13 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   UserName name = UserName.of("[USER]");
+   *   Empty response = identityClient.DeleteUser(name);
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -255,6 +344,13 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   String name = "name3373707";
+   *   Empty response = identityClient.DeleteUser(name);
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -267,6 +363,14 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   UserName name = UserName.of("[USER]");
+   *   DeleteUserRequest request = DeleteUserRequest.newBuilder().setName(name).build();
+   *   Empty response = identityClient.DeleteUser(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -284,6 +388,15 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   ListUsersRequest request = ListUsersRequest.newBuilder().build();
+   *   for (IdentityClient identityClient : identityClient.ListUsers(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index 103843b065..cfa2f86cfc 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -75,7 +75,21 @@ * *

To customize credentials: * + *

{@code
+ * AssetServiceSettings assetServiceSettings =
+ *     AssetServiceSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * AssetServiceClient assetServiceClient = AssetServiceClient.create(assetServiceSettings);
+ * }
+ * *

To customize the endpoint: + * + *

{@code
+ * AssetServiceSettings assetServiceSettings =
+ *     AssetServiceSettings.newBuilder().setEndpoint("myEndpoint").build();
+ * AssetServiceClient assetServiceClient = AssetServiceClient.create(assetServiceSettings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") @@ -154,6 +168,13 @@ public final OperationsClient getOperationsClient() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   ExportAssetsRequest request = ExportAssetsRequest.newBuilder().build();
+   *   Operation response = AssetServiceClient.exportAssetsAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -207,6 +228,13 @@ public final UnaryCallable exportAssetsCallable( * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder().build();
+   *   BatchGetAssetsHistoryResponse response = assetServiceClient.BatchGetAssetsHistory(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -236,6 +264,13 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory( * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String parent = "parent-995424086";
+   *   Feed response = assetServiceClient.CreateFeed(parent);
+   * }
+   * }
+ * * @param parent Required. The name of the project/folder/organization where this feed should be * created in. It can only be an organization number (such as "organizations/123"), a folder * number (such as "folders/123"), a project ID (such as "projects/my-project-id")", or a @@ -253,6 +288,14 @@ public final Feed createFeed(String parent) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String parent = "parent-995424086";
+   *   CreateFeedRequest request = CreateFeedRequest.newBuilder().setParent(parent).build();
+   *   Feed response = assetServiceClient.CreateFeed(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -276,6 +319,13 @@ public final UnaryCallable createFeedCallable() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   Feed response = assetServiceClient.GetFeed(name);
+   * }
+   * }
+ * * @param name Required. The name of the Feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -293,6 +343,13 @@ public final Feed getFeed(FeedName name) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String name = "name3373707";
+   *   Feed response = assetServiceClient.GetFeed(name);
+   * }
+   * }
+ * * @param name Required. The name of the Feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -309,6 +366,14 @@ public final Feed getFeed(String name) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   GetFeedRequest request = GetFeedRequest.newBuilder().setName(name).build();
+   *   Feed response = assetServiceClient.GetFeed(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -332,6 +397,13 @@ public final UnaryCallable getFeedCallable() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String parent = "parent-995424086";
+   *   ListFeedsResponse response = assetServiceClient.ListFeeds(parent);
+   * }
+   * }
+ * * @param parent Required. The parent project/folder/organization whose feeds are to be listed. It * can only be using project/folder/organization number (such as "folders/12345")", or a * project ID (such as "projects/my-project-id"). @@ -348,6 +420,14 @@ public final ListFeedsResponse listFeeds(String parent) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String parent = "parent-995424086";
+   *   ListFeedsRequest request = ListFeedsRequest.newBuilder().setParent(parent).build();
+   *   ListFeedsResponse response = assetServiceClient.ListFeeds(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -371,6 +451,13 @@ public final UnaryCallable listFeedsCallabl * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   Feed feed = Feed.newBuilder().build();
+   *   Feed response = assetServiceClient.UpdateFeed(feed);
+   * }
+   * }
+ * * @param feed Required. The new values of feed details. It must match an existing feed and the * field `name` must be in the format of: projects/project_number/feeds/feed_id or * folders/folder_number/feeds/feed_id or organizations/organization_number/feeds/feed_id. @@ -387,6 +474,14 @@ public final Feed updateFeed(Feed feed) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   Feed feed = Feed.newBuilder().build();
+   *   UpdateFeedRequest request = UpdateFeedRequest.newBuilder().setFeed(feed).build();
+   *   Feed response = assetServiceClient.UpdateFeed(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -410,6 +505,13 @@ public final UnaryCallable updateFeedCallable() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   Empty response = assetServiceClient.DeleteFeed(name);
+   * }
+   * }
+ * * @param name Required. The name of the feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -429,6 +531,13 @@ public final Empty deleteFeed(FeedName name) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String name = "name3373707";
+   *   Empty response = assetServiceClient.DeleteFeed(name);
+   * }
+   * }
+ * * @param name Required. The name of the feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -445,6 +554,14 @@ public final Empty deleteFeed(String name) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   DeleteFeedRequest request = DeleteFeedRequest.newBuilder().setName(name).build();
+   *   Empty response = assetServiceClient.DeleteFeed(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -470,6 +587,18 @@ public final UnaryCallable deleteFeedCallable() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   List asset_types = new ArrayList<>();
+   *   for (AssetServiceClient assetServiceClient :
+   *       assetServiceClient.SearchAllResources(scope, query, asset_types).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param scope Required. A scope can be a project, a folder, or an organization. The search is * limited to the resources within the `scope`. The caller must be granted the * [`cloudasset.assets.searchAllResources`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) @@ -538,6 +667,24 @@ public final SearchAllResourcesPagedResponse searchAllResources( * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   List asset_types = new ArrayList<>();
+   *   SearchAllResourcesRequest request =
+   *       SearchAllResourcesRequest.newBuilder()
+   *           .setScope(scope)
+   *           .setQuery(query)
+   *           .setAssetTypes(asset_types)
+   *           .build();
+   *   for (AssetServiceClient assetServiceClient :
+   *       assetServiceClient.SearchAllResources(scope, query, asset_types).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -580,6 +727,17 @@ public final SearchAllResourcesPagedResponse searchAllResources( * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   for (AssetServiceClient assetServiceClient :
+   *       assetServiceClient.SearchAllIamPolicies(scope, query).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param scope Required. A scope can be a project, a folder, or an organization. The search is * limited to the IAM policies within the `scope`. The caller must be granted the * [`cloudasset.assets.searchAllIamPolicies`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) @@ -632,6 +790,19 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   SearchAllIamPoliciesRequest request =
+   *       SearchAllIamPoliciesRequest.newBuilder().setScope(scope).setQuery(query).build();
+   *   for (AssetServiceClient assetServiceClient :
+   *       assetServiceClient.SearchAllIamPolicies(scope, query).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ diff --git a/test/integration/goldens/logging/ConfigServiceV2Client.java b/test/integration/goldens/logging/ConfigServiceV2Client.java index b6516172fc..2042747d89 100644 --- a/test/integration/goldens/logging/ConfigServiceV2Client.java +++ b/test/integration/goldens/logging/ConfigServiceV2Client.java @@ -73,7 +73,23 @@ * *

To customize credentials: * + *

{@code
+ * ConfigServiceV2Settings configServiceV2Settings =
+ *     ConfigServiceV2Settings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * ConfigServiceV2Client configServiceV2Client =
+ *     ConfigServiceV2Client.create(configServiceV2Settings);
+ * }
+ * *

To customize the endpoint: + * + *

{@code
+ * ConfigServiceV2Settings configServiceV2Settings =
+ *     ConfigServiceV2Settings.newBuilder().setEndpoint("myEndpoint").build();
+ * ConfigServiceV2Client configServiceV2Client =
+ *     ConfigServiceV2Client.create(configServiceV2Settings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") @@ -135,6 +151,17 @@ public ConfigServiceV2Stub getStub() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountLocationName parent =
+   *       BillingAccountLocationName.of("[BILLING_ACCOUNT]", "[LOCATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -158,6 +185,16 @@ public final ListBucketsPagedResponse listBuckets(BillingAccountLocationName par * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   FolderLocationName parent = FolderLocationName.of("[FOLDER]", "[LOCATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -181,6 +218,16 @@ public final ListBucketsPagedResponse listBuckets(FolderLocationName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -204,6 +251,16 @@ public final ListBucketsPagedResponse listBuckets(LocationName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -227,6 +284,16 @@ public final ListBucketsPagedResponse listBuckets(OrganizationLocationName paren * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String parent = "parent-995424086";
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -247,6 +314,18 @@ public final ListBucketsPagedResponse listBuckets(String parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountLocationName parent =
+   *       BillingAccountLocationName.of("[BILLING_ACCOUNT]", "[LOCATION]");
+   *   ListBucketsRequest request = ListBucketsRequest.newBuilder().setParent(parent).build();
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -281,6 +360,13 @@ public final UnaryCallable listBucketsC * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   GetBucketRequest request = GetBucketRequest.newBuilder().build();
+   *   LogBucket response = configServiceV2Client.GetBucket(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -313,6 +399,13 @@ public final UnaryCallable getBucketCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   UpdateBucketRequest request = UpdateBucketRequest.newBuilder().build();
+   *   LogBucket response = configServiceV2Client.UpdateBucket(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -345,6 +438,16 @@ public final UnaryCallable updateBucketCallable( * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -364,6 +467,16 @@ public final ListSinksPagedResponse listSinks(BillingAccountName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -383,6 +496,16 @@ public final ListSinksPagedResponse listSinks(FolderName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -402,6 +525,16 @@ public final ListSinksPagedResponse listSinks(OrganizationName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -421,6 +554,16 @@ public final ListSinksPagedResponse listSinks(ProjectName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String parent = "parent-995424086";
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -437,6 +580,17 @@ public final ListSinksPagedResponse listSinks(String parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   ListSinksRequest request = ListSinksRequest.newBuilder().setParent(parent).build();
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -470,6 +624,13 @@ public final UnaryCallable listSinksCallabl * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   LogSink response = configServiceV2Client.GetSink(sink_name);
+   * }
+   * }
+ * * @param sink_name Required. The resource name of the sink: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -492,6 +653,13 @@ public final LogSink getSink(LogSinkName sinkName) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String sink_name = "sink_name-1391757129";
+   *   LogSink response = configServiceV2Client.GetSink(sink_name);
+   * }
+   * }
+ * * @param sink_name Required. The resource name of the sink: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -511,6 +679,14 @@ public final LogSink getSink(String sinkName) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(sink_name).build();
+   *   LogSink response = configServiceV2Client.GetSink(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -537,6 +713,14 @@ public final UnaryCallable getSinkCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   LogSink response = configServiceV2Client.CreateSink(parent, sink);
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -563,6 +747,14 @@ public final LogSink createSink(BillingAccountName parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   LogSink response = configServiceV2Client.CreateSink(parent, sink);
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -589,6 +781,14 @@ public final LogSink createSink(FolderName parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   LogSink response = configServiceV2Client.CreateSink(parent, sink);
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -615,6 +815,14 @@ public final LogSink createSink(OrganizationName parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   LogSink response = configServiceV2Client.CreateSink(parent, sink);
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -641,6 +849,14 @@ public final LogSink createSink(ProjectName parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String parent = "parent-995424086";
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   LogSink response = configServiceV2Client.CreateSink(parent, sink);
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -664,6 +880,16 @@ public final LogSink createSink(String parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   CreateSinkRequest request =
+   *       CreateSinkRequest.newBuilder().setParent(parent).setSink(sink).build();
+   *   LogSink response = configServiceV2Client.CreateSink(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -694,6 +920,14 @@ public final UnaryCallable createSinkCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   LogSink response = configServiceV2Client.UpdateSink(sink_name, sink);
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -724,6 +958,14 @@ public final LogSink updateSink(LogSinkName sinkName, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String sink_name = "sink_name-1391757129";
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   LogSink response = configServiceV2Client.UpdateSink(sink_name, sink);
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -751,6 +993,15 @@ public final LogSink updateSink(String sinkName, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   LogSink response = configServiceV2Client.UpdateSink(sink_name, sink, update_mask);
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -791,6 +1042,15 @@ public final LogSink updateSink(LogSinkName sinkName, LogSink sink, FieldMask up * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String sink_name = "sink_name-1391757129";
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   LogSink response = configServiceV2Client.UpdateSink(sink_name, sink, update_mask);
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -831,6 +1091,16 @@ public final LogSink updateSink(String sinkName, LogSink sink, FieldMask updateM * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   UpdateSinkRequest request =
+   *       UpdateSinkRequest.newBuilder().setSinkName(sink_name).setSink(sink).build();
+   *   LogSink response = configServiceV2Client.UpdateSink(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -859,6 +1129,13 @@ public final UnaryCallable updateSinkCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   Empty response = configServiceV2Client.DeleteSink(sink_name);
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to delete, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -883,6 +1160,13 @@ public final Empty deleteSink(LogSinkName sinkName) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String sink_name = "sink_name-1391757129";
+   *   Empty response = configServiceV2Client.DeleteSink(sink_name);
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to delete, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -904,6 +1188,14 @@ public final Empty deleteSink(String sinkName) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   DeleteSinkRequest request = DeleteSinkRequest.newBuilder().setSinkName(sink_name).build();
+   *   Empty response = configServiceV2Client.DeleteSink(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -928,6 +1220,16 @@ public final UnaryCallable deleteSinkCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -947,6 +1249,16 @@ public final ListExclusionsPagedResponse listExclusions(BillingAccountName paren * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -966,6 +1278,16 @@ public final ListExclusionsPagedResponse listExclusions(FolderName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -985,6 +1307,16 @@ public final ListExclusionsPagedResponse listExclusions(OrganizationName parent) * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1004,6 +1336,16 @@ public final ListExclusionsPagedResponse listExclusions(ProjectName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String parent = "parent-995424086";
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1020,6 +1362,17 @@ public final ListExclusionsPagedResponse listExclusions(String parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   ListExclusionsRequest request = ListExclusionsRequest.newBuilder().setParent(parent).build();
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1055,6 +1408,13 @@ public final ListExclusionsPagedResponse listExclusions(ListExclusionsRequest re * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   LogExclusion response = configServiceV2Client.GetExclusion(name);
+   * }
+   * }
+ * * @param name Required. The resource name of an existing exclusion: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1077,6 +1437,13 @@ public final LogExclusion getExclusion(LogExclusionName name) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String name = "name3373707";
+   *   LogExclusion response = configServiceV2Client.GetExclusion(name);
+   * }
+   * }
+ * * @param name Required. The resource name of an existing exclusion: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1096,6 +1463,14 @@ public final LogExclusion getExclusion(String name) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   GetExclusionRequest request = GetExclusionRequest.newBuilder().setName(name).build();
+   *   LogExclusion response = configServiceV2Client.GetExclusion(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1120,6 +1495,14 @@ public final UnaryCallable getExclusionCallab * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   LogExclusion response = configServiceV2Client.CreateExclusion(parent, exclusion);
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1144,6 +1527,14 @@ public final LogExclusion createExclusion(BillingAccountName parent, LogExclusio * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   LogExclusion response = configServiceV2Client.CreateExclusion(parent, exclusion);
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1168,6 +1559,14 @@ public final LogExclusion createExclusion(FolderName parent, LogExclusion exclus * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   LogExclusion response = configServiceV2Client.CreateExclusion(parent, exclusion);
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1192,6 +1591,14 @@ public final LogExclusion createExclusion(OrganizationName parent, LogExclusion * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   LogExclusion response = configServiceV2Client.CreateExclusion(parent, exclusion);
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1216,6 +1623,14 @@ public final LogExclusion createExclusion(ProjectName parent, LogExclusion exclu * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String parent = "parent-995424086";
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   LogExclusion response = configServiceV2Client.CreateExclusion(parent, exclusion);
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1237,6 +1652,16 @@ public final LogExclusion createExclusion(String parent, LogExclusion exclusion) * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   CreateExclusionRequest request =
+   *       CreateExclusionRequest.newBuilder().setParent(parent).setExclusion(exclusion).build();
+   *   LogExclusion response = configServiceV2Client.CreateExclusion(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1261,6 +1686,15 @@ public final UnaryCallable createExclusion * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   LogExclusion response = configServiceV2Client.UpdateExclusion(name, exclusion, update_mask);
+   * }
+   * }
+ * * @param name Required. The resource name of the exclusion to update: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1294,6 +1728,15 @@ public final LogExclusion updateExclusion( * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String name = "name3373707";
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   LogExclusion response = configServiceV2Client.UpdateExclusion(name, exclusion, update_mask);
+   * }
+   * }
+ * * @param name Required. The resource name of the exclusion to update: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1327,6 +1770,21 @@ public final LogExclusion updateExclusion( * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   UpdateExclusionRequest request =
+   *       UpdateExclusionRequest.newBuilder()
+   *           .setName(name)
+   *           .setExclusion(exclusion)
+   *           .setUpdateMask(update_mask)
+   *           .build();
+   *   LogExclusion response = configServiceV2Client.UpdateExclusion(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1350,6 +1808,13 @@ public final UnaryCallable updateExclusion * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   Empty response = configServiceV2Client.DeleteExclusion(name);
+   * }
+   * }
+ * * @param name Required. The resource name of an existing exclusion to delete: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1372,6 +1837,13 @@ public final Empty deleteExclusion(LogExclusionName name) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   String name = "name3373707";
+   *   Empty response = configServiceV2Client.DeleteExclusion(name);
+   * }
+   * }
+ * * @param name Required. The resource name of an existing exclusion to delete: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1391,6 +1863,14 @@ public final Empty deleteExclusion(String name) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   DeleteExclusionRequest request = DeleteExclusionRequest.newBuilder().setName(name).build();
+   *   Empty response = configServiceV2Client.DeleteExclusion(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1420,6 +1900,13 @@ public final UnaryCallable deleteExclusionCallabl * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   GetCmekSettingsRequest request = GetCmekSettingsRequest.newBuilder().build();
+   *   CmekSettings response = configServiceV2Client.GetCmekSettings(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1460,6 +1947,13 @@ public final UnaryCallable getCmekSettings * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   UpdateCmekSettingsRequest request = UpdateCmekSettingsRequest.newBuilder().build();
+   *   CmekSettings response = configServiceV2Client.UpdateCmekSettings(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ diff --git a/test/integration/goldens/logging/LoggingServiceV2Client.java b/test/integration/goldens/logging/LoggingServiceV2Client.java index d90cbfadf6..efd1503cec 100644 --- a/test/integration/goldens/logging/LoggingServiceV2Client.java +++ b/test/integration/goldens/logging/LoggingServiceV2Client.java @@ -75,7 +75,23 @@ * *

To customize credentials: * + *

{@code
+ * LoggingServiceV2Settings loggingServiceV2Settings =
+ *     LoggingServiceV2Settings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * LoggingServiceV2Client loggingServiceV2Client =
+ *     LoggingServiceV2Client.create(loggingServiceV2Settings);
+ * }
+ * *

To customize the endpoint: + * + *

{@code
+ * LoggingServiceV2Settings loggingServiceV2Settings =
+ *     LoggingServiceV2Settings.newBuilder().setEndpoint("myEndpoint").build();
+ * LoggingServiceV2Client loggingServiceV2Client =
+ *     LoggingServiceV2Client.create(loggingServiceV2Settings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") @@ -139,6 +155,13 @@ public LoggingServiceV2Stub getStub() { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   LogName log_name = LogName.ofProjectLogName("[PROJECT]", "[LOG]");
+   *   Empty response = loggingServiceV2Client.DeleteLog(log_name);
+   * }
+   * }
+ * * @param log_name Required. The resource name of the log to delete: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" @@ -163,6 +186,13 @@ public final Empty deleteLog(LogName logName) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   String log_name = "log_name2013526694";
+   *   Empty response = loggingServiceV2Client.DeleteLog(log_name);
+   * }
+   * }
+ * * @param log_name Required. The resource name of the log to delete: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" @@ -184,6 +214,14 @@ public final Empty deleteLog(String logName) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   LogName log_name = LogName.ofProjectLogName("[PROJECT]", "[LOG]");
+   *   DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(log_name).build();
+   *   Empty response = loggingServiceV2Client.DeleteLog(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -212,6 +250,17 @@ public final UnaryCallable deleteLogCallable() { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   LogName log_name = LogName.ofProjectLogName("[PROJECT]", "[LOG]");
+   *   MonitoredResource resource = MonitoredResource.newBuilder().build();
+   *   Map labels = new HashMap<>();
+   *   List entries = new ArrayList<>();
+   *   WriteLogEntriesResponse response =
+   *       loggingServiceV2Client.WriteLogEntries(log_name, resource, labels, entries);
+   * }
+   * }
+ * * @param log_name Optional. A default log resource name that is assigned to all log entries in * `entries` that do not specify a value for `log_name`: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" @@ -276,6 +325,17 @@ public final WriteLogEntriesResponse writeLogEntries( * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   String log_name = "log_name2013526694";
+   *   MonitoredResource resource = MonitoredResource.newBuilder().build();
+   *   Map labels = new HashMap<>();
+   *   List entries = new ArrayList<>();
+   *   WriteLogEntriesResponse response =
+   *       loggingServiceV2Client.WriteLogEntries(log_name, resource, labels, entries);
+   * }
+   * }
+ * * @param log_name Optional. A default log resource name that is assigned to all log entries in * `entries` that do not specify a value for `log_name`: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" @@ -340,6 +400,23 @@ public final WriteLogEntriesResponse writeLogEntries( * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   LogName log_name = LogName.ofProjectLogName("[PROJECT]", "[LOG]");
+   *   MonitoredResource resource = MonitoredResource.newBuilder().build();
+   *   Map labels = new HashMap<>();
+   *   List entries = new ArrayList<>();
+   *   WriteLogEntriesRequest request =
+   *       WriteLogEntriesRequest.newBuilder()
+   *           .setLogName(log_name)
+   *           .setResource(resource)
+   *           .setLabels(labels)
+   *           .setEntries(entries)
+   *           .build();
+   *   WriteLogEntriesResponse response = loggingServiceV2Client.WriteLogEntries(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -369,6 +446,18 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   List resource_names = new ArrayList<>();
+   *   String filter = "filter-1274492040";
+   *   String order_by = "order_by1234304744";
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogEntries(resource_names, filter, order_by).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param resource_names Required. Names of one or more parent resources from which to retrieve * log entries: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" @@ -406,6 +495,24 @@ public final ListLogEntriesPagedResponse listLogEntries( * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   List resource_names = new ArrayList<>();
+   *   String filter = "filter-1274492040";
+   *   String order_by = "order_by1234304744";
+   *   ListLogEntriesRequest request =
+   *       ListLogEntriesRequest.newBuilder()
+   *           .setResourceNames(resource_names)
+   *           .setFilter(filter)
+   *           .setOrderBy(order_by)
+   *           .build();
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogEntries(resource_names, filter, order_by).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -445,6 +552,17 @@ public final ListLogEntriesPagedResponse listLogEntries(ListLogEntriesRequest re * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   ListMonitoredResourceDescriptorsRequest request =
+   *       ListMonitoredResourceDescriptorsRequest.newBuilder().build();
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListMonitoredResourceDescriptors(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -484,6 +602,16 @@ public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResource * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -504,6 +632,16 @@ public final ListLogsPagedResponse listLogs(BillingAccountName parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -524,6 +662,16 @@ public final ListLogsPagedResponse listLogs(FolderName parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -544,6 +692,16 @@ public final ListLogsPagedResponse listLogs(OrganizationName parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -564,6 +722,16 @@ public final ListLogsPagedResponse listLogs(ProjectName parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   String parent = "parent-995424086";
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -581,6 +749,17 @@ public final ListLogsPagedResponse listLogs(String parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   ListLogsRequest request = ListLogsRequest.newBuilder().setParent(parent).build();
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ diff --git a/test/integration/goldens/logging/MetricsServiceV2Client.java b/test/integration/goldens/logging/MetricsServiceV2Client.java index 19f6aef98d..bf3fac6f53 100644 --- a/test/integration/goldens/logging/MetricsServiceV2Client.java +++ b/test/integration/goldens/logging/MetricsServiceV2Client.java @@ -72,7 +72,23 @@ * *

To customize credentials: * + *

{@code
+ * MetricsServiceV2Settings metricsServiceV2Settings =
+ *     MetricsServiceV2Settings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * MetricsServiceV2Client metricsServiceV2Client =
+ *     MetricsServiceV2Client.create(metricsServiceV2Settings);
+ * }
+ * *

To customize the endpoint: + * + *

{@code
+ * MetricsServiceV2Settings metricsServiceV2Settings =
+ *     MetricsServiceV2Settings.newBuilder().setEndpoint("myEndpoint").build();
+ * MetricsServiceV2Client metricsServiceV2Client =
+ *     MetricsServiceV2Client.create(metricsServiceV2Settings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") @@ -134,6 +150,16 @@ public MetricsServiceV2Stub getStub() { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (MetricsServiceV2Client metricsServiceV2Client :
+   *       metricsServiceV2Client.ListLogMetrics(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The name of the project containing the metrics: *

"projects/[PROJECT_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -152,6 +178,16 @@ public final ListLogMetricsPagedResponse listLogMetrics(ProjectName parent) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   String parent = "parent-995424086";
+   *   for (MetricsServiceV2Client metricsServiceV2Client :
+   *       metricsServiceV2Client.ListLogMetrics(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The name of the project containing the metrics: *

"projects/[PROJECT_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -167,6 +203,17 @@ public final ListLogMetricsPagedResponse listLogMetrics(String parent) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder().setParent(parent).build();
+   *   for (MetricsServiceV2Client metricsServiceV2Client :
+   *       metricsServiceV2Client.ListLogMetrics(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -202,6 +249,13 @@ public final ListLogMetricsPagedResponse listLogMetrics(ListLogMetricsRequest re * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   LogMetric response = metricsServiceV2Client.GetLogMetric(metric_name);
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the desired metric: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -220,6 +274,13 @@ public final LogMetric getLogMetric(LogMetricName metricName) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   String metric_name = "metric_name-1737602118";
+   *   LogMetric response = metricsServiceV2Client.GetLogMetric(metric_name);
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the desired metric: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -236,6 +297,15 @@ public final LogMetric getLogMetric(String metricName) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   GetLogMetricRequest request =
+   *       GetLogMetricRequest.newBuilder().setMetricName(metric_name).build();
+   *   LogMetric response = metricsServiceV2Client.GetLogMetric(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -259,6 +329,14 @@ public final UnaryCallable getLogMetricCallable( * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   LogMetric response = metricsServiceV2Client.CreateLogMetric(parent, metric);
+   * }
+   * }
+ * * @param parent Required. The resource name of the project in which to create the metric: *

"projects/[PROJECT_ID]" *

The new metric must be provided in the request. @@ -281,6 +359,14 @@ public final LogMetric createLogMetric(ProjectName parent, LogMetric metric) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   String parent = "parent-995424086";
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   LogMetric response = metricsServiceV2Client.CreateLogMetric(parent, metric);
+   * }
+   * }
+ * * @param parent Required. The resource name of the project in which to create the metric: *

"projects/[PROJECT_ID]" *

The new metric must be provided in the request. @@ -300,6 +386,16 @@ public final LogMetric createLogMetric(String parent, LogMetric metric) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   CreateLogMetricRequest request =
+   *       CreateLogMetricRequest.newBuilder().setParent(parent).setMetric(metric).build();
+   *   LogMetric response = metricsServiceV2Client.CreateLogMetric(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -323,6 +419,14 @@ public final UnaryCallable createLogMetricCal * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   LogMetric response = metricsServiceV2Client.UpdateLogMetric(metric_name, metric);
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the metric to update: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" *

The updated metric must be provided in the request and it's `name` field must be the @@ -346,6 +450,14 @@ public final LogMetric updateLogMetric(LogMetricName metricName, LogMetric metri * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   String metric_name = "metric_name-1737602118";
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   LogMetric response = metricsServiceV2Client.UpdateLogMetric(metric_name, metric);
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the metric to update: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" *

The updated metric must be provided in the request and it's `name` field must be the @@ -366,6 +478,16 @@ public final LogMetric updateLogMetric(String metricName, LogMetric metric) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   UpdateLogMetricRequest request =
+   *       UpdateLogMetricRequest.newBuilder().setMetricName(metric_name).setMetric(metric).build();
+   *   LogMetric response = metricsServiceV2Client.UpdateLogMetric(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -389,6 +511,13 @@ public final UnaryCallable updateLogMetricCal * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   Empty response = metricsServiceV2Client.DeleteLogMetric(metric_name);
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the metric to delete: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -407,6 +536,13 @@ public final Empty deleteLogMetric(LogMetricName metricName) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   String metric_name = "metric_name-1737602118";
+   *   Empty response = metricsServiceV2Client.DeleteLogMetric(metric_name);
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the metric to delete: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -423,6 +559,15 @@ public final Empty deleteLogMetric(String metricName) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   DeleteLogMetricRequest request =
+   *       DeleteLogMetricRequest.newBuilder().setMetricName(metric_name).build();
+   *   Empty response = metricsServiceV2Client.DeleteLogMetric(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index c807b6dd8a..e20d84dca2 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -95,7 +95,21 @@ * *

To customize credentials: * + *

{@code
+ * CloudRedisSettings cloudRedisSettings =
+ *     CloudRedisSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * CloudRedisClient cloudRedisClient = CloudRedisClient.create(cloudRedisSettings);
+ * }
+ * *

To customize the endpoint: + * + *

{@code
+ * CloudRedisSettings cloudRedisSettings =
+ *     CloudRedisSettings.newBuilder().setEndpoint("myEndpoint").build();
+ * CloudRedisClient cloudRedisClient = CloudRedisClient.create(cloudRedisSettings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") @@ -176,6 +190,16 @@ public final OperationsClient getOperationsClient() { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (CloudRedisClient cloudRedisClient :
+   *       cloudRedisClient.ListInstances(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -204,6 +228,16 @@ public final ListInstancesPagedResponse listInstances(LocationName parent) { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String parent = "parent-995424086";
+   *   for (CloudRedisClient cloudRedisClient :
+   *       cloudRedisClient.ListInstances(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -229,6 +263,17 @@ public final ListInstancesPagedResponse listInstances(String parent) { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent(parent).build();
+   *   for (CloudRedisClient cloudRedisClient :
+   *       cloudRedisClient.ListInstances(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -283,6 +328,13 @@ public final UnaryCallable listInst * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   Instance response = cloudRedisClient.GetInstance(name);
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -302,6 +354,13 @@ public final Instance getInstance(InstanceName name) { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String name = "name3373707";
+   *   Instance response = cloudRedisClient.GetInstance(name);
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -318,6 +377,14 @@ public final Instance getInstance(String name) { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   GetInstanceRequest request = GetInstanceRequest.newBuilder().setName(name).build();
+   *   Instance response = cloudRedisClient.GetInstance(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -352,6 +419,16 @@ public final UnaryCallable getInstanceCallable() { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String instance_id = "instance_id-2101995259";
+   *   Instance instance = Instance.newBuilder().build();
+   *   Operation response =
+   *       cloudRedisClient.createInstanceAsync(parent, instance_id, instance).get();
+   * }
+   * }
+ * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. * @param instance_id Required. The logical name of the Redis instance in the customer project @@ -395,6 +472,16 @@ public final OperationFuture createInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String parent = "parent-995424086";
+   *   String instance_id = "instance_id-2101995259";
+   *   Instance instance = Instance.newBuilder().build();
+   *   Operation response =
+   *       cloudRedisClient.createInstanceAsync(parent, instance_id, instance).get();
+   * }
+   * }
+ * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. * @param instance_id Required. The logical name of the Redis instance in the customer project @@ -438,6 +525,21 @@ public final OperationFuture createInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String instance_id = "instance_id-2101995259";
+   *   Instance instance = Instance.newBuilder().build();
+   *   CreateInstanceRequest request =
+   *       CreateInstanceRequest.newBuilder()
+   *           .setParent(parent)
+   *           .setInstanceId(instance_id)
+   *           .setInstance(instance)
+   *           .build();
+   *   Operation response = CloudRedisClient.createInstanceAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -499,6 +601,14 @@ public final UnaryCallable createInstanceCalla * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   Instance instance = Instance.newBuilder().build();
+   *   Operation response = cloudRedisClient.updateInstanceAsync(update_mask, instance).get();
+   * }
+   * }
+ * * @param update_mask Required. Mask of fields to update. At least one path must be supplied in * this field. The elements of the repeated paths field may only include these fields from * [Instance][google.cloud.redis.v1.Instance]: @@ -523,6 +633,19 @@ public final OperationFuture updateInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   Instance instance = Instance.newBuilder().build();
+   *   UpdateInstanceRequest request =
+   *       UpdateInstanceRequest.newBuilder()
+   *           .setUpdateMask(update_mask)
+   *           .setInstance(instance)
+   *           .build();
+   *   Operation response = CloudRedisClient.updateInstanceAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -566,6 +689,14 @@ public final UnaryCallable updateInstanceCalla * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   String redis_version = "redis_version-685310444";
+   *   Operation response = cloudRedisClient.upgradeInstanceAsync(name, redis_version).get();
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -588,6 +719,14 @@ public final OperationFuture upgradeInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String name = "name3373707";
+   *   String redis_version = "redis_version-685310444";
+   *   Operation response = cloudRedisClient.upgradeInstanceAsync(name, redis_version).get();
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -607,6 +746,16 @@ public final OperationFuture upgradeInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   String redis_version = "redis_version-685310444";
+   *   UpgradeInstanceRequest request =
+   *       UpgradeInstanceRequest.newBuilder().setName(name).setRedisVersion(redis_version).build();
+   *   Operation response = CloudRedisClient.upgradeInstanceAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -648,6 +797,14 @@ public final UnaryCallable upgradeInstanceCal * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String name = "name3373707";
+   *   InputConfig input_config = InputConfig.newBuilder().build();
+   *   Operation response = cloudRedisClient.importInstanceAsync(name, input_config).get();
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -673,6 +830,16 @@ public final OperationFuture importInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String name = "name3373707";
+   *   InputConfig input_config = InputConfig.newBuilder().build();
+   *   ImportInstanceRequest request =
+   *       ImportInstanceRequest.newBuilder().setName(name).setInputConfig(input_config).build();
+   *   Operation response = CloudRedisClient.importInstanceAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -725,6 +892,14 @@ public final UnaryCallable importInstanceCalla * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String name = "name3373707";
+   *   OutputConfig output_config = OutputConfig.newBuilder().build();
+   *   Operation response = cloudRedisClient.exportInstanceAsync(name, output_config).get();
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -749,6 +924,16 @@ public final OperationFuture exportInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String name = "name3373707";
+   *   OutputConfig output_config = OutputConfig.newBuilder().build();
+   *   ExportInstanceRequest request =
+   *       ExportInstanceRequest.newBuilder().setName(name).setOutputConfig(output_config).build();
+   *   Operation response = CloudRedisClient.exportInstanceAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -795,6 +980,15 @@ public final UnaryCallable exportInstanceCalla * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   FailoverInstanceRequest.DataProtectionMode data_protection_mode =
+   *       FailoverInstanceRequest.DataProtectionMode.forNumber(0);
+   *   Operation response = cloudRedisClient.failoverInstanceAsync(name, data_protection_mode).get();
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -819,6 +1013,15 @@ public final OperationFuture failoverInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String name = "name3373707";
+   *   FailoverInstanceRequest.DataProtectionMode data_protection_mode =
+   *       FailoverInstanceRequest.DataProtectionMode.forNumber(0);
+   *   Operation response = cloudRedisClient.failoverInstanceAsync(name, data_protection_mode).get();
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -843,6 +1046,20 @@ public final OperationFuture failoverInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   FailoverInstanceRequest.DataProtectionMode data_protection_mode =
+   *       FailoverInstanceRequest.DataProtectionMode.forNumber(0);
+   *   FailoverInstanceRequest request =
+   *       FailoverInstanceRequest.newBuilder()
+   *           .setName(name)
+   *           .setDataProtectionMode(data_protection_mode)
+   *           .build();
+   *   Operation response = CloudRedisClient.failoverInstanceAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -880,6 +1097,13 @@ public final UnaryCallable failoverInstanceC * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   Operation response = cloudRedisClient.deleteInstanceAsync(name).get();
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -899,6 +1123,13 @@ public final OperationFuture deleteInstanceAsync(Insta * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   String name = "name3373707";
+   *   Operation response = cloudRedisClient.deleteInstanceAsync(name).get();
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -915,6 +1146,14 @@ public final OperationFuture deleteInstanceAsync(Strin * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder().setName(name).build();
+   *   Operation response = CloudRedisClient.deleteInstanceAsync(request).get();
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */