Search in sources :

Example 66 with com.amazonaws.services.s3.model

use of com.amazonaws.services.s3.model in project aws-sdk-android by aws-amplify.

the class AmazonS3Client method getObjectMetadata.

/*
     * (non-Javadoc)
     * @see
     * com.amazonaws.services.s3.AmazonS3#getObjectMetadata(com.amazonaws.services
     * .s3.model.GetObjectMetadataRequest)
     */
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException {
    assertParameterNotNull(getObjectMetadataRequest, "The GetObjectMetadataRequest parameter must be specified when requesting an object's metadata");
    final String bucketName = getObjectMetadataRequest.getBucketName();
    final String key = getObjectMetadataRequest.getKey();
    final String versionId = getObjectMetadataRequest.getVersionId();
    assertParameterNotNull(bucketName, "The bucket name parameter must be specified when requesting an object's metadata");
    assertParameterNotNull(key, "The key parameter must be specified when requesting an object's metadata");
    final Request<GetObjectMetadataRequest> request = createRequest(bucketName, key, getObjectMetadataRequest, HttpMethodName.HEAD);
    if (versionId != null) {
        request.addParameter("versionId", versionId);
    }
    populateRequesterPaysHeader(request, getObjectMetadataRequest.isRequesterPays());
    addPartNumberIfNotNull(request, getObjectMetadataRequest.getPartNumber());
    populateSSE_C(request, getObjectMetadataRequest.getSSECustomerKey());
    return invoke(request, new S3MetadataResponseHandler(), bucketName, key);
}
Also used : S3MetadataResponseHandler(com.amazonaws.services.s3.internal.S3MetadataResponseHandler)

Example 67 with com.amazonaws.services.s3.model

use of com.amazonaws.services.s3.model in project aws-sdk-android by aws-amplify.

the class AmazonS3Client method completeMultipartUpload.

/*
     * (non-Javadoc)
     * @see
     * com.amazonaws.services.s3.AmazonS3#completeMultipartUpload(com.amazonaws
     * .services.s3.model.CompleteMultipartUploadRequest)
     */
@Override
public CompleteMultipartUploadResult completeMultipartUpload(CompleteMultipartUploadRequest completeMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
    assertParameterNotNull(completeMultipartUploadRequest, "The request parameter must be specified when completing a multipart upload");
    final String bucketName = completeMultipartUploadRequest.getBucketName();
    final String key = completeMultipartUploadRequest.getKey();
    final String uploadId = completeMultipartUploadRequest.getUploadId();
    assertParameterNotNull(bucketName, "The bucket name parameter must be specified when completing a multipart upload");
    assertParameterNotNull(key, "The key parameter must be specified when completing a multipart upload");
    assertParameterNotNull(uploadId, "The upload ID parameter must be specified when completing a multipart upload");
    assertParameterNotNull(completeMultipartUploadRequest.getPartETags(), "The part ETags parameter must be specified when completing a multipart upload");
    int retries = 0;
    CompleteMultipartUploadHandler handler;
    do {
        final Request<CompleteMultipartUploadRequest> request = createRequest(bucketName, key, completeMultipartUploadRequest, HttpMethodName.POST);
        request.addParameter("uploadId", uploadId);
        populateRequesterPaysHeader(request, completeMultipartUploadRequest.isRequesterPays());
        final byte[] xml = RequestXmlFactory.convertToXmlByteArray(completeMultipartUploadRequest.getPartETags());
        request.addHeader("Content-Type", "application/xml");
        request.addHeader("Content-Length", String.valueOf(xml.length));
        request.setContent(new ByteArrayInputStream(xml));
        @SuppressWarnings("unchecked") final ResponseHeaderHandlerChain<CompleteMultipartUploadHandler> responseHandler = new ResponseHeaderHandlerChain<CompleteMultipartUploadHandler>(// xml payload unmarshaller
        new Unmarshallers.CompleteMultipartUploadResultUnmarshaller(), // header handlers
        new ServerSideEncryptionHeaderHandler<CompleteMultipartUploadHandler>(), new ObjectExpirationHeaderHandler<CompleteMultipartUploadHandler>(), new S3VersionHeaderHandler<CompleteMultipartUploadHandler>(), new S3RequesterChargedHeaderHandler<CompleteMultipartUploadHandler>());
        handler = invoke(request, responseHandler, bucketName, key);
        if (handler.getCompleteMultipartUploadResult() != null) {
            return handler.getCompleteMultipartUploadResult();
        }
    } while (shouldRetryCompleteMultipartUpload(completeMultipartUploadRequest, handler.getAmazonS3Exception(), retries++));
    throw handler.getAmazonS3Exception();
}
Also used : Unmarshallers(com.amazonaws.services.s3.model.transform.Unmarshallers) ByteArrayInputStream(java.io.ByteArrayInputStream) CompleteMultipartUploadHandler(com.amazonaws.services.s3.model.transform.XmlResponsesSaxParser.CompleteMultipartUploadHandler) ResponseHeaderHandlerChain(com.amazonaws.services.s3.internal.ResponseHeaderHandlerChain)

Example 68 with com.amazonaws.services.s3.model

use of com.amazonaws.services.s3.model in project aws-sdk-android by aws-amplify.

the class AmazonS3Client method createBucket.

