List of usage examples for com.amazonaws.services.iot.model AttributePayload addAttributesEntry
public AttributePayload addAttributesEntry(String key, String value)
From source file:io.klerch.alexa.state.handler.AWSIotStateHandler.java
License:Open Source License
private void createThing(final String thingName, final AlexaScope scope) { // only create thing if not already existing final AttributePayload attrPayload = new AttributePayload(); // add thing name as attribute as well. this is how the handler queries for the thing from now on attrPayload.addAttributesEntry(thingAttributeName, thingName); // if scope is user an attribute saves the plain user id as it is encrypted in the thing name if (AlexaScope.USER.includes(scope)) { attrPayload.addAttributesEntry(thingAttributeUser, session.getUser().getUserId()); }/* w ww .j a v a 2 s.c om*/ // another thing attributes holds the Alexa application-id attrPayload.addAttributesEntry(thingAttributeApp, session.getApplication().getApplicationId()); // now create the thing final CreateThingRequest request = new CreateThingRequest().withThingName(thingName) .withAttributePayload(attrPayload); awsClient.createThing(request); log.info(format("Thing '%1$s' is created in AWS IoT.", thingName)); }