Search in sources :

Example 36 with Object

use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.

the class SyncGetObjectStringStringLong method syncGetObjectStringStringLong.

public static void syncGetObjectStringStringLong() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        String bucket = "bucket-1378203158";
        String object = "object-1023368385";
        long generation = 305703192;
        Object response = storageClient.getObject(bucket, object, generation);
    }
}
Also used : StorageClient(com.google.storage.v2.StorageClient) Object(com.google.storage.v2.Object)

Example 37 with Object

use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.

the class SyncDeleteObjectStringStringLong method syncDeleteObjectStringStringLong.

public static void syncDeleteObjectStringStringLong() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        String bucket = "bucket-1378203158";
        String object = "object-1023368385";
        long generation = 305703192;
        storageClient.deleteObject(bucket, object, generation);
    }
}
Also used : StorageClient(com.google.storage.v2.StorageClient)

Example 38 with Object

use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.

the class AsyncDeleteObject method asyncDeleteObject.

public static void asyncDeleteObject() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        DeleteObjectRequest request = DeleteObjectRequest.newBuilder().setBucket("bucket-1378203158").setObject("object-1023368385").setUploadId("uploadId1563990780").setGeneration(305703192).setIfGenerationMatch(-1086241088).setIfGenerationNotMatch(1475720404).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        ApiFuture<Empty> future = storageClient.deleteObjectCallable().futureCall(request);
        // Do something.
        future.get();
    }
}
Also used : DeleteObjectRequest(com.google.storage.v2.DeleteObjectRequest) Empty(com.google.protobuf.Empty) StorageClient(com.google.storage.v2.StorageClient)

Example 39 with Object

use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.

the class SyncComposeObject method syncComposeObject.

public static void syncComposeObject() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        ComposeObjectRequest request = ComposeObjectRequest.newBuilder().setDestination(Object.newBuilder().build()).addAllSourceObjects(new ArrayList<ComposeObjectRequest.SourceObject>()).setDestinationPredefinedAcl(PredefinedObjectAcl.forNumber(0)).setIfGenerationMatch(-1086241088).setIfMetagenerationMatch(1043427781).setKmsKey(CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString()).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        Object response = storageClient.composeObject(request);
    }
}
Also used : ComposeObjectRequest(com.google.storage.v2.ComposeObjectRequest) ArrayList(java.util.ArrayList) StorageClient(com.google.storage.v2.StorageClient) Object(com.google.storage.v2.Object)

Example 40 with Object

use of com.google.storage.v2.Object in project grpc-gcp-java by GoogleCloudPlatform.

the class GrpcClient method makeRandomReadRequest.

private void makeRandomReadRequest(ManagedChannel channel, ResultTable results, int threadId) {
    StorageBlockingStub blockingStub = StorageGrpc.newBlockingStub(channel);
    if (creds != null) {
        blockingStub = blockingStub.withCallCredentials(MoreCallCredentials.from(creds));
    }
    String object = objectResolver.Resolve(threadId, /*objectId=*/
    0);
    ReadObjectRequest.Builder reqBuilder = ReadObjectRequest.newBuilder().setBucket(toV2BucketName(args.bkt)).setObject(object);
    Random r = new Random();
    long buffSize = args.buffSize * 1024;
    byte[] scratch = new byte[4 * 1024 * 1024];
    for (int i = 0; i < args.calls; i++) {
        long offset = (long) r.nextInt(args.size - args.buffSize) * 1024;
        reqBuilder.setReadOffset(offset);
        reqBuilder.setReadLimit(buffSize);
        ReadObjectRequest req = reqBuilder.build();
        long start = System.currentTimeMillis();
        Iterator<ReadObjectResponse> resIterator = blockingStub.readObject(req);
        while (resIterator.hasNext()) {
            ReadObjectResponse res = resIterator.next();
            ByteString content = res.getChecksummedData().getContent();
            content.copyTo(scratch, 0);
        }
        long dur = System.currentTimeMillis() - start;
        results.reportResult(args.bkt, object, buffSize, dur);
    }
}
Also used : ReadObjectResponse(com.google.storage.v2.ReadObjectResponse) ReadObjectRequest(com.google.storage.v2.ReadObjectRequest) Random(java.util.Random) ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) StorageBlockingStub(com.google.storage.v2.StorageGrpc.StorageBlockingStub)

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