com.google.cloud.storage.Bucket.getCreateTime()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中com.google.cloud.storage.Bucket.getCreateTime()方法的一些代码示例,展示了Bucket.getCreateTime()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bucket.getCreateTime()方法的具体详情如下:
包路径:com.google.cloud.storage.Bucket
类名称:Bucket
方法名:getCreateTime

Bucket.getCreateTime介绍

暂无

代码示例

代码示例来源:origin: googleapis/google-cloud-java

@Test(timeout = 5000)
public void testListBuckets() throws InterruptedException {
 Iterator<Bucket> bucketIterator =
   storage
     .list(Storage.BucketListOption.prefix(BUCKET), Storage.BucketListOption.fields())
     .iterateAll()
     .iterator();
 while (!bucketIterator.hasNext()) {
  Thread.sleep(500);
  bucketIterator =
    storage
      .list(Storage.BucketListOption.prefix(BUCKET), Storage.BucketListOption.fields())
      .iterateAll()
      .iterator();
 }
 while (bucketIterator.hasNext()) {
  Bucket remoteBucket = bucketIterator.next();
  assertTrue(remoteBucket.getName().startsWith(BUCKET));
  assertNull(remoteBucket.getCreateTime());
  assertNull(remoteBucket.getSelfLink());
 }
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testListBucketRequesterPaysFails() throws InterruptedException {
 String projectId = remoteStorageHelper.getOptions().getProjectId();
 Iterator<Bucket> bucketIterator =
   storage
     .list(
       Storage.BucketListOption.prefix(BUCKET),
       Storage.BucketListOption.fields(),
       Storage.BucketListOption.userProject(projectId))
     .iterateAll()
     .iterator();
 while (!bucketIterator.hasNext()) {
  Thread.sleep(500);
  bucketIterator =
    storage
      .list(Storage.BucketListOption.prefix(BUCKET), Storage.BucketListOption.fields())
      .iterateAll()
      .iterator();
 }
 while (bucketIterator.hasNext()) {
  Bucket remoteBucket = bucketIterator.next();
  assertTrue(remoteBucket.getName().startsWith(BUCKET));
  assertNull(remoteBucket.getCreateTime());
  assertNull(remoteBucket.getSelfLink());
 }
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGetBucketSelectedFields() {
 Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID));
 assertEquals(BUCKET, remoteBucket.getName());
 assertNull(remoteBucket.getCreateTime());
 assertNotNull(remoteBucket.getGeneratedId());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGetBucketEmptyFields() {
 Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields());
 assertEquals(BUCKET, remoteBucket.getName());
 assertNull(remoteBucket.getCreateTime());
 assertNull(remoteBucket.getSelfLink());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGetBucketAllSelectedFields() {
 Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.values()));
 assertEquals(BUCKET, remoteBucket.getName());
 assertNotNull(remoteBucket.getCreateTime());
 assertNotNull(remoteBucket.getSelfLink());
}

代码示例来源:origin: googleapis/google-cloud-java

assertNotNull(bucket.getDefaultKmsKeyName());
assertTrue(bucket.getDefaultKmsKeyName().startsWith(kmsKeyOneResourcePath));
assertNull(bucket.getCreateTime());
assertNull(bucket.getSelfLink());

代码示例来源:origin: googleapis/google-cloud-java

@Override
 public void run() {
  Page<Bucket> buckets =
    storage.list(Storage.BucketListOption.prefix(BUCKET_NAME_PREFIX));
  for (Bucket bucket : buckets.iterateAll()) {
   if (bucket.getCreateTime() < olderThan) {
    try {
     for (Blob blob :
       bucket
         .list(
           BlobListOption.fields(
             Storage.BlobField.EVENT_BASED_HOLD,
             Storage.BlobField.TEMPORARY_HOLD))
         .iterateAll()) {
      if (blob.getEventBasedHold() == true || blob.getTemporaryHold() == true) {
       storage.update(
         blob.toBuilder()
           .setTemporaryHold(false)
           .setEventBasedHold(false)
           .build());
      }
     }
     forceDelete(storage, bucket.getName());
    } catch (Exception e) {
     // Ignore the exception, maybe the bucket is being deleted by someone else.
    }
   }
  }
 }
};

代码示例来源:origin: googleapis/google-cloud-java

assertEquals(OWNER, bucket.getOwner());
assertEquals(SELF_LINK, bucket.getSelfLink());
assertEquals(CREATE_TIME, bucket.getCreateTime());
assertEquals(CORS, bucket.getCors());
assertEquals(DEFAULT_ACL, bucket.getDefaultAcl());

代码示例来源:origin: com.google.cloud/google-cloud-storage

@Override
 public void run() {
  Page<Bucket> buckets =
    storage.list(Storage.BucketListOption.prefix(BUCKET_NAME_PREFIX));
  for (Bucket bucket : buckets.iterateAll()) {
   if (bucket.getCreateTime() < olderThan) {
    try {
     for (Blob blob :
       bucket
         .list(
           BlobListOption.fields(
             Storage.BlobField.EVENT_BASED_HOLD,
             Storage.BlobField.TEMPORARY_HOLD))
         .iterateAll()) {
      if (blob.getEventBasedHold() == true || blob.getTemporaryHold() == true) {
       storage.update(
         blob.toBuilder()
           .setTemporaryHold(false)
           .setEventBasedHold(false)
           .build());
      }
     }
     forceDelete(storage, bucket.getName());
    } catch (Exception e) {
     // Ignore the exception, maybe the bucket is being deleted by someone else.
    }
   }
  }
 }
};

相关文章