-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Greengrass V2 IPC model for PutComponentMetric operation (#296)
* Update Greengrass V2 IPC model for PutComponentMetric operation * @kucnavya fix: increase timeout for subscriptionClosed from commit: 4ea1e66 Co-authored-by: Navya Kuchibhotla <kucnavya@amazon.com> Co-authored-by: Vera Xia <zhvxia@amazon.com>
- Loading branch information
1 parent
427f913
commit d59e0bb
Showing
11 changed files
with
477 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...-java/client/software/amazon/awssdk/aws/greengrass/PutComponentMetricResponseHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package software.amazon.awssdk.aws.greengrass; | ||
|
||
import java.lang.Override; | ||
import java.lang.Void; | ||
import java.util.concurrent.CompletableFuture; | ||
import software.amazon.awssdk.aws.greengrass.model.PutComponentMetricResponse; | ||
import software.amazon.awssdk.eventstreamrpc.OperationResponse; | ||
import software.amazon.awssdk.eventstreamrpc.StreamResponse; | ||
import software.amazon.awssdk.eventstreamrpc.model.EventStreamJsonMessage; | ||
|
||
public final class PutComponentMetricResponseHandler implements StreamResponse<PutComponentMetricResponse, EventStreamJsonMessage> { | ||
private final OperationResponse<PutComponentMetricResponse, EventStreamJsonMessage> operationResponse; | ||
|
||
public PutComponentMetricResponseHandler( | ||
final OperationResponse<PutComponentMetricResponse, EventStreamJsonMessage> operationResponse) { | ||
this.operationResponse = operationResponse; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> getRequestFlushFuture() { | ||
return operationResponse.getRequestFlushFuture(); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<PutComponentMetricResponse> getResponse() { | ||
return operationResponse.getResponse(); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> sendStreamEvent(final EventStreamJsonMessage event) { | ||
return operationResponse.sendStreamEvent(event); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Void> closeStream() { | ||
return operationResponse.closeStream(); | ||
} | ||
|
||
@Override | ||
public boolean isClosed() { | ||
return operationResponse.isClosed(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...-java/model/software/amazon/awssdk/aws/greengrass/PutComponentMetricOperationContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package software.amazon.awssdk.aws.greengrass; | ||
|
||
import java.lang.Class; | ||
import java.lang.Override; | ||
import java.lang.String; | ||
import java.util.Optional; | ||
import software.amazon.awssdk.aws.greengrass.model.PutComponentMetricRequest; | ||
import software.amazon.awssdk.aws.greengrass.model.PutComponentMetricResponse; | ||
import software.amazon.awssdk.eventstreamrpc.EventStreamRPCServiceModel; | ||
import software.amazon.awssdk.eventstreamrpc.OperationModelContext; | ||
import software.amazon.awssdk.eventstreamrpc.model.EventStreamJsonMessage; | ||
|
||
public class PutComponentMetricOperationContext implements OperationModelContext<PutComponentMetricRequest, PutComponentMetricResponse, EventStreamJsonMessage, EventStreamJsonMessage> { | ||
@Override | ||
public EventStreamRPCServiceModel getServiceModel() { | ||
return GreengrassCoreIPCServiceModel.getInstance(); | ||
} | ||
|
||
@Override | ||
public String getOperationName() { | ||
return GreengrassCoreIPCServiceModel.PUT_COMPONENT_METRIC; | ||
} | ||
|
||
@Override | ||
public Class<PutComponentMetricRequest> getRequestTypeClass() { | ||
return PutComponentMetricRequest.class; | ||
} | ||
|
||
@Override | ||
public Class<PutComponentMetricResponse> getResponseTypeClass() { | ||
return PutComponentMetricResponse.class; | ||
} | ||
|
||
@Override | ||
public String getRequestApplicationModelType() { | ||
return PutComponentMetricRequest.APPLICATION_MODEL_TYPE; | ||
} | ||
|
||
@Override | ||
public String getResponseApplicationModelType() { | ||
return PutComponentMetricResponse.APPLICATION_MODEL_TYPE; | ||
} | ||
|
||
@Override | ||
public Optional<Class<EventStreamJsonMessage>> getStreamingRequestTypeClass() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Optional<Class<EventStreamJsonMessage>> getStreamingResponseTypeClass() { | ||
return Optional.empty(); | ||
} | ||
|
||
public Optional<String> getStreamingRequestApplicationModelType() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Optional<String> getStreamingResponseApplicationModelType() { | ||
return Optional.empty(); | ||
} | ||
} |
136 changes: 136 additions & 0 deletions
136
...t/src/event-stream-rpc-java/model/software/amazon/awssdk/aws/greengrass/model/Metric.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package software.amazon.awssdk.aws.greengrass.model; | ||
|
||
import com.google.gson.annotations.Expose; | ||
import java.lang.Double; | ||
import java.lang.Object; | ||
import java.lang.Override; | ||
import java.lang.String; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import software.amazon.awssdk.eventstreamrpc.model.EventStreamJsonMessage; | ||
|
||
public class Metric implements EventStreamJsonMessage { | ||
public static final String APPLICATION_MODEL_TYPE = "aws.greengrass#Metric"; | ||
|
||
public static final Metric VOID; | ||
|
||
static { | ||
VOID = new Metric() { | ||
@Override | ||
public boolean isVoid() { | ||
return true; | ||
} | ||
}; | ||
} | ||
|
||
@Expose( | ||
serialize = true, | ||
deserialize = true | ||
) | ||
private Optional<String> name; | ||
|
||
@Expose( | ||
serialize = true, | ||
deserialize = true | ||
) | ||
private Optional<String> unit; | ||
|
||
@Expose( | ||
serialize = true, | ||
deserialize = true | ||
) | ||
private Optional<Double> value; | ||
|
||
public Metric() { | ||
this.name = Optional.empty(); | ||
this.unit = Optional.empty(); | ||
this.value = Optional.empty(); | ||
} | ||
|
||
public String getName() { | ||
if (name.isPresent()) { | ||
return name.get(); | ||
} | ||
return null; | ||
} | ||
|
||
public void setName(final String name) { | ||
this.name = Optional.ofNullable(name); | ||
} | ||
|
||
public Metric withName(final String name) { | ||
setName(name); | ||
return this; | ||
} | ||
|
||
public MetricUnitType getUnit() { | ||
if (unit.isPresent()) { | ||
return MetricUnitType.get(unit.get()); | ||
} | ||
return null; | ||
} | ||
|
||
public String getUnitAsString() { | ||
if (unit.isPresent()) { | ||
return unit.get(); | ||
} | ||
return null; | ||
} | ||
|
||
public void setUnit(final String unit) { | ||
this.unit = Optional.ofNullable(unit); | ||
} | ||
|
||
public Metric withUnit(final String unit) { | ||
setUnit(unit); | ||
return this; | ||
} | ||
|
||
public void setUnit(final MetricUnitType unit) { | ||
this.unit = Optional.ofNullable(unit.getValue()); | ||
} | ||
|
||
public Metric withUnit(final MetricUnitType unit) { | ||
setUnit(unit); | ||
return this; | ||
} | ||
|
||
public Double getValue() { | ||
if (value.isPresent()) { | ||
return value.get(); | ||
} | ||
return null; | ||
} | ||
|
||
public void setValue(final Double value) { | ||
this.value = Optional.ofNullable(value); | ||
} | ||
|
||
public Metric withValue(final Double value) { | ||
setValue(value); | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getApplicationModelType() { | ||
return APPLICATION_MODEL_TYPE; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object rhs) { | ||
if (rhs == null) return false; | ||
if (!(rhs instanceof Metric)) return false; | ||
if (this == rhs) return true; | ||
final Metric other = (Metric)rhs; | ||
boolean isEquals = true; | ||
isEquals = isEquals && this.name.equals(other.name); | ||
isEquals = isEquals && this.unit.equals(other.unit); | ||
isEquals = isEquals && this.value.equals(other.value); | ||
return isEquals; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, unit, value); | ||
} | ||
} |
Oops, something went wrong.