use of com.amazonaws.services.s3.model.analytics.StorageClassAnalysis in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method convertToXmlByteArray.
/**
* Converts the specified
* {@link com.amazonaws.services.s3.model.analytics.AnalyticsConfiguration}
* object to an XML fragment that can be sent to Amazon S3.
*
* @param config The
* {@link com.amazonaws.services.s3.model.analytics.AnalyticsConfiguration}
*/
/*
* <AnalyticsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
* <Id>XXX</Id> <Filter> <And> <Prefix>documents/</Prefix> <Tag>
* <Key>foo</Key> <Value>bar</Value> </Tag> </And> </Filter>
* <StorageClassAnalysis> <DataExport>
* <OutputSchemaVersion>1</OutputSchemaVersion> <Destination>
* <S3BucketDestination> <Format>CSV</Format>
* <BucketAccountId>123456789</BucketAccountId>
* <Bucket>destination-bucket</Bucket> <Prefix>destination-prefix</Prefix>
* </S3BucketDestination> </Destination> </DataExport>
* </StorageClassAnalysis> </AnalyticsConfiguration>
*/
public byte[] convertToXmlByteArray(AnalyticsConfiguration config) throws AmazonClientException {
final XmlWriter xml = new XmlWriter();
xml.start("AnalyticsConfiguration", "xmlns", Constants.XML_NAMESPACE);
addParameterIfNotNull(xml, "Id", config.getId());
writeAnalyticsFilter(xml, config.getFilter());
writeStorageClassAnalysis(xml, config.getStorageClassAnalysis());
xml.end();
return xml.getBytes();
}
use of com.amazonaws.services.s3.model.analytics.StorageClassAnalysis in project aws-sdk-android by aws-amplify.
the class BucketAnalyticsSaxUnmarshallerTest method getResponse_unmarshalls_properly.
@Test
public void getResponse_unmarshalls_properly() throws Exception {
AnalyticsConfiguration configuration = parseGetAnalyticsConfigurationResponse(GET_RESPONSE).getAnalyticsConfiguration();
AnalyticsFilter filter = configuration.getFilter();
StorageClassAnalysis storageClassAnalysis = configuration.getStorageClassAnalysis();
assertEquals("analytics-id", configuration.getId());
assertNotNull(filter);
List<AnalyticsFilterPredicate> operands = ((AnalyticsAndOperator) filter.getPredicate()).getOperands();
assertEquals(2, operands.size());
assertEquals("documents/", ((AnalyticsPrefixPredicate) operands.get(0)).getPrefix());
assertEquals("foo", ((AnalyticsTagPredicate) operands.get(1)).getTag().getKey());
assertEquals("bar", ((AnalyticsTagPredicate) operands.get(1)).getTag().getValue());
assertEquals(StorageClassAnalysisSchemaVersion.V_1.toString(), storageClassAnalysis.getDataExport().getOutputSchemaVersion());
AnalyticsS3BucketDestination s3BucketDestination = storageClassAnalysis.getDataExport().getDestination().getS3BucketDestination();
assertEquals(AnalyticsS3ExportFileFormat.CSV.toString(), s3BucketDestination.getFormat());
assertEquals("123456789", s3BucketDestination.getBucketAccountId());
assertEquals("arn:aws:s3:::destination-bucket", s3BucketDestination.getBucketArn());
assertEquals("destination-prefix", s3BucketDestination.getPrefix());
}
use of com.amazonaws.services.s3.model.analytics.StorageClassAnalysis in project aws-sdk-android by aws-amplify.
the class BucketAnalyticsSaxUnmarshallerTest method listResponse_unmarshalls_properly.
@Test
public void listResponse_unmarshalls_properly() throws Exception {
ListBucketAnalyticsConfigurationsResult result = parseListAnalyticsConfigurationResponse(LIST_RESPONSE);
assertTrue(result.isTruncated());
assertEquals("token1", result.getContinuationToken());
assertEquals("token2", result.getNextContinuationToken());
List<AnalyticsConfiguration> analyticsConfigurationList = result.getAnalyticsConfigurationList();
assertEquals(2, analyticsConfigurationList.size());
// Test first analytics configuration
AnalyticsConfiguration configuration = analyticsConfigurationList.get(0);
AnalyticsFilter filter = configuration.getFilter();
StorageClassAnalysis storageClassAnalysis = configuration.getStorageClassAnalysis();
assertEquals("XXX", configuration.getId());
assertNotNull(filter);
List<AnalyticsFilterPredicate> operands = ((AnalyticsAndOperator) filter.getPredicate()).getOperands();
assertEquals(2, operands.size());
assertEquals("documents/", ((AnalyticsPrefixPredicate) operands.get(0)).getPrefix());
assertEquals("foo", ((AnalyticsTagPredicate) operands.get(1)).getTag().getKey());
assertEquals("bar", ((AnalyticsTagPredicate) operands.get(1)).getTag().getValue());
assertEquals(StorageClassAnalysisSchemaVersion.V_1.toString(), storageClassAnalysis.getDataExport().getOutputSchemaVersion());
AnalyticsS3BucketDestination s3BucketDestination = storageClassAnalysis.getDataExport().getDestination().getS3BucketDestination();
assertEquals(AnalyticsS3ExportFileFormat.CSV.toString(), s3BucketDestination.getFormat());
assertEquals("123456789", s3BucketDestination.getBucketAccountId());
assertEquals("arn:aws:s3:::destination-bucket", s3BucketDestination.getBucketArn());
assertEquals("destination-prefix", s3BucketDestination.getPrefix());
// Test second analytics configuration
configuration = analyticsConfigurationList.get(1);
storageClassAnalysis = configuration.getStorageClassAnalysis();
assertEquals("YYY", configuration.getId());
assertEquals("prefix", ((AnalyticsPrefixPredicate) configuration.getFilter().getPredicate()).getPrefix());
assertEquals("V_2", storageClassAnalysis.getDataExport().getOutputSchemaVersion());
s3BucketDestination = storageClassAnalysis.getDataExport().getDestination().getS3BucketDestination();
assertEquals("JSON", s3BucketDestination.getFormat());
assertEquals("123", s3BucketDestination.getBucketAccountId());
assertEquals("arn:aws:s3:::bucket2", s3BucketDestination.getBucketArn());
assertEquals("prefix2", s3BucketDestination.getPrefix());
}
use of com.amazonaws.services.s3.model.analytics.StorageClassAnalysis in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method writeStorageClassAnalysis.
private void writeStorageClassAnalysis(XmlWriter xml, StorageClassAnalysis storageClassAnalysis) {
if (storageClassAnalysis == null) {
return;
}
xml.start("StorageClassAnalysis");
if (storageClassAnalysis.getDataExport() != null) {
final StorageClassAnalysisDataExport dataExport = storageClassAnalysis.getDataExport();
xml.start("DataExport");
addParameterIfNotNull(xml, "OutputSchemaVersion", dataExport.getOutputSchemaVersion());
writeAnalyticsExportDestination(xml, dataExport.getDestination());
// </DataExport>
xml.end();
}
// </StorageClassAnalysis>
xml.end();
}
Aggregations