Search in sources :

Example 31 with Object

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

Example 32 with Object

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

Example 33 with Object

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

Example 34 with Object

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

Example 35 with Object

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();
    }
}
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