Search in sources :

Example 1 with LocationName

use of com.google.cloud.aiplatform.v1beta1.LocationName in project java-docs-samples by GoogleCloudPlatform.

the class CreateQueue method createQueue.

public static void createQueue(String projectId, String locationId, String queueBlueName, String queueRedName) throws Exception {
    try (CloudTasksClient client = CloudTasksClient.create()) {
        // TODO(developer): Uncomment these lines and replace with your values.
        // String projectId = "your-project-id";
        // String locationId = "us-central1";
        // String queueBlueName = "queue-blue";
        // String queueRedName = "queue-red";
        LocationName parent = LocationName.of(projectId, locationId);
        Queue queueBlue = Queue.newBuilder().setName(QueueName.of(projectId, locationId, queueBlueName).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(5.0)).setAppEngineRoutingOverride(AppEngineRouting.newBuilder().setVersion("v2").setService("task-module")).build();
        Queue queueRed = Queue.newBuilder().setName(QueueName.of(projectId, locationId, queueRedName).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(1.0)).build();
        Queue[] queues = new Queue[] { queueBlue, queueRed };
        for (Queue queue : queues) {
            Queue response = client.createQueue(parent, queue);
            System.out.println(response);
        }
    }
}
Also used : CloudTasksClient(com.google.cloud.tasks.v2.CloudTasksClient) Queue(com.google.cloud.tasks.v2.Queue) LocationName(com.google.cloud.tasks.v2.LocationName)

Example 2 with LocationName

use of com.google.cloud.aiplatform.v1beta1.LocationName in project java-docs-samples by GoogleCloudPlatform.

the class RetryTask method retryTask.

public static void retryTask(String projectId, String locationId, String fooqueue, String barqueue, String bazqueue) throws Exception {
    try (CloudTasksClient client = CloudTasksClient.create()) {
        // TODO(developer): Uncomment these lines and replace with your values.
        // String projectId = "your-project-id";
        // String locationId = "us-central1";
        // String fooqueue = "fooqueue";
        // String barqueue = "barqueue";
        // String bazqueue = "bazqueue";
        LocationName parent = LocationName.of(projectId, locationId);
        Duration retryDuration = Duration.newBuilder().setSeconds(2 * 60 * 60 * 24).build();
        Duration min = Duration.newBuilder().setSeconds(10).build();
        Duration max1 = Duration.newBuilder().setSeconds(200).build();
        Duration max2 = Duration.newBuilder().setSeconds(300).build();
        Queue foo = Queue.newBuilder().setName(QueueName.of(projectId, locationId, fooqueue).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(1.0)).setRetryConfig(RetryConfig.newBuilder().setMaxAttempts(7).setMaxRetryDuration(retryDuration)).build();
        Queue bar = Queue.newBuilder().setName(QueueName.of(projectId, locationId, barqueue).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(1.0)).setRetryConfig(RetryConfig.newBuilder().setMinBackoff(min).setMaxBackoff(max1).setMaxDoublings(0)).build();
        Queue baz = Queue.newBuilder().setName(QueueName.of(projectId, locationId, bazqueue).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(1.0)).setRetryConfig(RetryConfig.newBuilder().setMinBackoff(min).setMaxBackoff(max2).setMaxDoublings(3)).build();
        Queue[] queues = new Queue[] { foo, bar, baz };
        for (Queue queue : queues) {
            Queue response = client.createQueue(parent, queue);
            System.out.println(response);
        }
    }
}
Also used : CloudTasksClient(com.google.cloud.tasks.v2.CloudTasksClient) Duration(com.google.protobuf.Duration) Queue(com.google.cloud.tasks.v2.Queue) LocationName(com.google.cloud.tasks.v2.LocationName)

Example 3 with LocationName

use of com.google.cloud.aiplatform.v1beta1.LocationName in project java-docs-samples by GoogleCloudPlatform.

the class UpdateQueue method updateQueue.

public static void updateQueue(String projectId, String locationId, String queueId) throws Exception {
    try (CloudTasksClient client = CloudTasksClient.create()) {
        // TODO(developer): Uncomment these lines and replace with your values.
        // String projectId = "your-project-id";
        // String locationId = "us-central1";
        // String queueId = "queue-blue";
        LocationName parent = LocationName.of(projectId, locationId);
        Queue queueBlue = Queue.newBuilder().setName(QueueName.of(projectId, locationId, queueId).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(20.0).setMaxConcurrentDispatches(10)).build();
        UpdateQueueRequest request = UpdateQueueRequest.newBuilder().setQueue(queueBlue).build();
        Queue response = client.updateQueue(request);
        System.out.println(response);
    }
}
Also used : CloudTasksClient(com.google.cloud.tasks.v2.CloudTasksClient) Queue(com.google.cloud.tasks.v2.Queue) UpdateQueueRequest(com.google.cloud.tasks.v2.UpdateQueueRequest) LocationName(com.google.cloud.tasks.v2.LocationName)

Example 4 with LocationName

use of com.google.cloud.aiplatform.v1beta1.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 5 with LocationName

use of com.google.cloud.aiplatform.v1beta1.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

Test (org.junit.Test)54 AbstractMessage (com.google.protobuf.AbstractMessage)37 LocationName (com.google.cloud.aiplatform.v1.LocationName)36 LocationName (com.google.privacy.dlp.v2.LocationName)22 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)22 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