Example usage for com.amazonaws.services.elastictranscoder.model CreatePipelineRequest CreatePipelineRequest

List of usage examples for com.amazonaws.services.elastictranscoder.model CreatePipelineRequest CreatePipelineRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.elastictranscoder.model CreatePipelineRequest CreatePipelineRequest.

Prototype

CreatePipelineRequest

Source Link

Usage

From source file:com.amediamanager.config.ElasticTranscoderPipelineResource.java

License:Apache License

private String provisionPipeline() {
    String pipelineId = config.getProperty(ConfigProps.TRANSCODE_PIPELINE);

    if (pipelineId == null) {
        LOG.info("Provisioning ETS Pipeline.");
        state = ProvisionState.PROVISIONING;
        Notifications notifications = new Notifications()
                .withError(config.getProperty(ConfigProps.TRANSCODE_TOPIC))
                .withCompleted(config.getProperty(ConfigProps.TRANSCODE_TOPIC)).withProgressing("")
                .withWarning("");

        CreatePipelineRequest pipelineRequest = new CreatePipelineRequest()
                .withName("amm-reinvent-pipeline-"
                        + UUID.randomUUID().toString().replace("-", "").substring(0, 18).toUpperCase())
                .withRole(config.getProperty(ConfigProps.TRANSCODE_ROLE))
                .withInputBucket(config.getProperty(ConfigProps.S3_UPLOAD_BUCKET))
                .withOutputBucket(config.getProperty(ConfigProps.S3_UPLOAD_BUCKET))
                .withNotifications(notifications);

        try {/*from   w w w . j  a va2s.  c  o m*/
            CreatePipelineResult pipelineResult = transcoderClient.createPipeline(pipelineRequest);
            pipelineId = pipelineResult.getPipeline().getId();
            LOG.info("Pipeline {} created. Persisting to configuration provider.", pipelineId);
            config.getConfigurationProvider().persistNewProperty(ConfigProps.TRANSCODE_PIPELINE, pipelineId);
        } catch (AmazonServiceException e) {
            LOG.error("Failed creating pipeline {}", pipelineRequest.getName(), e);
            state = ProvisionState.UNPROVISIONED;
        }
    }
    return pipelineId;
}

From source file:org.alanwilliamson.amazon.transcoder.pipeline.Create.java

License:Open Source License

public cfData execute(cfSession _session, cfArgStructData argStruct) throws cfmRunTimeException {
    AmazonKey amazonKey = getAmazonKey(_session, argStruct);
    AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

    CreatePipelineRequest cpr = new CreatePipelineRequest();

    cpr.setName(getNamedStringParam(argStruct, "name", null));
    if (cpr.getName() == null || cpr.getName().isEmpty() || cpr.getName().length() > 40)
        throwException(_session, "please provide a valid name (40chars or less)");

    cpr.setInputBucket(getNamedStringParam(argStruct, "inputbucket", null));
    if (cpr.getInputBucket() == null || cpr.getInputBucket().isEmpty())
        throwException(_session, "please provide a valid inputbucket");

    cpr.setRole(getNamedStringParam(argStruct, "role", null));
    if (cpr.getRole() == null || cpr.getRole().isEmpty())
        throwException(_session, "please provide a valid role");

    cpr.setAwsKmsKeyArn(getNamedStringParam(argStruct, "awskey", null));
    if (cpr.getAwsKmsKeyArn() == null || cpr.getAwsKmsKeyArn().isEmpty())
        throwException(_session, "please provide a valid awskey");

    if (getNamedStringParam(argStruct, "outputbucket", null) != null) {

        cpr.setOutputBucket(getNamedStringParam(argStruct, "outputbucket", null));
        if (cpr.getOutputBucket().isEmpty())
            throwException(_session, "please provide a 'contentconfig' or a 'outputbucket'");

    } else {//from  w  w  w.j a  v  a 2  s  .  c o m

        // Handle the ContentConfig
        cfStructData cc = getNamedStructParam(_session, argStruct, "contentconfig", null);
        if (cc == null)
            throwException(_session, "please provide a 'contentconfig' or a 'outputbucket'");

        PipelineOutputConfig contentConfig = new PipelineOutputConfig();

        contentConfig.setBucket(cc.getData("bucket").getString());
        if (contentConfig.getBucket() == null || contentConfig.getBucket().isEmpty())
            throwException(_session, "please provide a 'contentconfig.bucket'");

        contentConfig.setStorageClass(cc.getData("storageclass").getString());
        if (contentConfig.getStorageClass() == null || contentConfig.getStorageClass().isEmpty())
            throwException(_session, "please provide a 'contentconfig.storageclass'");

        Collection<Permission> permissions = getPermissions(_session, cc);
        if (!permissions.isEmpty())
            contentConfig.setPermissions(permissions);

        cpr.setContentConfig(contentConfig);

        // Handle the thumbnailconfig
        cc = getNamedStructParam(_session, argStruct, "thumbnailconfig", null);
        if (cc == null)
            throwException(_session, "please provide a 'thumbnailconfig' or a 'outputbucket'");

        contentConfig = new PipelineOutputConfig();

        contentConfig.setBucket(cc.getData("bucket").getString());
        if (contentConfig.getBucket() == null || contentConfig.getBucket().isEmpty())
            throwException(_session, "please provide a 'thumbnailconfig.bucket'");

        contentConfig.setStorageClass(cc.getData("storageclass").getString());
        if (contentConfig.getStorageClass() == null || contentConfig.getStorageClass().isEmpty())
            throwException(_session, "please provide a 'thumbnailconfig.storageclass'");

        permissions = getPermissions(_session, cc);
        if (!permissions.isEmpty())
            contentConfig.setPermissions(permissions);

        cpr.setThumbnailConfig(contentConfig);
    }

    // Now after collection all that; create the actual pipeline
    try {
        CreatePipelineResult cpres = et.createPipeline(cpr);
        return new cfStringData(cpres.getPipeline().getId());
    } catch (Exception e) {
        throwException(_session, "AmazonElasticTranscoder: " + e.getMessage());
        return cfBooleanData.TRUE;
    }
}