當前位置: 首頁>>代碼示例>>Java>>正文


Java Bucket.getName方法代碼示例

本文整理匯總了Java中com.amazonaws.services.s3.model.Bucket.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java Bucket.getName方法的具體用法?Java Bucket.getName怎麽用?Java Bucket.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.amazonaws.services.s3.model.Bucket的用法示例。


在下文中一共展示了Bucket.getName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findBucket

import com.amazonaws.services.s3.model.Bucket; //導入方法依賴的package包/類
private Optional<String> findBucket(final String environmentName) {
    AmazonS3Client s3Client = new AmazonS3Client();
    List<Bucket> buckets = s3Client.listBuckets();

    String envBucket = null;
    for (final Bucket bucket : buckets) {
        if (StringUtils.contains(bucket.getName(), ConfigConstants.CONFIG_BUCKET_KEY)) {
            String[] parts = bucket.getName().split("-");
            if (StringUtils.equalsIgnoreCase(environmentName, parts[0])) {
                envBucket = bucket.getName();
                break;
            }
        }
    }

    return Optional.ofNullable(envBucket);
}
 
開發者ID:Nike-Inc,項目名稱:cerberus-lifecycle-cli,代碼行數:18,代碼來源:CerberusModule.java

示例2: autoDiscoverBillsBucketName

import com.amazonaws.services.s3.model.Bucket; //導入方法依賴的package包/類
public static String autoDiscoverBillsBucketName(AmazonS3 s3Client, String awsAccountId) {
    String billFilePrefix = awsAccountId + AWSCsvBillParser.AWS_DETAILED_BILL_CSV_FILE_NAME_MID;
    for (Bucket bucket : s3Client.listBuckets()) {
        // For each bucket accessible to this client, try to search for files with the
        // 'billFilePrefix'
        ObjectListing objectListing = s3Client.listObjects(bucket.getName(), billFilePrefix);
        if (!objectListing.getObjectSummaries().isEmpty()) {
            // This means that this bucket contains zip files representing the detailed csv
            // bills.
            return bucket.getName();
        }
    }
    return null;
}
 
開發者ID:vmware,項目名稱:photon-model,代碼行數:15,代碼來源:AWSUtils.java

示例3: mapBucketToDiskState

import com.amazonaws.services.s3.model.Bucket; //導入方法依賴的package包/類
/**
 * Map an S3 bucket to a photon-model disk state.
 */
private DiskState mapBucketToDiskState(Bucket bucket, S3StorageEnumerationContext aws) {
    DiskState diskState = new DiskState();
    diskState.id = bucket.getName();
    diskState.name = bucket.getName();
    diskState.storageType = STORAGE_TYPE_S3;
    diskState.regionId = aws.regionsByBucketName.get(bucket.getName());
    diskState.authCredentialsLink = aws.endpointAuth.documentSelfLink;
    diskState.resourcePoolLink = aws.request.original.resourcePoolLink;
    diskState.endpointLink = aws.request.original.endpointLink;
    if (diskState.endpointLinks == null) {
        diskState.endpointLinks = new HashSet<>();
    }
    diskState.endpointLinks.add(aws.request.original.endpointLink);
    diskState.tenantLinks = aws.parentCompute.tenantLinks;
    diskState.computeHostLink = aws.parentCompute.documentSelfLink;
    diskState.tagLinks = new HashSet<>();

    if (bucket.getCreationDate() != null) {
        diskState.creationTimeMicros = TimeUnit.MILLISECONDS
                .toMicros(bucket.getCreationDate().getTime());
    }

    if (bucket.getOwner() != null && bucket.getOwner().getDisplayName() != null) {
        diskState.customProperties = new HashMap<>();
        diskState.customProperties.put(BUCKET_OWNER_NAME, bucket.getOwner().getDisplayName());
    }

    // Set internal type tag for all S3 disk states only if POST for the TagState was successful.
    if (aws.internalTypeTagSelfLink != null) {
        diskState.tagLinks.add(aws.internalTypeTagSelfLink);
    }

    return diskState;
}
 
