use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class StorageClientTest method listObjectsTest.
@Test
public void listObjectsTest() throws Exception {
Object responsesElement = Object.newBuilder().build();
ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
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.toString(), 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 SyncUpdateObject method syncUpdateObject.
public static void syncUpdateObject() 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();
Object response = storageClient.updateObject(request);
}
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class SyncUpdateObjectObjectFieldmask method syncUpdateObjectObjectFieldmask.
public static void syncUpdateObjectObjectFieldmask() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
Object object = Object.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Object response = storageClient.updateObject(object, updateMask);
}
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class AsyncReadObject method asyncReadObject.
public static void asyncReadObject() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
ReadObjectRequest request = ReadObjectRequest.newBuilder().setBucket("bucket-1378203158").setObject("object-1023368385").setGeneration(305703192).setReadOffset(-715377828).setReadLimit(-164298798).setIfGenerationMatch(-1086241088).setIfGenerationNotMatch(1475720404).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).setReadMask(FieldMask.newBuilder().build()).build();
ServerStream<ReadObjectResponse> stream = storageClient.readObjectCallable().call(request);
for (ReadObjectResponse response : stream) {
// Do something when a response is received.
}
}
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class AsyncGetObject method asyncGetObject.
public static void asyncGetObject() 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();
ApiFuture<Object> future = storageClient.getObjectCallable().futureCall(request);
// Do something.
Object response = future.get();
}
}
Aggregations