Search in sources :

Example 6 with SinkNameOneof

use of com.google.logging.v2.SinkNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class ConfigClientTest method getSinkTest.

@Test
@SuppressWarnings("all")
public void getSinkTest() {
    String name = "name3373707";
    ResourceName destination = ProjectName.create("[PROJECT]");
    String filter = "filter-1274492040";
    String writerIdentity = "writerIdentity775638794";
    LogSink expectedResponse = LogSink.newBuilder().setName(name).setDestinationWithResourceName(destination).setFilter(filter).setWriterIdentity(writerIdentity).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
    LogSink actualResponse = client.getSink(sinkName);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetSinkRequest actualRequest = (GetSinkRequest) actualRequests.get(0);
    Assert.assertEquals(sinkName, actualRequest.getSinkNameAsSinkNameOneof());
}
Also used : LogSink(com.google.logging.v2.LogSink) GetSinkRequest(com.google.logging.v2.GetSinkRequest) ResourceName(com.google.api.resourcenames.ResourceName) SinkNameOneof(com.google.logging.v2.SinkNameOneof) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 7 with SinkNameOneof

use of com.google.logging.v2.SinkNameOneof in project google-cloud-java by GoogleCloudPlatform.

the class ConfigClient method deleteSink.

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
   * Deletes a sink. If the sink has a unique `writer_identity`, then that service account is also
   * deleted.
   *
   * <p>Sample code:
   *
   * <pre><code>
   * try (ConfigClient configClient = ConfigClient.create()) {
   *   SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
   *   configClient.deleteSink(sinkName);
   * }
   * </code></pre>
   *
   * @param sinkName Required. The full resource name of the sink to delete, including the parent
   *     resource and the sink identifier:
   *     <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.grpc.ApiException if the remote call fails
   */
public final void deleteSink(SinkNameOneof sinkName) {
    DeleteSinkRequest request = DeleteSinkRequest.newBuilder().setSinkNameWithSinkNameOneof(sinkName).build();
    deleteSink(request);
}
Also used : DeleteSinkRequest(com.google.logging.v2.DeleteSinkRequest)

Aggregations

SinkNameOneof (com.google.logging.v2.SinkNameOneof)6 Test (org.junit.Test)6 ApiException (com.google.api.gax.grpc.ApiException)3 LogSink (com.google.logging.v2.LogSink)3 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)3 StatusRuntimeException (io.grpc.StatusRuntimeException)3 ResourceName (com.google.api.resourcenames.ResourceName)2 DeleteSinkRequest (com.google.logging.v2.DeleteSinkRequest)2 GetSinkRequest (com.google.logging.v2.GetSinkRequest)1 UpdateSinkRequest (com.google.logging.v2.UpdateSinkRequest)1 Empty (com.google.protobuf.Empty)1