/*
     * (non-Javadoc)
     * @see
     * com.amazonaws.services.s3.AmazonS3#createBucket(com.amazonaws.services
     * .s3.model.CreateBucketRequest)
     */
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    assertParameterNotNull(createBucketRequest, "The CreateBucketRequest parameter must be specified when creating a bucket");
    String bucketName = createBucketRequest.getBucketName();
    String region = createBucketRequest.getRegion();
    assertParameterNotNull(bucketName, "The bucket name parameter must be specified when creating a bucket");
    if (bucketName != null) {
        bucketName = bucketName.trim();
    }
    BucketNameUtils.validateBucketName(bucketName);
    final Request<CreateBucketRequest> request = createRequest(bucketName, null, createBucketRequest, HttpMethodName.PUT);
    if (createBucketRequest.getAccessControlList() != null) {
        addAclHeaders(request, createBucketRequest.getAccessControlList());
    } else if (createBucketRequest.getCannedAcl() != null) {
        request.addHeader(Headers.S3_CANNED_ACL, createBucketRequest.getCannedAcl().toString());
    }
    /*
         * If we're talking to a region-specific endpoint other than the US, we
         * *must* specify a location constraint. Try to derive the region from
         * the endpoint.
         */
    if (!(this.endpoint.getHost().equals(Constants.S3_HOSTNAME)) && (region == null || region.isEmpty())) {
        try {
            region = RegionUtils.getRegionByEndpoint(this.endpoint.getHost()).getName();
        } catch (final IllegalArgumentException exception) {
        // Endpoint does not correspond to a known region; send the
        // request with no location constraint and hope for the best.
        }
    }
    /*
         * We can only send the CreateBucketConfiguration if we're *not*
         * creating a bucket in the US region.
         */
    if (region != null && !StringUtils.upperCase(region).equals(Region.US_Standard.toString())) {
        final XmlWriter xml = new XmlWriter();
        xml.start("CreateBucketConfiguration", "xmlns", Constants.XML_NAMESPACE);
        xml.start("LocationConstraint").value(region).end();
        xml.end();
        final byte[] bytes = xml.getBytes();
        request.addHeader(Headers.CONTENT_LENGTH, String.valueOf(bytes.length));
        request.setContent(new ByteArrayInputStream(bytes));
    }
    invoke(request, voidResponseHandler, bucketName, null);
    return new Bucket(bucketName);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) XmlWriter(com.amazonaws.services.s3.internal.XmlWriter)

Example 69 with com.amazonaws.services.s3.model

use of com.amazonaws.services.s3.model in project aws-sdk-android by aws-amplify.

the class PresignedUrlIntegrationTest method testGetUrlWithContentType.

/**
 * Tests a simple pre-signed GET URL with content type header.
 */
private void testGetUrlWithContentType(String bucketName, String key) throws Exception {
    GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, key);
    request.setContentType("model/vrm");
    HttpURLConnection connection = connectToPresignedUrlWithHeaders(request);
    assertEquals(200, connection.getResponseCode());
    assertFileEqualsStream(file, connection.getInputStream());
}
Also used : GeneratePresignedUrlRequest(com.amazonaws.services.s3.model.GeneratePresignedUrlRequest) HttpURLConnection(java.net.HttpURLConnection)

Example 70 with com.amazonaws.services.s3.model

use of com.amazonaws.services.s3.model in project aws-sdk-android by aws-amplify.

the class BucketConfigurationXmlFactory method convertToXmlByteArray.

/**
 * Converts the specified
 * {@link com.amazonaws.services.s3.model.metrics.MetricsConfiguration}
 * object to an XML fragment that can be sent to Amazon S3.
 *
 * @param config The
 *            {@link com.amazonaws.services.s3.model.metrics.MetricsConfiguration}
 *            .
 */
/*
     * <MetricsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
     * <Id>metrics-id</Id> <Filter> <!-- A filter should have only one of
     * Prefix, Tag or And--> <Prefix>prefix</Prefix> <Tag> <Key>Project</Key>
     * <Value>Foo</Value> </Tag> <And> <Prefix>documents/</Prefix> <Tag>
     * <Key>foo</Key> <Value>bar</Value> </Tag> </And> </Filter>
     * </MetricsConfiguration>
     */
public byte[] convertToXmlByteArray(MetricsConfiguration config) throws AmazonClientException {
    final XmlWriter xml = new XmlWriter();
    xml.start("MetricsConfiguration", "xmlns", Constants.XML_NAMESPACE);
    addParameterIfNotNull(xml, "Id", config.getId());
    writeMetricsFilter(xml, config.getFilter());
    xml.end();
    return xml.getBytes();
}
Also used : XmlWriter(com.amazonaws.services.s3.internal.XmlWriter)

Aggregations

Test (org.junit.Test)49 Model (org.eclipse.xtext.valueconverter.bug250313.Model)30 Model (com.google.cloud.aiplatform.v1.Model)16 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)16 Model (com.google.cloud.automl.v1.Model)16 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)16 LocationName (com.google.cloud.aiplatform.v1.LocationName)14 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)14 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)14 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)14 InputDataConfig (com.google.cloud.aiplatform.v1.InputDataConfig)13 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)13 ByteArrayInputStream (java.io.ByteArrayInputStream)13 FilterSplit (com.google.cloud.aiplatform.v1.FilterSplit)11 FractionSplit (com.google.cloud.aiplatform.v1.FractionSplit)11 PredefinedSplit (com.google.cloud.aiplatform.v1.PredefinedSplit)11 TimestampSplit (com.google.cloud.aiplatform.v1.TimestampSplit)11 Status (com.google.rpc.Status)11 Model (com.microsoft.z3.Model)11 IOException (java.io.IOException)11