StorageObject toPb() { StorageObject storageObject = new StorageObject(); storageObject.setBucket(bucket); storageObject.setName(name); storageObject.setGeneration(generation); return storageObject; }
@Override void populateCondition(Rule.Condition condition) { condition.setAge(daysToLive); } }
com.google.api.services.storage.model.ServiceAccount toPb() { com.google.api.services.storage.model.ServiceAccount serviceAccountPb = new com.google.api.services.storage.model.ServiceAccount(); serviceAccountPb.setEmailAddress(email); return serviceAccountPb; }
@Override public StorageObject apply(String prefix) { return new StorageObject() .set("isDirectory", true) .setBucket(bucket) .setName(prefix) .setSize(BigInteger.ZERO); } };
static BlobId fromPb(StorageObject storageObject) { return BlobId.of( storageObject.getBucket(), storageObject.getName(), storageObject.getGeneration()); } }
private Iterator<String> createIterator() throws Exception { if (listObjectsSrvcHandle == null) initListing(); List<String> temp = Lists.newArrayList(); // a container of results // Sends the metadata request to the server and returns the parsed metadata response. this.objectsContainerHandle = listObjectsSrvcHandle.execute(); for (StorageObject object : this.objectsContainerHandle.getItems()) { // processing a page of results temp.add(object.getName()); } return temp.iterator(); }
Rule toPb() { Rule rule = new Rule(); rule.setAction(new Rule.Action().setType(SUPPORTED_ACTION)); Rule.Condition condition = new Rule.Condition(); populateCondition(condition); rule.setCondition(condition); return rule; }
public long size(final String bucket, final String path) throws IOException { return storage.objects().get(bucket, path).execute().getSize().longValue(); }
static Policy convertFromApiPolicy(com.google.api.services.storage.model.Policy apiPolicy) { Policy.Builder policyBuilder = Policy.newBuilder(); for (Bindings binding : apiPolicy.getBindings()) { for (String member : binding.getMembers()) { policyBuilder.addIdentity(Role.of(binding.getRole()), Identity.valueOf(member)); } } return policyBuilder.setEtag(apiPolicy.getEtag()).build(); }
BucketAccessControl toBucketPb() { BucketAccessControl bucketPb = new BucketAccessControl(); bucketPb.setEntity(getEntity().toString()); bucketPb.setRole(getRole().toString()); bucketPb.setId(getId()); bucketPb.setEtag(getEtag()); return bucketPb; }
public ApiPolicyMatcher(Policy expected) { expectedBindings = toMap(expected.getBindings()); expectedEtag = expected.getEtag(); }
StorageObject.CustomerEncryption toPb() { return new StorageObject.CustomerEncryption() .setEncryptionAlgorithm(encryptionAlgorithm) .setKeySha256(keySha256); }
public String version(final String bucket, final String path) throws IOException { return storage.objects().get(bucket, path).execute().getEtag(); }
@Override void populateCondition(Rule.Condition condition) { condition.setNumNewerVersions(numNewerVersions); } }
@Override void populateCondition(Rule.Condition condition) { condition.setIsLive(isLive); } }
static CustomerEncryption fromPb(StorageObject.CustomerEncryption customerEncryptionPb) { return new CustomerEncryption( customerEncryptionPb.getEncryptionAlgorithm(), customerEncryptionPb.getKeySha256()); } }
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeUTF(rule.toString()); }
@Override void populateCondition(Rule.Condition condition) { condition.setCreatedBefore(new DateTime(true, timeMillis, 0)); } }
static ServiceAccount fromPb(com.google.api.services.storage.model.ServiceAccount accountPb) { return new ServiceAccount(accountPb.getEmailAddress()); } }