本文整理了Java中com.google.api.services.storage.model.Bucket.getName()
方法的一些代码示例,展示了Bucket.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bucket.getName()
方法的具体详情如下:
包路径:com.google.api.services.storage.model.Bucket
类名称:Bucket
方法名:getName
暂无
代码示例来源:origin: googleapis/google-cloud-java
@Override
public Bucket lockRetentionPolicy(Bucket bucket, Map<Option, ?> options) {
Span span = startSpan(HttpStorageRpcSpans.SPAN_LOCK_RETENTION_POLICY);
Scope scope = tracer.withSpan(span);
try {
return storage
.buckets()
.lockRetentionPolicy(bucket.getName(), Option.IF_METAGENERATION_MATCH.getLong(options))
.setUserProject(Option.USER_PROJECT.getString(options))
.execute();
} catch (IOException ex) {
span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
throw translate(ex);
} finally {
scope.close();
span.end();
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public boolean delete(Bucket bucket, Map<Option, ?> options) {
Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_DELETE_BUCKET);
Scope scope = tracer.withSpan(span);
try {
storage
.buckets()
.delete(bucket.getName())
.setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options))
.setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options))
.setUserProject(Option.USER_PROJECT.getString(options))
.execute();
return true;
} catch (IOException ex) {
span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
StorageException serviceException = translate(ex);
if (serviceException.getCode() == HTTP_NOT_FOUND) {
return false;
}
throw serviceException;
} finally {
scope.close();
span.end();
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public Bucket get(Bucket bucket, Map<Option, ?> options) {
Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_GET_BUCKET);
Scope scope = tracer.withSpan(span);
try {
return storage
.buckets()
.get(bucket.getName())
.setProjection(DEFAULT_PROJECTION)
.setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options))
.setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options))
.setFields(Option.FIELDS.getString(options))
.setUserProject(Option.USER_PROJECT.getString(options))
.execute();
} catch (IOException ex) {
span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
StorageException serviceException = translate(ex);
if (serviceException.getCode() == HTTP_NOT_FOUND) {
return null;
}
throw serviceException;
} finally {
scope.close();
span.end();
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public Bucket patch(Bucket bucket, Map<Option, ?> options) {
Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_PATCH_BUCKET);
Scope scope = tracer.withSpan(span);
try {
return storage
.buckets()
.patch(bucket.getName(), bucket)
.setProjection(DEFAULT_PROJECTION)
.setPredefinedAcl(Option.PREDEFINED_ACL.getString(options))
.setPredefinedDefaultObjectAcl(Option.PREDEFINED_DEFAULT_OBJECT_ACL.getString(options))
.setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options))
.setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options))
.setUserProject(Option.USER_PROJECT.getString(options))
.execute();
} catch (IOException ex) {
span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
throw translate(ex);
} finally {
scope.close();
span.end();
}
}
代码示例来源:origin: google/google-api-java-client-samples
static void show(Bucket bucket) {
System.out.println("name: " + bucket.getName());
System.out.println("location: " + bucket.getLocation());
System.out.println("timeCreated: " + bucket.getTimeCreated());
System.out.println("owner: " + bucket.getOwner());
System.out.println("acl: " + bucket.getAcl());
}
代码示例来源:origin: googleapis/google-cloud-java
static BucketInfo fromPb(com.google.api.services.storage.model.Bucket bucketPb) {
Builder builder = new BuilderImpl(bucketPb.getName());
if (bucketPb.getId() != null) {
builder.setGeneratedId(bucketPb.getId());
代码示例来源:origin: com.google.cloud.bigdataoss/gcsio
/**
* See {@link GoogleCloudStorage#listBucketNames()} for details about expected behavior.
*/
@Override
public List<String> listBucketNames()
throws IOException {
logger.atFine().log("listBucketNames()");
List<Bucket> allBuckets = listBucketsInternal();
List<String> bucketNames = new ArrayList<>(allBuckets.size());
for (Bucket bucket : allBuckets) {
bucketNames.add(bucket.getName());
}
return bucketNames;
}
代码示例来源:origin: com.google.cloud.bigdataoss/gcsio
/** Helper for converting a StorageResourceId + Bucket into a GoogleCloudStorageItemInfo. */
public static GoogleCloudStorageItemInfo createItemInfoForBucket(
StorageResourceId resourceId, Bucket bucket) {
Preconditions.checkArgument(resourceId != null, "resourceId must not be null");
Preconditions.checkArgument(bucket != null, "bucket must not be null");
Preconditions.checkArgument(
resourceId.isBucket(), "resourceId must be a Bucket. resourceId: %s", resourceId);
Preconditions.checkArgument(
resourceId.getBucketName().equals(bucket.getName()),
"resourceId.getBucketName() must equal bucket.getName(): '%s' vs '%s'",
resourceId.getBucketName(), bucket.getName());
// For buckets, size is 0.
return new GoogleCloudStorageItemInfo(resourceId, bucket.getTimeCreated().getValue(),
0, bucket.getLocation(), bucket.getStorageClass());
}
代码示例来源:origin: pliablematter/simple-cloud-storage
/**
* List the buckets with the project
* (Project is configured in properties)
*
* @return
* @throws Exception
*/
public static List<String> listBuckets() throws Exception {
Storage storage = getStorage();
List<String> list = new ArrayList<String>();
List<Bucket> buckets = storage.buckets().list(getProperties().getProperty(PROJECT_ID_PROPERTY)).execute().getItems();
if(buckets != null) {
for(Bucket b : buckets) {
list.add(b.getName());
}
}
return list;
}
代码示例来源:origin: stackoverflow.com
List<Bucket> buckets=s3.listBuckets();
for(Bucket bucket:buckets){
Log.e("Bucket ","Name "+bucket.getName()+" Owner "+bucket.getOwner()+ " Date " + bucket.getCreationDate());
代码示例来源:origin: stackoverflow.com
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProtocol(Protocol.HTTP);
AmazonS3 conn = new AmazonS3Client(credentials, clientConfig);
conn.setEndpoint("correct end point");
Bucket bucket = conn.createBucket(bucketName);
ObjectListing objects = conn.listObjects(bucket.getName());
do {
for (S3ObjectSummary objectSummary : objects.getObjectSummaries()) {
System.out.println(objectSummary.getKey() + "\t" +
objectSummary.getSize() + "\t" +
StringUtils.fromDate(objectSummary.getLastModified()));
}
objects = conn.listNextBatchOfObjects(objects);
} while (objects.isTruncated());
代码示例来源:origin: org.apache.beam/beam-sdks-java-extensions-google-cloud-platform-core
} catch (GoogleJsonResponseException e) {
if (errorExtractor.accessDenied(e)) {
throw new AccessDeniedException(bucket.getName(), null, e.getMessage());
throw new FileAlreadyExistsException(bucket.getName(), null, e.getMessage());
String.format(
"Error while attempting to create bucket gs://%s for rproject %s",
bucket.getName(), projectId),
e);
代码示例来源:origin: com.google.cloud.bigdataoss/gcsio
/**
* See {@link GoogleCloudStorage#listBucketInfo()} for details about expected behavior.
*/
@Override
public List<GoogleCloudStorageItemInfo> listBucketInfo()
throws IOException {
logger.atFine().log("listBucketInfo()");
List<Bucket> allBuckets = listBucketsInternal();
List<GoogleCloudStorageItemInfo> bucketInfos = new ArrayList<>(allBuckets.size());
for (Bucket bucket : allBuckets) {
bucketInfos.add(new GoogleCloudStorageItemInfo(
new StorageResourceId(bucket.getName()), bucket.getTimeCreated().getValue(), 0,
bucket.getLocation(), bucket.getStorageClass()));
}
return bucketInfos;
}
代码示例来源:origin: com.google.cloud/google-cloud-storage
@Override
public Bucket lockRetentionPolicy(Bucket bucket, Map<Option, ?> options) {
Span span = startSpan(HttpStorageRpcSpans.SPAN_LOCK_RETENTION_POLICY);
Scope scope = tracer.withSpan(span);
try {
return storage
.buckets()
.lockRetentionPolicy(bucket.getName(), Option.IF_METAGENERATION_MATCH.getLong(options))
.setUserProject(Option.USER_PROJECT.getString(options))
.execute();
} catch (IOException ex) {
span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
throw translate(ex);
} finally {
scope.close();
span.end();
}
}
代码示例来源:origin: com.google.gcloud/gcloud-java-storage
@Override
public boolean delete(Bucket bucket, Map<Option, ?> options) {
try {
storage.buckets()
.delete(bucket.getName())
.setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options))
.setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options))
.execute();
return true;
} catch (IOException ex) {
StorageException serviceException = translate(ex);
if (serviceException.code() == HTTP_NOT_FOUND) {
return false;
}
throw serviceException;
}
}
代码示例来源:origin: com.google.gcloud/gcloud-java-storage
@Override
public Bucket patch(Bucket bucket, Map<Option, ?> options) {
try {
return storage.buckets()
.patch(bucket.getName(), bucket)
.setProjection(DEFAULT_PROJECTION)
.setPredefinedAcl(PREDEFINED_ACL.getString(options))
.setPredefinedDefaultObjectAcl(PREDEFINED_DEFAULT_OBJECT_ACL.getString(options))
.setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options))
.setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options))
.execute();
} catch (IOException ex) {
throw translate(ex);
}
}
代码示例来源:origin: com.google.gcloud/gcloud-java-storage
@Override
public Bucket get(Bucket bucket, Map<Option, ?> options) {
try {
return storage.buckets()
.get(bucket.getName())
.setProjection(DEFAULT_PROJECTION)
.setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options))
.setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options))
.setFields(FIELDS.getString(options))
.execute();
} catch (IOException ex) {
StorageException serviceException = translate(ex);
if (serviceException.code() == HTTP_NOT_FOUND) {
return null;
}
throw serviceException;
}
}
代码示例来源:origin: com.google.cloud/google-cloud-storage
@Override
public boolean delete(Bucket bucket, Map<Option, ?> options) {
Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_DELETE_BUCKET);
Scope scope = tracer.withSpan(span);
try {
storage
.buckets()
.delete(bucket.getName())
.setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options))
.setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options))
.setUserProject(Option.USER_PROJECT.getString(options))
.execute();
return true;
} catch (IOException ex) {
span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
StorageException serviceException = translate(ex);
if (serviceException.getCode() == HTTP_NOT_FOUND) {
return false;
}
throw serviceException;
} finally {
scope.close();
span.end();
}
}
代码示例来源:origin: com.google.cloud/google-cloud-storage
@Override
public Bucket get(Bucket bucket, Map<Option, ?> options) {
Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_GET_BUCKET);
Scope scope = tracer.withSpan(span);
try {
return storage
.buckets()
.get(bucket.getName())
.setProjection(DEFAULT_PROJECTION)
.setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options))
.setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options))
.setFields(Option.FIELDS.getString(options))
.setUserProject(Option.USER_PROJECT.getString(options))
.execute();
} catch (IOException ex) {
span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
StorageException serviceException = translate(ex);
if (serviceException.getCode() == HTTP_NOT_FOUND) {
return null;
}
throw serviceException;
} finally {
scope.close();
span.end();
}
}
代码示例来源:origin: com.google.cloud/google-cloud-storage
@Override
public Bucket patch(Bucket bucket, Map<Option, ?> options) {
Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_PATCH_BUCKET);
Scope scope = tracer.withSpan(span);
try {
return storage
.buckets()
.patch(bucket.getName(), bucket)
.setProjection(DEFAULT_PROJECTION)
.setPredefinedAcl(Option.PREDEFINED_ACL.getString(options))
.setPredefinedDefaultObjectAcl(Option.PREDEFINED_DEFAULT_OBJECT_ACL.getString(options))
.setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options))
.setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options))
.setUserProject(Option.USER_PROJECT.getString(options))
.execute();
} catch (IOException ex) {
span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage()));
throw translate(ex);
} finally {
scope.close();
span.end();
}
}
内容来源于网络,如有侵权,请联系作者删除!