@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
/** * Gets a sink. * * <p>Sample code: * * <pre><code> * try (ConfigClient configClient = ConfigClient.create()) { * SinkName sinkName = ProjectSinkName.of("[PROJECT]", "[SINK]"); * LogSink response = configClient.getSink(sinkName); * } * </code></pre> * * @param sinkName Required. The resource name of the sink: * <p>"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" * "folders/[FOLDER_ID]/sinks/[SINK_ID]" * <p>Example: `"projects/my-project-id/sinks/my-sink-id"`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogSink getSink(SinkName sinkName) { GetSinkRequest request = GetSinkRequest.newBuilder() .setSinkName(sinkName == null ? null : sinkName.toString()) .build(); return getSink(request); }
/** * Gets a sink. * * <p>Sample code: * * <pre><code> * try (ConfigClient configClient = ConfigClient.create()) { * SinkName sinkName = ProjectSinkName.of("[PROJECT]", "[SINK]"); * LogSink response = configClient.getSink(sinkName.toString()); * } * </code></pre> * * @param sinkName Required. The resource name of the sink: * <p>"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" * "folders/[FOLDER_ID]/sinks/[SINK_ID]" * <p>Example: `"projects/my-project-id/sinks/my-sink-id"`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogSink getSink(String sinkName) { GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(sinkName).build(); return getSink(request); }
@Test public void testGetSink_Null() { ApiFuture<LogSink> response = ApiFutures.immediateFuture(null); GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); assertNull(logging.getSink(SINK_NAME)); }
@Override public ApiFuture<Sink> getSinkAsync(String sink) { GetSinkRequest request = GetSinkRequest.newBuilder() .setSinkName(ProjectSinkName.of(getOptions().getProjectId(), sink).toString()) .build(); return transform(rpc.get(request), Sink.fromPbFunction(this)); }
@Test public void testGetSinkAsync_Null() throws ExecutionException, InterruptedException { ApiFuture<LogSink> response = ApiFutures.immediateFuture(null); GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); assertNull(logging.getSinkAsync(SINK_NAME).get()); }
@Test public void testGetSink() { LogSink sinkPb = SINK_INFO.toPb(PROJECT); ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb); GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Sink sink = logging.getSink(SINK_NAME); assertEquals(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), sink); }
@Test public void testGetSinkAsync() throws ExecutionException, InterruptedException { LogSink sinkPb = SINK_INFO.toPb(PROJECT); ApiFuture<LogSink> response = ApiFutures.immediateFuture(sinkPb); GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(SINK_NAME_PB).build(); EasyMock.expect(loggingRpcMock.get(request)).andReturn(response); EasyMock.replay(rpcFactoryMock, loggingRpcMock); logging = options.getService(); Sink sink = logging.getSinkAsync(SINK_NAME).get(); assertEquals(new Sink(logging, new SinkInfo.BuilderImpl(SINK_INFO)), sink); }
/** * Gets a sink. * * <p>Sample code: * * <pre><code> * try (ConfigClient configClient = ConfigClient.create()) { * SinkName sinkName = ProjectSinkName.of("[PROJECT]", "[SINK]"); * LogSink response = configClient.getSink(sinkName); * } * </code></pre> * * @param sinkName Required. The resource name of the sink: * <p>"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" * "folders/[FOLDER_ID]/sinks/[SINK_ID]" * <p>Example: `"projects/my-project-id/sinks/my-sink-id"`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogSink getSink(SinkName sinkName) { GetSinkRequest request = GetSinkRequest.newBuilder() .setSinkName(sinkName == null ? null : sinkName.toString()) .build(); return getSink(request); }
/** * Gets a sink. * * <p>Sample code: * * <pre><code> * try (ConfigClient configClient = ConfigClient.create()) { * SinkName sinkName = ProjectSinkName.of("[PROJECT]", "[SINK]"); * LogSink response = configClient.getSink(sinkName.toString()); * } * </code></pre> * * @param sinkName Required. The resource name of the sink: * <p>"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" * "folders/[FOLDER_ID]/sinks/[SINK_ID]" * <p>Example: `"projects/my-project-id/sinks/my-sink-id"`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final LogSink getSink(String sinkName) { GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(sinkName).build(); return getSink(request); }
@Override public ApiFuture<Sink> getSinkAsync(String sink) { GetSinkRequest request = GetSinkRequest.newBuilder() .setSinkName(ProjectSinkName.of(getOptions().getProjectId(), sink).toString()) .build(); return transform(rpc.get(request), Sink.fromPbFunction(this)); }