Search in sources :

Example 51 with ProjectName

use of com.google.cloud.dialogflow.v2beta1.ProjectName in project gapic-generator-java by googleapis.

the class SyncCreateNotificationProjectnameNotification method syncCreateNotificationProjectnameNotification.

public static void syncCreateNotificationProjectnameNotification() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        ProjectName parent = ProjectName.of("[PROJECT]");
        Notification notification = Notification.newBuilder().build();
        Notification response = storageClient.createNotification(parent, notification);
    }
}
Also used : ProjectName(com.google.storage.v2.ProjectName) StorageClient(com.google.storage.v2.StorageClient) Notification(com.google.storage.v2.Notification)

Example 52 with ProjectName

use of com.google.cloud.dialogflow.v2beta1.ProjectName in project gapic-generator-java by googleapis.

the class SyncGetHmacKeyStringProjectname method syncGetHmacKeyStringProjectname.

public static void syncGetHmacKeyStringProjectname() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        String accessId = "accessId-2146437729";
        ProjectName project = ProjectName.of("[PROJECT]");
        HmacKeyMetadata response = storageClient.getHmacKey(accessId, project);
    }
}
Also used : HmacKeyMetadata(com.google.storage.v2.HmacKeyMetadata) ProjectName(com.google.storage.v2.ProjectName) StorageClient(com.google.storage.v2.StorageClient)

Example 53 with ProjectName

use of com.google.cloud.dialogflow.v2beta1.ProjectName in project java-recaptchaenterprise by googleapis.

the class RecaptchaEnterpriseServiceClientTest method listRelatedAccountGroupsExceptionTest.

@Test
public void listRelatedAccountGroupsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockRecaptchaEnterpriseService.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        client.listRelatedAccountGroups(parent);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.recaptchaenterprise.v1.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 54 with ProjectName

use of com.google.cloud.dialogflow.v2beta1.ProjectName in project java-recaptchaenterprise by googleapis.

the class RecaptchaEnterpriseServiceClientTest method createAssessmentExceptionTest.

@Test
public void createAssessmentExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockRecaptchaEnterpriseService.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        Assessment assessment = Assessment.newBuilder().build();
        client.createAssessment(parent, assessment);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.recaptchaenterprise.v1.ProjectName) Assessment(com.google.recaptchaenterprise.v1.Assessment) AccountDefenderAssessment(com.google.recaptchaenterprise.v1.AccountDefenderAssessment) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 55 with ProjectName

use of com.google.cloud.dialogflow.v2beta1.ProjectName in project java-asset by googleapis.

the class ExportAssetsExample method exportAssets.

// Export assets for a project.
// @param exportPath where the results will be exported to.
public static void exportAssets(String exportPath, ContentType contentType) throws IOException, IllegalArgumentException, InterruptedException, ExecutionException {
    try (AssetServiceClient client = AssetServiceClient.create()) {
        ProjectName parent = ProjectName.of(projectId);
        OutputConfig outputConfig = OutputConfig.newBuilder().setGcsDestination(GcsDestination.newBuilder().setUri(exportPath).build()).build();
        ExportAssetsRequest request = ExportAssetsRequest.newBuilder().setParent(parent.toString()).setOutputConfig(outputConfig).setContentType(contentType).build();
        ExportAssetsResponse response = client.exportAssetsAsync(request).get();
        System.out.println(response);
    }
}
Also used : OutputConfig(com.google.cloud.asset.v1.OutputConfig) ExportAssetsRequest(com.google.cloud.asset.v1.ExportAssetsRequest) ProjectName(com.google.cloud.asset.v1.ProjectName) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) ExportAssetsResponse(com.google.cloud.asset.v1.ExportAssetsResponse)

Aggregations

Test (org.junit.Test)183 StatusRuntimeException (io.grpc.StatusRuntimeException)89 AbstractMessage (com.google.protobuf.AbstractMessage)81 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)74 ProjectName (com.google.monitoring.v3.ProjectName)62 ProjectName (com.google.pubsub.v1.ProjectName)44 ProjectName (com.google.logging.v2.ProjectName)31 ArrayList (java.util.ArrayList)31 ProjectName (com.google.privacy.dlp.v2.ProjectName)22 ByteString (com.google.protobuf.ByteString)20 DataTransferServiceClient (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient)17 ProjectName (com.google.cloud.bigquery.datatransfer.v1.ProjectName)17 IOException (java.io.IOException)17 CreateTransferConfigRequest (com.google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest)16 TransferConfig (com.google.cloud.bigquery.datatransfer.v1.TransferConfig)16 ProjectName (com.google.cloud.secretmanager.v1.ProjectName)16 ProjectName (com.google.containeranalysis.v1beta1.ProjectName)16 ApiException (com.google.api.gax.rpc.ApiException)15 MetricServiceClient (com.google.cloud.monitoring.v3.MetricServiceClient)15 TimeSeries (com.google.monitoring.v3.TimeSeries)15