use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class AsyncListObjects method asyncListObjects.
public static void asyncListObjects() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
ListObjectsRequest request = ListObjectsRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setDelimiter("delimiter-250518009").setIncludeTrailingDelimiter(true).setPrefix("prefix-980110702").setVersions(true).setReadMask(FieldMask.newBuilder().build()).setLexicographicStart("lexicographicStart-2093413008").setLexicographicEnd("lexicographicEnd1646968169").setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
ApiFuture<Object> future = storageClient.listObjectsPagedCallable().futureCall(request);
// Do something.
for (Object element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class AsyncListObjectsPaged method asyncListObjectsPaged.
public static void asyncListObjectsPaged() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
ListObjectsRequest request = ListObjectsRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setDelimiter("delimiter-250518009").setIncludeTrailingDelimiter(true).setPrefix("prefix-980110702").setVersions(true).setReadMask(FieldMask.newBuilder().build()).setLexicographicStart("lexicographicStart-2093413008").setLexicographicEnd("lexicographicEnd1646968169").setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
while (true) {
ListObjectsResponse response = storageClient.listObjectsCallable().call(request);
for (Object element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class StorageClientTest method listObjectsTest2.
@Test
public void listObjectsTest2() throws Exception {
Object responsesElement = Object.newBuilder().build();
ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
String parent = "parent-995424086";
ListObjectsPagedResponse pagedListResponse = client.listObjects(parent);
List<Object> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getObjectsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListObjectsRequest actualRequest = ((ListObjectsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class AsyncUpdateObject method asyncUpdateObject.
public static void asyncUpdateObject() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
UpdateObjectRequest request = UpdateObjectRequest.newBuilder().setObject(Object.newBuilder().build()).setIfGenerationMatch(-1086241088).setIfGenerationNotMatch(1475720404).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setPredefinedAcl(PredefinedObjectAcl.forNumber(0)).setUpdateMask(FieldMask.newBuilder().build()).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
ApiFuture<Object> future = storageClient.updateObjectCallable().futureCall(request);
// Do something.
Object response = future.get();
}
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class SyncGetObject method syncGetObject.
public static void syncGetObject() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
GetObjectRequest request = GetObjectRequest.newBuilder().setBucket("bucket-1378203158").setObject("object-1023368385").setGeneration(305703192).setIfGenerationMatch(-1086241088).setIfGenerationNotMatch(1475720404).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).setReadMask(FieldMask.newBuilder().build()).build();
Object response = storageClient.getObject(request);
}
}
Aggregations