Skip to content

Commit 12f4aeb

Browse files
authored
Greengrass IPC update including MQTT 5 models (#412)
1 parent c7317ec commit 12f4aeb

File tree

63 files changed

+1773
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1773
-27
lines changed

sdk/greengrass/event-stream-rpc-client/src/main/java/software/amazon/awssdk/eventstreamrpc/EventStreamRPCConnection.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ enum Phase {
3434
CONNECTED,
3535
CLOSING
3636
};
37-
37+
3838
Phase connectionPhase;
3939
ClientConnection connection;
4040
Throwable closeReason;
4141
boolean onConnectCalled;
42-
42+
4343
protected ConnectionState(Phase phase, ClientConnection connection) {
4444
this.connectionPhase = phase;
4545
this.connection = connection;
@@ -75,7 +75,7 @@ protected String getVersionString() {
7575

7676
/**
7777
* Connects to the event stream RPC server asynchronously
78-
*
78+
*
7979
* @return A future that completes when connected
8080
*/
8181
public CompletableFuture<Void> connect(final LifecycleHandler lifecycleHandler) {
@@ -156,7 +156,7 @@ protected void onProtocolMessage(List<Header> headers, byte[] payload, MessageTy
156156
LOGGER.warning("AccessDenied to event stream RPC server");
157157
connectionState.connectionPhase = ConnectionState.Phase.CLOSING;
158158
connectionState.connection.closeConnection(0);
159-
159+
160160
final AccessDeniedException ade = new AccessDeniedException("Connection access denied to event stream RPC server");
161161
if (!initialConnectFuture.isDone()) {
162162
initialConnectFuture.completeExceptionally(ade);
@@ -179,7 +179,7 @@ protected void onProtocolMessage(List<Header> headers, byte[] payload, MessageTy
179179
disconnect();
180180
} else if (MessageType.ProtocolError.equals(messageType) || MessageType.ServerError.equals(messageType)) {
181181
LOGGER.severe("Received " + messageType.name() + ": " + CRT.awsErrorName(CRT.awsLastError()));
182-
connectionState.closeReason = EventStreamError.create(headers, payload, messageType);
182+
connectionState.closeReason = EventStreamError.create(headers, payload, messageType);
183183
doOnError(lifecycleHandler, connectionState.closeReason);
184184
disconnect();
185185
} else {
@@ -222,7 +222,7 @@ protected void onConnectionClosed(int errorCode) {
222222
/**
223223
* Creates a new stream with the given continuation handler.
224224
* Trhows an exception if not connected
225-
*
225+
*
226226
* @param continuationHandler The continuation handler to use
227227
* @return A new ClientConnectionContinuation containing the new stream.
228228
*/
@@ -375,7 +375,7 @@ public interface LifecycleHandler {
375375
* Do nothing on ping by default. Inform handler of ping data
376376
*
377377
* TODO: Could use boolean return here as a hint on whether a pong reply should be sent?
378-
*
378+
*
379379
* @param headers The ping headers
380380
* @param payload The ping payload
381381
*/
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package software.amazon.awssdk.eventstreamrpc;
22

3-
import java.util.Arrays;
4-
53
/**
64
* Thrown when a deserialization exception occurs
75
*/
@@ -20,14 +18,6 @@ public DeserializationException(Object lexicalData) {
2018
* @param cause The reason the data could not be deserialized
2119
*/
2220
public DeserializationException(Object lexicalData, Throwable cause) {
23-
super("Could not deserialize data: [" + stringify(lexicalData) + "]", cause);
24-
}
25-
26-
private static String stringify(Object lexicalData) {
27-
if (lexicalData instanceof byte[]) {
28-
return Arrays.toString((byte[]) lexicalData);
29-
}
30-
31-
return lexicalData.toString();
21+
super("Could not deserialize data: [" + lexicalData.toString() + "]", cause);
3222
}
3323
}

sdk/greengrass/greengrass-client/src/event-stream-rpc-java/model/software/amazon/awssdk/aws/greengrass/GreengrassCoreIPCServiceModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
import software.amazon.awssdk.aws.greengrass.model.MetricUnitType;
7979
import software.amazon.awssdk.aws.greengrass.model.PauseComponentRequest;
8080
import software.amazon.awssdk.aws.greengrass.model.PauseComponentResponse;
81+
import software.amazon.awssdk.aws.greengrass.model.PayloadFormat;
8182
import software.amazon.awssdk.aws.greengrass.model.PostComponentUpdateEvent;
8283
import software.amazon.awssdk.aws.greengrass.model.PreComponentUpdateEvent;
8384
import software.amazon.awssdk.aws.greengrass.model.PublishMessage;
@@ -124,6 +125,7 @@
124125
import software.amazon.awssdk.aws.greengrass.model.UpdateStateResponse;
125126
import software.amazon.awssdk.aws.greengrass.model.UpdateThingShadowRequest;
126127
import software.amazon.awssdk.aws.greengrass.model.UpdateThingShadowResponse;
128+
import software.amazon.awssdk.aws.greengrass.model.UserProperty;
127129
import software.amazon.awssdk.aws.greengrass.model.ValidateAuthorizationTokenRequest;
128130
import software.amazon.awssdk.aws.greengrass.model.ValidateAuthorizationTokenResponse;
129131
import software.amazon.awssdk.aws.greengrass.model.ValidateConfigurationUpdateEvent;
@@ -408,6 +410,7 @@ public class GreengrassCoreIPCServiceModel extends EventStreamRPCServiceModel {
408410
SERVICE_OBJECT_MODEL_MAP.put(MetricUnitType.APPLICATION_MODEL_TYPE, MetricUnitType.class);
409411
SERVICE_OBJECT_MODEL_MAP.put(PauseComponentRequest.APPLICATION_MODEL_TYPE, PauseComponentRequest.class);
410412
SERVICE_OBJECT_MODEL_MAP.put(PauseComponentResponse.APPLICATION_MODEL_TYPE, PauseComponentResponse.class);
413+
SERVICE_OBJECT_MODEL_MAP.put(PayloadFormat.APPLICATION_MODEL_TYPE, PayloadFormat.class);
411414
SERVICE_OBJECT_MODEL_MAP.put(PostComponentUpdateEvent.APPLICATION_MODEL_TYPE, PostComponentUpdateEvent.class);
412415
SERVICE_OBJECT_MODEL_MAP.put(PreComponentUpdateEvent.APPLICATION_MODEL_TYPE, PreComponentUpdateEvent.class);
413416
SERVICE_OBJECT_MODEL_MAP.put(PublishMessage.APPLICATION_MODEL_TYPE, PublishMessage.class);
@@ -454,6 +457,7 @@ public class GreengrassCoreIPCServiceModel extends EventStreamRPCServiceModel {
454457
SERVICE_OBJECT_MODEL_MAP.put(UpdateStateResponse.APPLICATION_MODEL_TYPE, UpdateStateResponse.class);
455458
SERVICE_OBJECT_MODEL_MAP.put(UpdateThingShadowRequest.APPLICATION_MODEL_TYPE, UpdateThingShadowRequest.class);
456459
SERVICE_OBJECT_MODEL_MAP.put(UpdateThingShadowResponse.APPLICATION_MODEL_TYPE, UpdateThingShadowResponse.class);
460+
SERVICE_OBJECT_MODEL_MAP.put(UserProperty.APPLICATION_MODEL_TYPE, UserProperty.class);
457461
SERVICE_OBJECT_MODEL_MAP.put(ValidateAuthorizationTokenRequest.APPLICATION_MODEL_TYPE, ValidateAuthorizationTokenRequest.class);
458462
SERVICE_OBJECT_MODEL_MAP.put(ValidateAuthorizationTokenResponse.APPLICATION_MODEL_TYPE, ValidateAuthorizationTokenResponse.class);
459463
SERVICE_OBJECT_MODEL_MAP.put(ValidateConfigurationUpdateEvent.APPLICATION_MODEL_TYPE, ValidateConfigurationUpdateEvent.class);

sdk/greengrass/greengrass-client/src/event-stream-rpc-java/model/software/amazon/awssdk/aws/greengrass/model/AuthorizeClientDeviceActionRequest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,50 +53,77 @@ public AuthorizeClientDeviceActionRequest() {
5353
this.resource = Optional.empty();
5454
}
5555

56+
/**
57+
* The session token for the client device from GetClientDeviceAuthToken.
58+
*/
5659
public String getClientDeviceAuthToken() {
5760
if (clientDeviceAuthToken.isPresent()) {
5861
return clientDeviceAuthToken.get();
5962
}
6063
return null;
6164
}
6265

66+
/**
67+
* The session token for the client device from GetClientDeviceAuthToken.
68+
*/
6369
public void setClientDeviceAuthToken(final String clientDeviceAuthToken) {
6470
this.clientDeviceAuthToken = Optional.ofNullable(clientDeviceAuthToken);
6571
}
6672

73+
/**
74+
* The session token for the client device from GetClientDeviceAuthToken.
75+
*/
6776
public AuthorizeClientDeviceActionRequest withClientDeviceAuthToken(
6877
final String clientDeviceAuthToken) {
6978
setClientDeviceAuthToken(clientDeviceAuthToken);
7079
return this;
7180
}
7281

82+
/**
83+
* The operation to authorize.
84+
*/
7385
public String getOperation() {
7486
if (operation.isPresent()) {
7587
return operation.get();
7688
}
7789
return null;
7890
}
7991

92+
/**
93+
* The operation to authorize.
94+
*/
8095
public void setOperation(final String operation) {
8196
this.operation = Optional.ofNullable(operation);
8297
}
8398

99+
/**
100+
* The operation to authorize.
101+
*/
84102
public AuthorizeClientDeviceActionRequest withOperation(final String operation) {
85103
setOperation(operation);
86104
return this;
87105
}
88106

107+
/**
108+
* The resource the client device performs the operation on.
109+
*/
89110
public String getResource() {
90111
if (resource.isPresent()) {
91112
return resource.get();
92113
}
93114
return null;
94115
}
95116

117+
/**
118+
* The resource the client device performs the operation on.
119+
*/
96120
public void setResource(final String resource) {
97121
this.resource = Optional.ofNullable(resource);
98122
}
99123

124+
/**
125+
* The resource the client device performs the operation on.
126+
*/
100127
public AuthorizeClientDeviceActionRequest withResource(final String resource) {
101128
setResource(resource);
102129
return this;

sdk/greengrass/greengrass-client/src/event-stream-rpc-java/model/software/amazon/awssdk/aws/greengrass/model/AuthorizeClientDeviceActionResponse.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,26 @@ public AuthorizeClientDeviceActionResponse() {
4040
this.isAuthorized = Optional.empty();
4141
}
4242

43+
/**
44+
* Whether the client device is authorized to perform the operation on the resource.
45+
*/
4346
public Boolean isIsAuthorized() {
4447
if (isAuthorized.isPresent()) {
4548
return isAuthorized.get();
4649
}
4750
return null;
4851
}
4952

53+
/**
54+
* Whether the client device is authorized to perform the operation on the resource.
55+
*/
5056
public void setIsAuthorized(final Boolean isAuthorized) {
5157
this.isAuthorized = Optional.ofNullable(isAuthorized);
5258
}
5359

60+
/**
61+
* Whether the client device is authorized to perform the operation on the resource.
62+
*/
5463
public AuthorizeClientDeviceActionResponse withIsAuthorized(final Boolean isAuthorized) {
5564
setIsAuthorized(isAuthorized);
5665
return this;

sdk/greengrass/greengrass-client/src/event-stream-rpc-java/model/software/amazon/awssdk/aws/greengrass/model/BinaryMessage.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,33 @@ public BinaryMessage() {
4747
this.context = Optional.empty();
4848
}
4949

50+
/**
51+
* The binary message as a blob.
52+
*/
5053
public byte[] getMessage() {
5154
if (message.isPresent()) {
5255
return message.get();
5356
}
5457
return null;
5558
}
5659

60+
/**
61+
* The binary message as a blob.
62+
*/
5763
public void setMessage(final byte[] message) {
5864
this.message = Optional.ofNullable(message);
5965
}
6066

67+
/**
68+
* The binary message as a blob.
69+
*/
6170
public BinaryMessage withMessage(final byte[] message) {
6271
setMessage(message);
6372
return this;
6473
}
6574

6675
/**
67-
* The context is ignored if used in PublishMessage.
76+
* The context of the message, such as the topic where the message was published.
6877
*/
6978
public MessageContext getContext() {
7079
if (context.isPresent()) {
@@ -74,14 +83,14 @@ public MessageContext getContext() {
7483
}
7584

7685
/**
77-
* The context is ignored if used in PublishMessage.
86+
* The context of the message, such as the topic where the message was published.
7887
*/
7988
public void setContext(final MessageContext context) {
8089
this.context = Optional.ofNullable(context);
8190
}
8291

8392
/**
84-
* The context is ignored if used in PublishMessage.
93+
* The context of the message, such as the topic where the message was published.
8594
*/
8695
public BinaryMessage withContext(final MessageContext context) {
8796
setContext(context);

sdk/greengrass/greengrass-client/src/event-stream-rpc-java/model/software/amazon/awssdk/aws/greengrass/model/CertificateOptions.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,41 @@ public CertificateType getCertificateType() {
4646
return null;
4747
}
4848

49+
/**
50+
* The types of certificate updates to subscribe to.
51+
*/
4952
public String getCertificateTypeAsString() {
5053
if (certificateType.isPresent()) {
5154
return certificateType.get();
5255
}
5356
return null;
5457
}
5558

59+
/**
60+
* The types of certificate updates to subscribe to.
61+
*/
5662
public void setCertificateType(final String certificateType) {
5763
this.certificateType = Optional.ofNullable(certificateType);
5864
}
5965

66+
/**
67+
* The types of certificate updates to subscribe to.
68+
*/
6069
public CertificateOptions withCertificateType(final String certificateType) {
6170
setCertificateType(certificateType);
6271
return this;
6372
}
6473

74+
/**
75+
* The types of certificate updates to subscribe to.
76+
*/
6577
public void setCertificateType(final CertificateType certificateType) {
6678
this.certificateType = Optional.ofNullable(certificateType.getValue());
6779
}
6880

81+
/**
82+
* The types of certificate updates to subscribe to.
83+
*/
6984
public CertificateOptions withCertificateType(final CertificateType certificateType) {
7085
setCertificateType(certificateType);
7186
return this;

0 commit comments

Comments
 (0)