Search in sources :

Example 71 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.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();
}
Also used : XmlWriter(com.amazonaws.services.s3.internal.XmlWriter)

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

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

the class ServiceUtilsTest method skipMd5CheckPerRequestTest.

@Test
public void skipMd5CheckPerRequestTest() throws Throwable {
    final S3ClientOptions clientOptions = S3ClientOptions.builder().skipContentMd5Check(true).build();
    assertTrue(ServiceUtils.skipMd5CheckPerRequest(null, clientOptions));
    System.setProperty("com.amazonaws.services.s3.disableGetObjectMD5Validation", "true");
    assertTrue(ServiceUtils.skipMd5CheckPerRequest(null));
    System.clearProperty("com.amazonaws.services.s3.disableGetObjectMD5Validation");
    GetObjectRequest getObjectRequest = new GetObjectRequest("bucket", "key");
    getObjectRequest.setRange(100);
    assertTrue(ServiceUtils.skipMd5CheckPerRequest(getObjectRequest));
    getObjectRequest = new GetObjectRequest("bucket", "key");
    getObjectRequest.setSSECustomerKey(new SSECustomerKey("testKey"));
    assertTrue(ServiceUtils.skipMd5CheckPerRequest(getObjectRequest));
    getObjectRequest = new GetObjectRequest("bucket", "key");
    assertFalse(ServiceUtils.skipMd5CheckPerRequest(getObjectRequest));
    PutObjectRequest putObjectRequest = new PutObjectRequest("bucket", "key", File.createTempFile("test", "test2"));
    final ObjectMetadata metadata = new ObjectMetadata();
    metadata.setSSEAlgorithm(SSEAlgorithm.KMS.toString());
    putObjectRequest.setMetadata(metadata);
    assertTrue(ServiceUtils.skipMd5CheckPerRequest(putObjectRequest));
    putObjectRequest = new PutObjectRequest("bucket", "key", File.createTempFile("test", "test2"));
    putObjectRequest.setSSECustomerKey(new SSECustomerKey("testKey"));
    assertTrue(ServiceUtils.skipMd5CheckPerRequest(putObjectRequest));
    putObjectRequest = new PutObjectRequest("bucket", "key", File.createTempFile("test", "test2"));
    assertFalse(ServiceUtils.skipMd5CheckPerRequest(putObjectRequest));
    UploadPartRequest partRequest = new UploadPartRequest();
    partRequest.setSSECustomerKey(new SSECustomerKey("testKey"));
    assertTrue(ServiceUtils.skipMd5CheckPerRequest(partRequest));
    partRequest = new UploadPartRequest();
    assertFalse(ServiceUtils.skipMd5CheckPerRequest(partRequest));
}
Also used : SSECustomerKey(com.amazonaws.services.s3.model.SSECustomerKey) S3ClientOptions(com.amazonaws.services.s3.S3ClientOptions) UploadPartRequest(com.amazonaws.services.s3.model.UploadPartRequest) GetObjectRequest(com.amazonaws.services.s3.model.GetObjectRequest) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata) PutObjectRequest(com.amazonaws.services.s3.model.PutObjectRequest) Test(org.junit.Test)

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

use of com.amazonaws.services.s3.model in project aws-doc-sdk-examples by awsdocs.

the class DocumentText method main.

public static void main(String[] arg) throws Exception {
    // The S3 bucket and document
    String document = "";
    String bucket = "";
    AmazonS3 s3client = AmazonS3ClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration("https://s3.amazonaws.com", "us-east-1")).build();
    // Get the document from S3
    com.amazonaws.services.s3.model.S3Object s3object = s3client.getObject(bucket, document);
    S3ObjectInputStream inputStream = s3object.getObjectContent();
    BufferedImage image = ImageIO.read(inputStream);
    // Call DetectDocumentText
    EndpointConfiguration endpoint = new EndpointConfiguration("https://textract.us-east-1.amazonaws.com", "us-east-1");
    AmazonTextract client = AmazonTextractClientBuilder.standard().withEndpointConfiguration(endpoint).build();
    DetectDocumentTextRequest request = new DetectDocumentTextRequest().withDocument(new Document().withS3Object(new S3Object().withName(document).withBucket(bucket)));
    DetectDocumentTextResult result = client.detectDocumentText(request);
    // Create frame and panel.
    JFrame frame = new JFrame("RotateImage");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    DocumentText panel = new DocumentText(result, image);
    panel.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
    frame.setContentPane(panel);
    frame.pack();
    frame.setVisible(true);
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) S3ObjectInputStream(com.amazonaws.services.s3.model.S3ObjectInputStream) DetectDocumentTextRequest(com.amazonaws.services.textract.model.DetectDocumentTextRequest) Document(com.amazonaws.services.textract.model.Document) AmazonTextract(com.amazonaws.services.textract.AmazonTextract) BufferedImage(java.awt.image.BufferedImage) DetectDocumentTextResult(com.amazonaws.services.textract.model.DetectDocumentTextResult) EndpointConfiguration(com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration) S3Object(com.amazonaws.services.textract.model.S3Object)

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

use of com.amazonaws.services.s3.model in project aws-doc-sdk-examples by awsdocs.

the class AnalyzeDocument method main.

public static void main(String[] arg) throws Exception {
    // The S3 bucket and document
    String document = "";
    String bucket = "";
    AmazonS3 s3client = AmazonS3ClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration("https://s3.amazonaws.com", "us-east-1")).build();
    // Get the document from S3
    com.amazonaws.services.s3.model.S3Object s3object = s3client.getObject(bucket, document);
    S3ObjectInputStream inputStream = s3object.getObjectContent();
    BufferedImage image = ImageIO.read(inputStream);
    // Call AnalyzeDocument
    EndpointConfiguration endpoint = new EndpointConfiguration("https://textract.us-east-1.amazonaws.com", "us-east-1");
    AmazonTextract client = AmazonTextractClientBuilder.standard().withEndpointConfiguration(endpoint).build();
    AnalyzeDocumentRequest request = new AnalyzeDocumentRequest().withFeatureTypes("TABLES", "FORMS").withDocument(new Document().withS3Object(new S3Object().withName(document).withBucket(bucket)));
    AnalyzeDocumentResult result = client.analyzeDocument(request);
    // Create frame and panel.
    JFrame frame = new JFrame("RotateImage");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    AnalyzeDocument panel = new AnalyzeDocument(result, image);
    panel.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
    frame.setContentPane(panel);
    frame.pack();
    frame.setVisible(true);
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) S3ObjectInputStream(com.amazonaws.services.s3.model.S3ObjectInputStream) Document(com.amazonaws.services.textract.model.Document) AmazonTextract(com.amazonaws.services.textract.AmazonTextract) BufferedImage(java.awt.image.BufferedImage) AnalyzeDocumentResult(com.amazonaws.services.textract.model.AnalyzeDocumentResult) EndpointConfiguration(com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration) S3Object(com.amazonaws.services.textract.model.S3Object) AnalyzeDocumentRequest(com.amazonaws.services.textract.model.AnalyzeDocumentRequest)

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

use of com.amazonaws.services.s3.model in project xtext-core by eclipse.

the class Bug299395TestLanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Bug299395Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Bug299395Package.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
            case Bug299395Package.SUB_MODEL:
                sequence_SubModel(context, (SubModel) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) SubModel(org.eclipse.xtext.parsetree.reconstr.bug299395.SubModel) Model(org.eclipse.xtext.parsetree.reconstr.bug299395.Model) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage) SubModel(org.eclipse.xtext.parsetree.reconstr.bug299395.SubModel)

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