Search in sources :

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

use of com.amazonaws.services.s3.model in project java-automl by googleapis.

the class PredictionApiIT method setUp.

@Before
public void setUp() throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Verify that the model is deployed for prediction
    try (AutoMlClient client = AutoMlClient.create()) {
        ModelName modelFullId = ModelName.of(PROJECT_ID, "us-central1", modelId);
        Model model = client.getModel(modelFullId);
        if (model.getDeploymentState() == Model.DeploymentState.UNDEPLOYED) {
            // Deploy the model if not deployed
            DeployModelRequest request = DeployModelRequest.newBuilder().setName(modelFullId.toString()).build();
            Future future = client.deployModelAsync(request);
            future.get(30, TimeUnit.MINUTES);
        }
    }
    bout = new ByteArrayOutputStream();
    out = new PrintStream(bout);
    System.setOut(out);
}
Also used : DeployModelRequest(com.google.cloud.automl.v1beta1.DeployModelRequest) PrintStream(java.io.PrintStream) ModelName(com.google.cloud.automl.v1beta1.ModelName) Model(com.google.cloud.automl.v1beta1.Model) Future(java.util.concurrent.Future) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AutoMlClient(com.google.cloud.automl.v1beta1.AutoMlClient) Before(org.junit.Before)

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

use of com.amazonaws.services.s3.model in project pxf by greenplum-db.

the class S3SelectAccessor method getCSVInput.

/**
 * Returns a {@link com.amazonaws.services.s3.model.CSVInput}
 * object with parsed values from the request context.
 *
 * @param context the request context
 * @return a {@link CSVInput}
 */
CSVInput getCSVInput(RequestContext context) {
    CSVInput csvInput = new CSVInput();
    GreenplumCSV csv = context.getGreenplumCSV();
    String fileHeaderInfo = context.getOption(FILE_HEADER_INFO);
    if (fileHeaderInfo != null) {
        LOG.debug("With CSV FileHeaderInfo '{}'", fileHeaderInfo);
        csvInput.setFileHeaderInfo(fileHeaderInfo);
    }
    if (csv.getDelimiter() != null) {
        LOG.debug("With CSV field delimiter '{}'", csv.getDelimiter());
        csvInput.setFieldDelimiter(csv.getDelimiter());
    }
    if (csv.getNewline() != null) {
        LOG.debug("With CSV NEWLINE '{}'", csv.getNewline());
        csvInput.setRecordDelimiter(csv.getNewline());
    }
    if (csv.getEscape() != null) {
        LOG.debug("With CSV quote escape character '{}'", csv.getEscape());
        csvInput.setQuoteEscapeCharacter(csv.getEscape());
    }
    LOG.debug("With CSV quote character '{}'", csv.getQuote());
    csvInput.setQuoteCharacter(csv.getQuote());
    return csvInput;
}
Also used : GreenplumCSV(org.greenplum.pxf.api.model.GreenplumCSV) CSVInput(com.amazonaws.services.s3.model.CSVInput)

Example 63 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 setBucketLifecycleConfiguration.

/*
     * (non-Javadoc)
     * @see
     * com.amazonaws.services.s3.AmazonS3#setBucketLifecycleConfiguration(com
     * .amazonaws.services.s3.model.SetBucketLifecycleConfigurationRequest)
     */
@Override
public void setBucketLifecycleConfiguration(SetBucketLifecycleConfigurationRequest setBucketLifecycleConfigurationRequest) {
    assertParameterNotNull(setBucketLifecycleConfigurationRequest, "The set bucket lifecycle configuration request object must be specified.");
    final String bucketName = setBucketLifecycleConfigurationRequest.getBucketName();
    final BucketLifecycleConfiguration bucketLifecycleConfiguration = setBucketLifecycleConfigurationRequest.getLifecycleConfiguration();
    assertParameterNotNull(bucketName, "The bucket name parameter must be specified when setting bucket lifecycle configuration.");
    assertParameterNotNull(bucketLifecycleConfiguration, "The lifecycle configuration parameter must be specified when setting bucket lifecycle configuration.");
    final Request<SetBucketLifecycleConfigurationRequest> request = createRequest(bucketName, null, setBucketLifecycleConfigurationRequest, HttpMethodName.PUT);
    request.addParameter("lifecycle", null);
    final byte[] content = new BucketConfigurationXmlFactory().convertToXmlByteArray(bucketLifecycleConfiguration);
    request.addHeader("Content-Length", String.valueOf(content.length));
    request.addHeader("Content-Type", "application/xml");
    request.setContent(new ByteArrayInputStream(content));
    try {
        final byte[] md5 = Md5Utils.computeMD5Hash(content);
        final String md5Base64 = BinaryUtils.toBase64(md5);
        request.addHeader("Content-MD5", md5Base64);
    } catch (final Exception e) {
        throw new AmazonClientException("Couldn't compute md5 sum", e);
    }
    invoke(request, voidResponseHandler, bucketName, null);
}
Also used : BucketConfigurationXmlFactory(com.amazonaws.services.s3.model.transform.BucketConfigurationXmlFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) AmazonClientException(com.amazonaws.AmazonClientException) AmazonServiceException(com.amazonaws.AmazonServiceException) AmazonClientException(com.amazonaws.AmazonClientException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) AbortedException(com.amazonaws.AbortedException)

Example 64 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 deleteObjects.

