/** * Collect data for ElasticTranscoder. * * @param stats * current statistics object. * @param account * currently used credentials object. * @param region * currently used aws region. */ public static void scanElasticTranscoder(AwsStats stats, AwsAccount account, Regions region) { if (region == Regions.EU_CENTRAL_1) return; LOG.debug("Scan for ElasticTranscoder in region " + region.getName() + " in account " + account.getAccountId()); try { AmazonElasticTranscoder elasticTranscoder = new AmazonElasticTranscoderClient(account.getCredentials()); elasticTranscoder.setRegion(Region.getRegion(region)); List<Pipeline> list = elasticTranscoder.listPipelines().getPipelines(); int totalItems = list.size(); for (Pipeline pipeline : list) { AwsResource res = new AwsResource(pipeline.getName(), account.getAccountId(), AwsResourceType.ElasticTranscoder, region); res.addInfo(AwsTag.Arn, pipeline.getArn()); stats.add(res); } LOG.info(totalItems + " Elastic Transcoder pipelines in region " + region.getName() + " in account " + account.getAccountId()); } catch (AmazonServiceException ase) { LOG.error("Exception of ElasticTranscoder: " + ase.getMessage()); } }
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{ AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey); String jobid = getNamedStringParam(argStruct, "jobid", null ); if ( jobid == null ) throwException(_session, "Please specify a jobid" ); try{ ReadJobResult rjr = et.readJob( new ReadJobRequest().withId(jobid) ); return new cfStringData( rjr.getJob().getStatus() ); }catch(Exception e){ throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() ); } return cfBooleanData.TRUE; }
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{ AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey); String jobid = getNamedStringParam(argStruct, "jobid", null ); if ( jobid == null ) throwException(_session, "Please specify a jobid" ); try{ et.cancelJob( new CancelJobRequest().withId(jobid) ); }catch(Exception e){ throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() ); } return cfBooleanData.TRUE; }
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{ AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey); String pipelineid = getNamedStringParam(argStruct, "pipelineid", null ); if ( pipelineid == null ) throwException(_session, "Please specify a pipelineid" ); try{ ReadPipelineResult rp = et.readPipeline( new ReadPipelineRequest().withId(pipelineid) ); return getPipeline( rp.getPipeline() ); }catch(Exception e){ throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() ); } return cfBooleanData.TRUE; }
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{ AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey); String pipelineid = getNamedStringParam(argStruct, "pipelineid", null ); if ( pipelineid == null ) throwException(_session, "Please specify a pipelineid" ); try{ et.deletePipeline( new DeletePipelineRequest().withId(pipelineid) ); }catch(Exception e){ throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() ); } return cfBooleanData.TRUE; }
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{ AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey); String pipelineid = getNamedStringParam(argStruct, "pipelineid", null ); if ( pipelineid == null ) throwException(_session, "Please specify a pipelineid" ); String status = getNamedStringParam(argStruct, "status", null ); if ( status == null ) throwException(_session, "Please specify a status" ); try{ et.updatePipelineStatus( new UpdatePipelineStatusRequest().withId(pipelineid).withStatus(status) ); }catch(Exception e){ throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() ); } return cfBooleanData.TRUE; }
/** * Returns back the necessary AmazonElasticTranscoder class for interacting with Elastic Transcoder * @param amazonKey * @return * @throws cfmRunTimeException */ public AmazonElasticTranscoder getAmazonElasticTranscoder( AmazonKey amazonKey ) throws cfmRunTimeException{ BasicAWSCredentials awsCreds = new BasicAWSCredentials(amazonKey.getKey(), amazonKey.getSecret()); AmazonElasticTranscoder et = new AmazonElasticTranscoderClient(awsCreds); et.setRegion( amazonKey.getAmazonRegion().toAWSRegion() ); return et; }
@Bean( destroyMethod = "shutdown" ) AmazonElasticTranscoder amazonElasticTranscoderClient() { return this.awsRegion().createClient( AmazonElasticTranscoderClient.class, this.awsCredentials(), new ClientConfiguration() ); }
public AmazonElasticTranscoder getTranscoderClient() { return transcoderClient; }
public void setTranscoderClient(AmazonElasticTranscoder transcoderClient) { this.transcoderClient = transcoderClient; }
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{ AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey); CreateJobRequest cjr = new CreateJobRequest(); cjr.setPipelineId( getNamedStringParam(argStruct, "pipelineid", null) ); if ( cjr.getPipelineId() == null || cjr.getPipelineId().isEmpty() ) throwException(_session, "please provide a valid pipelineid"); cjr.setOutputKeyPrefix( getNamedStringParam(argStruct, "outputkeyprefix", null) ); if ( cjr.getOutputKeyPrefix() != null && cjr.getOutputKeyPrefix().isEmpty() ) throwException(_session, "please provide a valid outputkeyprefix"); // Handle the input cfStructData input = getNamedStructParam( _session, argStruct, "input", null ); if ( input == null ) throwException(_session, "please provide a 'input'"); JobInput jobinput = new JobInput(); if ( input.containsKey("aspectratio") ) jobinput.setAspectRatio( input.getData("aspectratio").getString() ); if ( input.containsKey("container") ) jobinput.setContainer( input.getData("container").getString() ); if ( input.containsKey("framerate") ) jobinput.setFrameRate( input.getData("framerate").getString() ); if ( input.containsKey("interlaced") ) jobinput.setInterlaced( input.getData("interlaced").getString() ); if ( input.containsKey("key") ) jobinput.setKey( input.getData("key").getString() ); if ( input.containsKey("resolution") ) jobinput.setResolution( input.getData("resolution").getString() ); if ( input.containsKey("encryption") ) jobinput.setEncryption( getEncryption( (cfStructData)input.getData("encryption") ) ); cjr.setInput(jobinput); // Set the output cfArrayData outputArr = getNamedArrayParam( _session, argStruct, "outputs", null ); if ( outputArr == null ) throwException(_session, "please provide 'outputs'"); List<CreateJobOutput> outputs = new LinkedList(); for ( int x=0; x < outputArr.size(); x++ ) outputs.add( getCreateJobOutput( (cfStructData)outputArr.getData(x+1) ) ); cjr.setOutputs(outputs); // Now after collection all that; create the actual pipeline try{ CreateJobResult cpres = et.createJob(cjr); return new cfStringData( cpres.getJob().getId() ); }catch(Exception e){ throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() ); return cfBooleanData.TRUE; } }
@Bean @Scope(WebApplicationContext.SCOPE_APPLICATION) public AmazonElasticTranscoder transcodeClient(final AWSCredentialsProvider creds, final Region region) { return region.createClient(AmazonElasticTranscoderClient.class, creds, null); }
public TranscodingService( final AmazonElasticTranscoder elasticTranscoder ) { this.elasticTranscoder = elasticTranscoder; }
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{ AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey); try{ cfArrayData pipelines = cfArrayData.createArray(1); ListPresetsRequest listObjectsRequest = new ListPresetsRequest(); ListPresetsResult lpr; do { lpr = et.listPresets(listObjectsRequest); for (Preset preset: lpr.getPresets() ) pipelines.addElement( getPreset(preset) ); listObjectsRequest.setPageToken( lpr.getNextPageToken() ); } while ( listObjectsRequest.getPageToken() != null ); return pipelines; }catch(Exception e){ throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() ); } return cfBooleanData.TRUE; }
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{ AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey); String pipelineid = getNamedStringParam(argStruct, "pipelineid", null ); if ( pipelineid == null ) throwException(_session, "Please specify a pipelineid" ); try{ cfArrayData jobs = cfArrayData.createArray(1); ListJobsByPipelineRequest listObjectsRequest = new ListJobsByPipelineRequest(); ListJobsByPipelineResult lpr; do { lpr = et.listJobsByPipeline(listObjectsRequest); for (Job job : lpr.getJobs() ) jobs.addElement( getJob(job) ); listObjectsRequest.setPageToken( lpr.getNextPageToken() ); } while ( listObjectsRequest.getPageToken() != null ); return jobs; }catch(Exception e){ throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() ); } return cfBooleanData.TRUE; }
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{ AmazonKey amazonKey = getAmazonKey(_session, argStruct); AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey); try{ cfArrayData pipelines = cfArrayData.createArray(1); ListPipelinesRequest listObjectsRequest = new ListPipelinesRequest(); ListPipelinesResult lpr; do { lpr = et.listPipelines(listObjectsRequest); for (Pipeline pipeline : lpr.getPipelines()) pipelines.addElement( getPipeline(pipeline) ); listObjectsRequest.setPageToken( lpr.getNextPageToken() ); } while ( listObjectsRequest.getPageToken() != null ); return pipelines; }catch(Exception e){ throwException(_session, "AmazonElasticTranscoder: " + e.getMessage() ); } return cfBooleanData.TRUE; }