開發者ID:vmware,項目名稱:photon-model,代碼行數:38,代碼來源:AWSS3StorageEnumerationAdapterService.java

示例4: getConfigBucketName

import com.amazonaws.services.s3.model.Bucket; //導入方法依賴的package包/類
protected String getConfigBucketName(String environmentName) {
    List<Bucket> buckets = amazonS3Client.listBuckets();

    for (final Bucket bucket : buckets) {
        if (StringUtils.contains(bucket.getName(), CERBERUS_CONFIG_BUCKET)) {
            String[] parts = bucket.getName().split("-");
            if (StringUtils.equalsIgnoreCase(environmentName, parts[0])) {
                return bucket.getName();
            }
        }
    }
    throw new RuntimeException("Failed to determine the config s3 bucket");
}
 
開發者ID:Nike-Inc,項目名稱:cerberus-serverless-components,代碼行數:14,代碼來源:CloudFrontLogEventHandler.java

示例5: provisionBackupBucketForRegion

import com.amazonaws.services.s3.model.Bucket; //導入方法依賴的package包/類
private String provisionBackupBucketForRegion(String region) {
    AmazonS3 s3 = AmazonS3ClientBuilder.standard()
            .withCredentials(getAWSCredentialsProviderChain())
            .withRegion(region)
            .build();

    Bucket bucket = s3.createBucket(getBackupBucketName(region));
    String bucketName = bucket.getName();
    log.info("Created bucket in region: {} with name: {}", region, bucketName);
    return bucketName;
}
 
開發者ID:Nike-Inc,項目名稱:cerberus-lifecycle-cli,代碼行數:12,代碼來源:CreateCerberusBackupOperation.java

示例6: listBuckets

import com.amazonaws.services.s3.model.Bucket; //導入方法依賴的package包/類
String listBuckets(String access_key, String secret_key, String endpoint) {

        AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key);
        AmazonS3 s3Client = new AmazonS3Client(credentials,
                new ClientConfiguration());
        s3Client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build());
        s3Client.setEndpoint(endpoint);
        String[] array = new String[10];

        String bucketlist = null;

        int i = 0;
        try {

            for (Bucket bucket : s3Client.listBuckets()) {
                bucketlist = bucketlist + " " + bucket.getName();
            }

        } catch (AmazonServiceException ase) {
            if (NewJFrame.gui) {
                mainFrame.jTextArea1.append("\n\nError Message:    " + ase.getMessage());
                mainFrame.jTextArea1.append("\nHTTP Status Code: " + ase.getStatusCode());
                mainFrame.jTextArea1.append("\nAWS Error Code:   " + ase.getErrorCode());
                mainFrame.jTextArea1.append("\nError Type:       " + ase.getErrorType());
                mainFrame.jTextArea1.append("\nRequest ID:       " + ase.getRequestId());
                calibrate();
            } else {
                System.out.print("\n\nError Message:    " + ase.getMessage());
                System.out.print("\nHTTP Status Code: " + ase.getStatusCode());
                System.out.print("\nAWS Error Code:   " + ase.getErrorCode());
                System.out.print("\nError Type:       " + ase.getErrorType());
                System.out.print("\nRequest ID:       " + ase.getRequestId());
            }

        } catch (Exception lsbuckets) {

            if (lsbuckets.getMessage().contains("peer not authenticated") || lsbuckets.getMessage().contains("hostname in certificate didn't match")) {
                if (NewJFrame.gui) {
                    mainFrame.jTextArea1.append("\nError: This program does not support non-trusted SSL certificates\n\nor your SSL certificates are incorrect.");
                } else {
                    System.out.print("\n\nError: This program does not support non-trusted SSL certificates\n\nor your SSL certificates are not correctly installed.");
                }
            }
        }
        String parse = null;

        if (bucketlist != null) {
            parse = bucketlist.replace("null", "");

        } else {
            parse = "no_bucket_found";
        }

        return parse;
    }
 
開發者ID:rusher81572,項目名稱:cloudExplorer,代碼行數:56,代碼來源:BucketClass.java


注:本文中的com.amazonaws.services.s3.model.Bucket.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。