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);
}
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]);
}
Aggregations