@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
CreateSinkRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setSink(sink)
/** * Creates a sink that exports specified log entries to a destination. The export of * newly-ingested log entries begins immediately, unless the sink's `writer_identity` is not * permitted to write to the destination. A sink can export log entries only from the resource * owning the sink. * * <p>Sample code: * * <pre><code> * try (ConfigClient configClient = ConfigClient.create()) { * ParentName parent = ProjectName.of("[PROJECT]"); * LogSink sink = LogSink.newBuilder().build(); * LogSink response = configClient.createSink(parent.toString(), sink); * } * </code></pre> * * @param parent Required. The resource in which to create the sink: * <p>"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" * <p>Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. * @param sink Required. The new sink, whose `name` parameter is a sink identifier that is not * already in use. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogSink createSink(String parent, LogSink sink) { CreateSinkRequest request = CreateSinkRequest.newBuilder().setParent(parent).setSink(sink).build(); return createSink(request); }
@Override public ApiFuture<Sink> createAsync(SinkInfo sink) { CreateSinkRequest request = CreateSinkRequest.newBuilder() .setParent(ProjectName.of(getOptions().getProjectId()).toString()) .setSink(sink.toPb(getOptions().getProjectId())) .build(); return transform(rpc.create(request), Sink.fromPbFunction(this)); }
@Test public void testCreateSink() { LogSink sinkPb = SINK_INFO.toPb(PROJECT); ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb); CreateSinkRequest request = CreateSinkRequest.newBuilder().setParent(PROJECT_PB).setSink(sinkPb).build(); EasyMock.expect(loggingRpcMock.create(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Sink sink = logging.create(SINK_INFO); assertEquals(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), sink); }
@Test public void testCreateSinkAsync() throws ExecutionException, InterruptedException { LogSink sinkPb = SINK_INFO.toPb(PROJECT); ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb); CreateSinkRequest request = CreateSinkRequest.newBuilder().setParent(PROJECT_PB).setSink(sinkPb).build(); EasyMock.expect(loggingRpcMock.create(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Sink sink = logging.createAsync(SINK_INFO).get(); assertEquals(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), sink); }
CreateSinkRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setSink(sink)
/** * Creates a sink that exports specified log entries to a destination. The export of * newly-ingested log entries begins immediately, unless the sink's `writer_identity` is not * permitted to write to the destination. A sink can export log entries only from the resource * owning the sink. * * <p>Sample code: * * <pre><code> * try (ConfigClient configClient = ConfigClient.create()) { * ParentName parent = ProjectName.of("[PROJECT]"); * LogSink sink = LogSink.newBuilder().build(); * LogSink response = configClient.createSink(parent.toString(), sink); * } * </code></pre> * * @param parent Required. The resource in which to create the sink: * <p>"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" * <p>Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. * @param sink Required. The new sink, whose `name` parameter is a sink identifier that is not * already in use. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogSink createSink(String parent, LogSink sink) { CreateSinkRequest request = CreateSinkRequest.newBuilder().setParent(parent).setSink(sink).build(); return createSink(request); }
@Override public ApiFuture<Sink> createAsync(SinkInfo sink) { CreateSinkRequest request = CreateSinkRequest.newBuilder() .setParent(ProjectName.of(getOptions().getProjectId()).toString()) .setSink(sink.toPb(getOptions().getProjectId())) .build(); return transform(rpc.create(request), Sink.fromPbFunction(this)); }