Search in sources :

Example 76 with Object

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);
        }
    }
}
Also used : ListObjectsRequest(com.google.storage.v2.ListObjectsRequest) StorageClient(com.google.storage.v2.StorageClient) Object(com.google.storage.v2.Object)

Example 77 with Object

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;
            }
        }
    }
}
Also used : ListObjectsRequest(com.google.storage.v2.ListObjectsRequest) StorageClient(com.google.storage.v2.StorageClient) ListObjectsResponse(com.google.storage.v2.ListObjectsResponse) Object(com.google.storage.v2.Object)

Example 78 with Object

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListObjectsPagedResponse(com.google.storage.v2.StorageClient.ListObjectsPagedResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 79 with Object

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();
    }
}
Also used : UpdateObjectRequest(com.google.storage.v2.UpdateObjectRequest) StorageClient(com.google.storage.v2.StorageClient) Object(com.google.storage.v2.Object)

Example 80 with Object

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);
    }
}
Also used : StorageClient(com.google.storage.v2.StorageClient) Object(com.google.storage.v2.Object) GetObjectRequest(com.google.storage.v2.GetObjectRequest)

Aggregations

Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)33 ArrayList (java.util.ArrayList)25 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)18 StorageClient (com.google.storage.v2.StorageClient)16 Object (com.google.storage.v2.Object)12 Test (org.junit.Test)12 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)12 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)12 Object (no.mnemonic.act.platform.api.model.v1.Object)8 Preconditions (com.google.common.base.Preconditions)6 ObjectRecord (no.mnemonic.act.platform.dao.api.record.ObjectRecord)6 Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics)6 Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.Metrics)5 Ero (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero)5 AbstractMessage (com.google.protobuf.AbstractMessage)4 ByteString (com.google.protobuf.ByteString)4 PCEPErrors (org.opendaylight.protocol.pcep.spi.PCEPErrors)4 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)4 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp)4 ListObjectsPagedResponse (com.google.storage.v2.StorageClient.ListObjectsPagedResponse)3