Search in sources :

Example 1 with Location

use of com.google.cloud.location.Location in project gapic-generator-java by googleapis.

the class SyncGetLocation method syncGetLocation.

public static void syncGetLocation() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
        Location response = keyManagementServiceClient.getLocation(request);
    }
}
Also used : GetLocationRequest(com.google.cloud.location.GetLocationRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) Location(com.google.cloud.location.Location)

Example 2 with Location

use of com.google.cloud.location.Location in project gapic-generator-java by googleapis.

the class AsyncListLocations method asyncListLocations.

public static void asyncListLocations() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        ListLocationsRequest request = ListLocationsRequest.newBuilder().setName("name3373707").setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();
        ApiFuture<Location> future = keyManagementServiceClient.listLocationsPagedCallable().futureCall(request);
        // Do something.
        for (Location element : future.get().iterateAll()) {
        // doThingsWith(element);
        }
    }
}
Also used : ListLocationsRequest(com.google.cloud.location.ListLocationsRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) Location(com.google.cloud.location.Location)

Example 3 with Location

use of com.google.cloud.location.Location in project java-security-private-ca by googleapis.

the class CertificateAuthorityServiceClientTest method getLocationTest.

@Test
public void getLocationTest() throws Exception {
    Location expectedResponse = Location.newBuilder().setName("name3373707").setLocationId("locationId1541836720").setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setMetadata(Any.newBuilder().build()).build();
    mockLocations.addResponse(expectedResponse);
    GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
    Location actualResponse = client.getLocation(request);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockLocations.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) GetLocationRequest(com.google.cloud.location.GetLocationRequest) ByteString(com.google.protobuf.ByteString) Location(com.google.cloud.location.Location) Test(org.junit.Test)

Example 4 with Location

use of com.google.cloud.location.Location in project gapic-generator-java by googleapis.

the class AsyncGetLocation method asyncGetLocation.

public static void asyncGetLocation() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
        ApiFuture<Location> future = keyManagementServiceClient.getLocationCallable().futureCall(request);
        // Do something.
        Location response = future.get();
    }
}
Also used : GetLocationRequest(com.google.cloud.location.GetLocationRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) Location(com.google.cloud.location.Location)

Example 5 with Location

use of com.google.cloud.location.Location in project gapic-generator-java by googleapis.

the class AsyncListLocationsPaged method asyncListLocationsPaged.

public static void asyncListLocationsPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
        ListLocationsRequest request = ListLocationsRequest.newBuilder().setName("name3373707").setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();
        while (true) {
            ListLocationsResponse response = keyManagementServiceClient.listLocationsCallable().call(request);
            for (Location element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : ListLocationsResponse(com.google.cloud.location.ListLocationsResponse) ListLocationsRequest(com.google.cloud.location.ListLocationsRequest) KeyManagementServiceClient(com.google.cloud.kms.v1.KeyManagementServiceClient) Location(com.google.cloud.location.Location)

Aggregations

Location (com.google.cloud.location.Location)10 AbstractMessage (com.google.protobuf.AbstractMessage)6 Test (org.junit.Test)6 GetLocationRequest (com.google.cloud.location.GetLocationRequest)5 ListLocationsRequest (com.google.cloud.location.ListLocationsRequest)5 KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)4 ListLocationsResponse (com.google.cloud.location.ListLocationsResponse)4 ByteString (com.google.protobuf.ByteString)2 ListLocationsPagedResponse (com.google.cloud.datastream.v1.DatastreamClient.ListLocationsPagedResponse)1 ListLocationsPagedResponse (com.google.cloud.kms.v1.KeyManagementServiceClient.ListLocationsPagedResponse)1 ListLocationsPagedResponse (com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient.ListLocationsPagedResponse)1