Search in sources :

Example 1 with Tag

use of com.amazonaws.kinesisvideo.producer.Tag in project aws-sdk-android by aws-amplify.

the class DefaultServiceCallbacksImpl method tagResource.

@Override
public void tagResource(@NonNull final String resourceArn, @Nullable final Tag[] tags, final long callAfter, final long timeout, @Nullable final byte[] authData, final int authType, final long streamHandle, final KinesisVideoProducerStream stream) throws ProducerException {
    Preconditions.checkState(isInitialized(), "Service callbacks object should be initialized first");
    final long delay = calculateRelativeServiceCallAfter(callAfter);
    final Runnable task = new Runnable() {

        @Override
        public void run() {
            final KinesisVideoCredentialsProvider credentialsProvider = getCredentialsProvider(authData, log);
            final long timeoutInMillis = timeout / Time.HUNDREDS_OF_NANOS_IN_A_MILLISECOND;
            int statusCode = HTTP_OK;
            Map<String, String> tagsMap = null;
            if (null != tags) {
                // Convert the tags to map
                tagsMap = new HashMap<String, String>(tags.length);
                for (final Tag tag : tags) {
                    tagsMap.put(tag.getName(), tag.getValue());
                }
            }
            try {
                kinesisVideoServiceClient.tagStream(resourceArn, tagsMap, timeoutInMillis, credentialsProvider);
            } catch (final KinesisVideoException e) {
                log.error("Kinesis Video service client returned an error " + e.getMessage() + ". Reporting to Kinesis Video PIC.");
                statusCode = getStatusCodeFromException(e);
            }
            if (statusCode != HTTP_OK) {
                // TODO: more URI validation
                statusCode = HTTP_BAD_REQUEST;
            }
            try {
                kinesisVideoProducer.tagResourceResult(stream, streamHandle, statusCode);
            } catch (final ProducerException e) {
                throw new RuntimeException(e);
            }
        }
    };
    executor.schedule(task, delay, TimeUnit.NANOSECONDS);
}
Also used : ProducerException(com.amazonaws.kinesisvideo.producer.ProducerException) Tag(com.amazonaws.kinesisvideo.producer.Tag) KinesisVideoCredentialsProvider(com.amazonaws.kinesisvideo.auth.KinesisVideoCredentialsProvider) KinesisVideoException(com.amazonaws.kinesisvideo.common.exception.KinesisVideoException)

Example 2 with Tag

use of com.amazonaws.kinesisvideo.producer.Tag in project amazon-kinesis-video-streams-parser-library by aws.

the class ProducerStreamUtil method getTags.

private static Tag[] getTags() {
    final List<Tag> tagList = new ArrayList<Tag>();
    tagList.add(new Tag("device", "Test Device"));
    tagList.add(new Tag("stream", "Test Stream"));
    return tagList.toArray(new Tag[0]);
}
Also used : ArrayList(java.util.ArrayList) Tag(com.amazonaws.kinesisvideo.producer.Tag)

Aggregations

Tag (com.amazonaws.kinesisvideo.producer.Tag)2 KinesisVideoCredentialsProvider (com.amazonaws.kinesisvideo.auth.KinesisVideoCredentialsProvider)1 KinesisVideoException (com.amazonaws.kinesisvideo.common.exception.KinesisVideoException)1 ProducerException (com.amazonaws.kinesisvideo.producer.ProducerException)1 ArrayList (java.util.ArrayList)1