当前位置: 首页>>代码示例>>Java>>正文


Java Buckets类代码示例

本文整理汇总了Java中com.google.api.services.storage.model.Buckets的典型用法代码示例。如果您正苦于以下问题:Java Buckets类的具体用法?Java Buckets怎么用?Java Buckets使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Buckets类属于com.google.api.services.storage.model包,在下文中一共展示了Buckets类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateBucketWithOptionsNormalOperation

import com.google.api.services.storage.model.Buckets; //导入依赖的package包/类
/**
 * Test successful operation of GoogleCloudStorage.create(String, CreateBucketOptions).
 */
@Test
public void testCreateBucketWithOptionsNormalOperation()
    throws IOException {
  final Bucket[] bucketWithOptions = new Bucket[1];
  when(mockStorage.buckets()).thenReturn(mockStorageBuckets);
  when(mockBackOffFactory.newBackOff()).thenReturn(mockBackOff);

  final Storage.Buckets.Insert finalMockInsert = mockStorageBucketsInsert;
  when(mockStorageBuckets.insert(eq(PROJECT_ID), any(Bucket.class)))
      .thenAnswer(new Answer<Storage.Buckets.Insert>() {
        @Override public Storage.Buckets.Insert answer(InvocationOnMock invocation) {
          bucketWithOptions[0] = (Bucket) invocation.getArguments()[1];
          return finalMockInsert;
        }});
  gcs.create(BUCKET_NAME, new CreateBucketOptions("some-location", "storage-class"));

  assertEquals(BUCKET_NAME, bucketWithOptions[0].getName());
  assertEquals("some-location", bucketWithOptions[0].getLocation());
  assertEquals("storage-class", bucketWithOptions[0].getStorageClass());

  verify(mockStorage).buckets();
  verify(mockBackOffFactory).newBackOff();
  verify(mockStorageBuckets).insert(eq(PROJECT_ID), any(Bucket.class));
  verify(mockStorageBucketsInsert).execute();
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:29,代码来源:GoogleCloudStorageTest.java

示例2: setupMocksForListBuckets

import com.google.api.services.storage.model.Buckets; //导入依赖的package包/类
/**
 * Sets up mocks for a list-bucket operation.
 */
private void setupMocksForListBuckets()
    throws IOException {
  when(mockStorage.buckets()).thenReturn(mockStorageBuckets);
  when(mockStorageBuckets.list(eq(PROJECT_ID))).thenReturn(mockStorageBucketsList);
  when(mockStorageBucketsList.execute())
      .thenReturn(new Buckets()
          .setItems(ImmutableList.of(
              createTestBucket(0),
              createTestBucket(1)))
          .setNextPageToken("token0"))
      .thenReturn(new Buckets()
          .setItems(ImmutableList.of(
              createTestBucket(2)))
          .setNextPageToken(null));
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:19,代码来源:GoogleCloudStorageTest.java

示例3: getPotentialStagingLocations

import com.google.api.services.storage.model.Buckets; //导入依赖的package包/类
/**
 * Gets a collection of potential Staging Locations.
 */
public SortedSet<String> getPotentialStagingLocations(String projectId) throws IOException {
  SortedSet<String> result = new TreeSet<>();
  Buckets buckets = gcsClient.buckets().list(projectId).execute();
  List<Bucket> bucketList = buckets.getItems();
  if (bucketList != null) {
    for (Bucket bucket : bucketList) {
      result.add(GCS_PREFIX + bucket.getName());
    }
  }
  return result;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:15,代码来源:GcsDataflowProjectClient.java

示例4: create

import com.google.api.services.storage.model.Buckets; //导入依赖的package包/类
/**
 * See {@link GoogleCloudStorage#create(String, CreateBucketOptions)} for
 * details about expected behavior.
 */
@Override
public void create(String bucketName, CreateBucketOptions options)
    throws IOException {
  LOG.debug("create({})", bucketName);
  Preconditions.checkArgument(!Strings.isNullOrEmpty(bucketName),
      "bucketName must not be null or empty");
  Preconditions.checkNotNull(options, "options must not be null");
  Preconditions.checkNotNull(storageOptions.getProjectId(), "projectId must not be null");

  Bucket bucket = new Bucket();
  bucket.setName(bucketName);
  bucket.setLocation(options.getLocation());
  bucket.setStorageClass(options.getStorageClass());
  Storage.Buckets.Insert insertBucket =
      gcs.buckets().insert(storageOptions.getProjectId(), bucket);
  // TODO(user): To match the behavior of throwing FileNotFoundException for 404, we probably
  // want to throw org.apache.commons.io.FileExistsException for 409 here.
  try {
    ResilientOperation.retry(
        ResilientOperation.getGoogleRequestCallable(insertBucket),
        backOffFactory.newBackOff(),
        rateLimitedRetryDeterminer,
        IOException.class,
        sleeper);
  } catch (InterruptedException e) {
    throw new IOException(e);  // From sleep
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:33,代码来源:GoogleCloudStorageImpl.java


注:本文中的com.google.api.services.storage.model.Buckets类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。