Search in sources :

Example 71 with LocationName

use of com.google.cloud.security.privateca.v1.LocationName in project java-security-private-ca by googleapis.

the class CertificateAuthorityServiceClientTest method listCaPoolsTest.

@Test
public void listCaPoolsTest() throws Exception {
    CaPool responsesElement = CaPool.newBuilder().build();
    ListCaPoolsResponse expectedResponse = ListCaPoolsResponse.newBuilder().setNextPageToken("").addAllCaPools(Arrays.asList(responsesElement)).build();
    mockCertificateAuthorityService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListCaPoolsPagedResponse pagedListResponse = client.listCaPools(parent);
    List<CaPool> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getCaPoolsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCertificateAuthorityService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListCaPoolsRequest actualRequest = ((ListCaPoolsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListCaPoolsPagedResponse(com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient.ListCaPoolsPagedResponse) Test(org.junit.Test)

Example 72 with LocationName

use of com.google.cloud.security.privateca.v1.LocationName in project java-security-private-ca by googleapis.

the class CertificateAuthorityServiceClientTest method listCertificateTemplatesTest.

@Test
public void listCertificateTemplatesTest() throws Exception {
    CertificateTemplate responsesElement = CertificateTemplate.newBuilder().build();
    ListCertificateTemplatesResponse expectedResponse = ListCertificateTemplatesResponse.newBuilder().setNextPageToken("").addAllCertificateTemplates(Arrays.asList(responsesElement)).build();
    mockCertificateAuthorityService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListCertificateTemplatesPagedResponse pagedListResponse = client.listCertificateTemplates(parent);
    List<CertificateTemplate> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getCertificateTemplatesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCertificateAuthorityService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListCertificateTemplatesRequest actualRequest = ((ListCertificateTemplatesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListCertificateTemplatesPagedResponse(com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient.ListCertificateTemplatesPagedResponse) Test(org.junit.Test)

Example 73 with LocationName

use of com.google.cloud.security.privateca.v1.LocationName in project java-security-private-ca by googleapis.

the class ListCaPools method listCaPools.

// List all CA pools present in the given project and location.
public static void listCaPools(String project, String location) throws IOException {
    // clean up any remaining background resources.
    try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) {
        // Set the Location Name which contains project and location of the pool.
        LocationName locationName = LocationName.newBuilder().setProject(project).setLocation(location).build();
        String caPoolName = "";
        System.out.println("Available CA pools: ");
        // List the CA pools.
        for (CaPool caPool : certificateAuthorityServiceClient.listCaPools(locationName).iterateAll()) {
            caPoolName = caPool.getName();
            // caPoolName represents the full resource name of the
            // format 'projects/{project-id}/locations/{location}/ca-pools/{ca-pool-id}'.
            // Hence stripping it down to just CA pool id.
            System.out.println(caPoolName.substring(caPoolName.lastIndexOf("/") + 1) + " " + caPool.isInitialized());
        }
    }
}
Also used : CertificateAuthorityServiceClient(com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient) CaPool(com.google.cloud.security.privateca.v1.CaPool) LocationName(com.google.cloud.security.privateca.v1.LocationName)

Example 74 with LocationName

use of com.google.cloud.security.privateca.v1.LocationName in project java-bigqueryconnection by googleapis.

the class ConnectionServiceClientTest method listConnectionsTest.

@Test
public void listConnectionsTest() throws Exception {
    Connection responsesElement = Connection.newBuilder().build();
    ListConnectionsResponse expectedResponse = ListConnectionsResponse.newBuilder().setNextPageToken("").addAllConnections(Arrays.asList(responsesElement)).build();
    mockConnectionService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListConnectionsPagedResponse pagedListResponse = client.listConnections(parent);
    List<Connection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getConnectionsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListConnectionsRequest actualRequest = ((ListConnectionsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListConnectionsRequest(com.google.cloud.bigquery.connection.v1.ListConnectionsRequest) ListConnectionsResponse(com.google.cloud.bigquery.connection.v1.ListConnectionsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Connection(com.google.cloud.bigquery.connection.v1.Connection) ListConnectionsPagedResponse(com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient.ListConnectionsPagedResponse) LocationName(com.google.cloud.bigquery.connection.v1.LocationName) Test(org.junit.Test)

Example 75 with LocationName

use of com.google.cloud.security.privateca.v1.LocationName in project java-bigqueryconnection by googleapis.

the class ConnectionServiceClientTest method createConnectionTest.

@Test
public void createConnectionTest() throws Exception {
    Connection expectedResponse = Connection.newBuilder().setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString()).setFriendlyName("friendlyName461933014").setDescription("description-1724546052").setCreationTime(1932333101).setLastModifiedTime(-671513446).setHasCredential(true).build();
    mockConnectionService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    Connection connection = Connection.newBuilder().build();
    String connectionId = "connectionId1923106969";
    Connection actualResponse = client.createConnection(parent, connection, connectionId);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateConnectionRequest actualRequest = ((CreateConnectionRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(connection, actualRequest.getConnection());
    Assert.assertEquals(connectionId, actualRequest.getConnectionId());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Connection(com.google.cloud.bigquery.connection.v1.Connection) ByteString(com.google.protobuf.ByteString) CreateConnectionRequest(com.google.cloud.bigquery.connection.v1.CreateConnectionRequest) LocationName(com.google.cloud.bigquery.connection.v1.LocationName) Test(org.junit.Test)

Aggregations

LocationName (com.google.cloud.aiplatform.v1.LocationName)36 Test (org.junit.Test)36 LocationName (com.google.privacy.dlp.v2.LocationName)22 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)22 AbstractMessage (com.google.protobuf.AbstractMessage)19 LocationName (com.google.cloud.translate.v3beta1.LocationName)18 TranslationServiceClient (com.google.cloud.translate.v3beta1.TranslationServiceClient)18 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)17 LocationName (com.google.cloud.automl.v1.LocationName)17 JobServiceClient (com.google.cloud.aiplatform.v1.JobServiceClient)15 JobServiceSettings (com.google.cloud.aiplatform.v1.JobServiceSettings)15 Value (com.google.protobuf.Value)15 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)14 Model (com.google.cloud.aiplatform.v1.Model)14 StatusRuntimeException (io.grpc.StatusRuntimeException)14 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)13 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)13 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)13 LocationName (com.google.cloud.translate.v3.LocationName)13 TranslationServiceClient (com.google.cloud.translate.v3.TranslationServiceClient)13