/*
     * (non-Javadoc)
     * @see
     * com.amazonaws.services.s3.AmazonS3#deleteObjects(com.amazonaws.services
     * .s3.model.DeleteObjectsRequest)
     */
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest) {
    final Request<DeleteObjectsRequest> request = createRequest(deleteObjectsRequest.getBucketName(), null, deleteObjectsRequest, HttpMethodName.POST);
    request.addParameter("delete", null);
    if (deleteObjectsRequest.getMfa() != null) {
        populateRequestWithMfaDetails(request, deleteObjectsRequest.getMfa());
    }
    populateRequesterPaysHeader(request, deleteObjectsRequest.isRequesterPays());
    final byte[] content = new MultiObjectDeleteXmlFactory().convertToXmlByteArray(deleteObjectsRequest);
    request.addHeader("Content-Length", String.valueOf(content.length));
    request.addHeader("Content-Type", "application/xml");
    request.setContent(new ByteArrayInputStream(content));
    try {
        final byte[] md5 = Md5Utils.computeMD5Hash(content);
        final String md5Base64 = BinaryUtils.toBase64(md5);
        request.addHeader("Content-MD5", md5Base64);
    } catch (final Exception e) {
        throw new AmazonClientException("Couldn't compute md5 sum", e);
    }
    @SuppressWarnings("unchecked") final ResponseHeaderHandlerChain<DeleteObjectsResponse> responseHandler = new ResponseHeaderHandlerChain<DeleteObjectsResponse>(new Unmarshallers.DeleteObjectsResultUnmarshaller(), new S3RequesterChargedHeaderHandler<DeleteObjectsResponse>());
    final DeleteObjectsResponse response = invoke(request, responseHandler, deleteObjectsRequest.getBucketName(), null);
    /*
         * If the result was only partially successful, throw an exception
         */
    if (!response.getErrors().isEmpty()) {
        final Map<String, String> headers = responseHandler.getResponseHeaders();
        final MultiObjectDeleteException ex = new MultiObjectDeleteException(response.getErrors(), response.getDeletedObjects());
        ex.setStatusCode(200);
        ex.setRequestId(headers.get(Headers.REQUEST_ID));
        ex.setExtendedRequestId(headers.get(Headers.EXTENDED_REQUEST_ID));
        ex.setCloudFrontId(headers.get(Headers.CLOUD_FRONT_ID));
        throw ex;
    }
    final DeleteObjectsResult result = new DeleteObjectsResult(response.getDeletedObjects(), response.isRequesterCharged());
    return result;
}
Also used : DeleteObjectsResponse(com.amazonaws.services.s3.internal.DeleteObjectsResponse) Unmarshallers(com.amazonaws.services.s3.model.transform.Unmarshallers) AmazonClientException(com.amazonaws.AmazonClientException) AmazonServiceException(com.amazonaws.AmazonServiceException) AmazonClientException(com.amazonaws.AmazonClientException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) AbortedException(com.amazonaws.AbortedException) MultiObjectDeleteXmlFactory(com.amazonaws.services.s3.model.transform.MultiObjectDeleteXmlFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) ResponseHeaderHandlerChain(com.amazonaws.services.s3.internal.ResponseHeaderHandlerChain)

Example 65 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 setBucketTaggingConfiguration.

/*
     * (non-Javadoc)
     * @see
     * com.amazonaws.services.s3.AmazonS3#setBucketTaggingConfiguration(com.
     * amazonaws.services.s3.model.SetBucketTaggingConfigurationRequest)
     */
@Override
public void setBucketTaggingConfiguration(SetBucketTaggingConfigurationRequest setBucketTaggingConfigurationRequest) {
    assertParameterNotNull(setBucketTaggingConfigurationRequest, "The set bucket tagging configuration request object must be specified.");
    final String bucketName = setBucketTaggingConfigurationRequest.getBucketName();
    final BucketTaggingConfiguration bucketTaggingConfiguration = setBucketTaggingConfigurationRequest.getTaggingConfiguration();
    assertParameterNotNull(bucketName, "The bucket name parameter must be specified when setting bucket tagging configuration.");
    assertParameterNotNull(bucketTaggingConfiguration, "The tagging configuration parameter must be specified when setting bucket tagging configuration.");
    final Request<SetBucketTaggingConfigurationRequest> request = createRequest(bucketName, null, setBucketTaggingConfigurationRequest, HttpMethodName.PUT);
    request.addParameter("tagging", null);
    final byte[] content = new BucketConfigurationXmlFactory().convertToXmlByteArray(bucketTaggingConfiguration);
    request.addHeader("Content-Length", String.valueOf(content.length));
    request.addHeader("Content-Type", "application/xml");
    request.setContent(new ByteArrayInputStream(content));
    try {
        final byte[] md5 = Md5Utils.computeMD5Hash(content);
        final String md5Base64 = BinaryUtils.toBase64(md5);
        request.addHeader("Content-MD5", md5Base64);
    } catch (final Exception e) {
        throw new AmazonClientException("Couldn't compute md5 sum", e);
    }
    invoke(request, voidResponseHandler, bucketName, null);
}
Also used : BucketConfigurationXmlFactory(com.amazonaws.services.s3.model.transform.BucketConfigurationXmlFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) AmazonClientException(com.amazonaws.AmazonClientException) AmazonServiceException(com.amazonaws.AmazonServiceException) AmazonClientException(com.amazonaws.AmazonClientException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) AbortedException(com.amazonaws.AbortedException)

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