diff --git a/proto/automation.proto b/proto/automation.proto index f41bef9e28588fbd2a0acf416d347eb530c48df0..9297236766a28878a5f0c0de6a4aeae0487d330a 100644 --- a/proto/automation.proto +++ b/proto/automation.proto @@ -21,7 +21,7 @@ service AutomationService { rpc ZtpGetDeviceRole(DeviceRoleId) returns (DeviceRole) {} rpc ZtpGetDeviceRolesByDeviceId(context.DeviceId) returns (DeviceRoleList) {} rpc ZtpAdd(DeviceRole) returns (DeviceRoleState) {} - rpc ZtpUpdate(DeviceRole) returns (DeviceRoleState) {} + rpc ZtpUpdate(DeviceRoleConfig) returns (DeviceRoleState) {} rpc ZtpDelete(DeviceRole) returns (DeviceRoleState) {} rpc ZtpDeleteAll(context.Empty) returns (DeviceDeletionResult) {} } @@ -43,6 +43,11 @@ message DeviceRole { DeviceRoleType devRoleType = 2; } +message DeviceRoleConfig { + DeviceRole devRole = 1; + context.DeviceConfig devConfig = 2; +} + message DeviceRoleList { repeated DeviceRole devRole = 1; } diff --git a/src/automation/src/main/java/eu/teraflow/automation/AutomationGatewayImpl.java b/src/automation/src/main/java/eu/teraflow/automation/AutomationGatewayImpl.java index c160387c3e3448f29d01a185afc31127b025c2b6..6d672fdea2c3e97f9f2a50c7efa8d77c05532357 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/AutomationGatewayImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/AutomationGatewayImpl.java @@ -17,9 +17,12 @@ package eu.teraflow.automation; import automation.Automation; +import automation.Automation.DeviceRoleConfig; +import automation.Automation.DeviceRoleState; import context.ContextOuterClass; import eu.teraflow.automation.context.model.Device; import eu.teraflow.automation.model.DeviceRoleId; +import eu.teraflow.automation.model.DeviceState; import io.quarkus.grpc.GrpcService; import io.smallrye.mutiny.Uni; import javax.inject.Inject; @@ -56,17 +59,19 @@ public class AutomationGatewayImpl implements AutomationGateway { return automationService .addDevice(deviceId) .onItem() - .transform(device -> transformToDeviceRoleState(device, devRoleId)); + .transform(device -> transformToDeviceRoleState(device, devRoleId, DeviceState.CREATED)); } @Override - public Uni<Automation.DeviceRoleState> ztpUpdate(Automation.DeviceRole request) { - return Uni.createFrom() - .item( - () -> - Automation.DeviceRoleState.newBuilder() - .setDevRoleId(request.getDevRoleId()) - .build()); + public Uni<DeviceRoleState> ztpUpdate(DeviceRoleConfig request) { + final var devRoleId = request.getDevRole().getDevRoleId().getDevRoleId().getUuid(); + final var deviceId = serializer.deserialize(request.getDevRole().getDevRoleId().getDevId()); + final var deviceConfig = serializer.deserialize(request.getDevConfig()); + + return automationService + .updateDevice(deviceId, deviceConfig) + .onItem() + .transform(device -> transformToDeviceRoleState(device, devRoleId, DeviceState.UPDATED)); } @Override @@ -84,16 +89,15 @@ public class AutomationGatewayImpl implements AutomationGateway { return Uni.createFrom().item(() -> Automation.DeviceDeletionResult.newBuilder().build()); } - // TODO When `DeviceRoleState` domain object will be created, move this method to Serializer class - // and create related tests - private Automation.DeviceRoleState transformToDeviceRoleState(Device device, String devRoleId) { - + private Automation.DeviceRoleState transformToDeviceRoleState( + Device device, String devRoleId, DeviceState deviceState) { final var deviceRoleId = new DeviceRoleId(devRoleId, device.getDeviceId()); final var serializeDeviceRoleId = serializer.serialize(deviceRoleId); + final var serializedDeviceState = serializer.serialize(deviceState); return Automation.DeviceRoleState.newBuilder() .setDevRoleId(serializeDeviceRoleId) - .setDevRoleState(Automation.ZtpDeviceState.ZTP_DEV_STATE_CREATED) + .setDevRoleState(serializedDeviceState) .build(); } } diff --git a/src/automation/src/main/java/eu/teraflow/automation/AutomationService.java b/src/automation/src/main/java/eu/teraflow/automation/AutomationService.java index a825005de904a4837252ab2fdd91830b98871892..b9f34d8e4bd3e1703bff1cf48a18a0a2b84e61b1 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/AutomationService.java +++ b/src/automation/src/main/java/eu/teraflow/automation/AutomationService.java @@ -17,6 +17,7 @@ package eu.teraflow.automation; import eu.teraflow.automation.context.model.Device; +import eu.teraflow.automation.context.model.DeviceConfig; import io.smallrye.mutiny.Uni; public interface AutomationService { @@ -24,4 +25,6 @@ public interface AutomationService { Uni<Device> addDevice(String deviceId); Uni<Device> deleteDevice(String deviceId); + + Uni<Device> updateDevice(String deviceId, DeviceConfig deviceConfig); } diff --git a/src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java b/src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java index 2b970b401bc3640bc98d9ff5230ecab3e0a0b58f..773c99de6d94b5f8806a8a354b2371c0a6748f9f 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/AutomationServiceImpl.java @@ -18,6 +18,7 @@ package eu.teraflow.automation; import eu.teraflow.automation.context.ContextService; import eu.teraflow.automation.context.model.Device; +import eu.teraflow.automation.context.model.DeviceConfig; import eu.teraflow.automation.device.DeviceService; import io.smallrye.mutiny.Uni; import javax.enterprise.context.ApplicationScoped; @@ -27,6 +28,7 @@ import org.jboss.logging.Logger; @ApplicationScoped public class AutomationServiceImpl implements AutomationService { private static final Logger LOGGER = Logger.getLogger(AutomationServiceImpl.class); + private static final String MESSAGE = "Retrieved %s"; private final DeviceService deviceService; private final ContextService contextService; @@ -43,14 +45,13 @@ public class AutomationServiceImpl implements AutomationService { final var deserializedDeviceUni = contextService.getDevice(deviceId); deserializedDeviceUni - // TODO fix subscribe .subscribe() .with( device -> { final var id = deviceId; if (!device.isEnabled()) { - LOGGER.infof("Retrieved %s", device); + LOGGER.infof(MESSAGE, device); final var initialConfiguration = deviceService.getInitialConfiguration(device.getDeviceId()); @@ -91,7 +92,7 @@ public class AutomationServiceImpl implements AutomationService { device -> { final var id = deviceId; - LOGGER.infof("Retrieved %s", device); + LOGGER.infof(MESSAGE, device); final var empty = deviceService.deleteDevice(device.getDeviceId()); @@ -102,4 +103,30 @@ public class AutomationServiceImpl implements AutomationService { return deserializedDeviceUni; } + + @Override + public Uni<Device> updateDevice(String deviceId, DeviceConfig deviceConfig) { + final var deserializedDeviceUni = contextService.getDevice(deviceId); + + deserializedDeviceUni + .subscribe() + .with( + device -> { + final var id = deviceId; + + LOGGER.infof(MESSAGE, device); + device.setDeviceConfiguration(deviceConfig); + final var updatedDeviceIdUni = deviceService.configureDevice(device); + + updatedDeviceIdUni + .subscribe() + .with( + configuredDeviceId -> + LOGGER.infof( + "Device [%s] has been updated successfully with %s.\n", + id, deviceConfig)); + }); + + return deserializedDeviceUni; + } } diff --git a/src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java b/src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java index 0bf89c4e6760cac77faad34f9fb9dfdf0ca6e30f..ce977d1ff24788c471ab6bf2c8d6b2c113fb5c63 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java +++ b/src/automation/src/main/java/eu/teraflow/automation/ContextSubscriber.java @@ -77,8 +77,10 @@ public class ContextSubscriber { LOGGER.infof("Received %s for device [%s]", event, deviceId); automationService.deleteDevice(deviceEvent.getDeviceId()); break; - case UPDATE: + // TODO a DeviceConfig object should be part of the DeviceEvent object in order + // for automationService.updateDevice() to be triggered automatically like + // addDevice(). case UNDEFINED: logWarningMessage(event, deviceId, eventType); break; diff --git a/src/automation/src/main/java/eu/teraflow/automation/Serializer.java b/src/automation/src/main/java/eu/teraflow/automation/Serializer.java index 248555cda004f9d9cf14e9096dbb109680824ade..4359d60db364b4fb28e2623cb0e832a656e803af 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/Serializer.java +++ b/src/automation/src/main/java/eu/teraflow/automation/Serializer.java @@ -18,6 +18,7 @@ package eu.teraflow.automation; import acl.Acl; import automation.Automation; +import automation.Automation.ZtpDeviceState; import context.ContextOuterClass; import context.ContextOuterClass.ConfigRule_ACL; import context.ContextOuterClass.ConfigRule_Custom; @@ -56,8 +57,10 @@ import eu.teraflow.automation.context.model.LocationTypeRegion; import eu.teraflow.automation.context.model.TopologyId; import eu.teraflow.automation.kpi_sample_types.model.KpiSampleType; import eu.teraflow.automation.model.DeviceRole; +import eu.teraflow.automation.model.DeviceRoleConfig; import eu.teraflow.automation.model.DeviceRoleId; import eu.teraflow.automation.model.DeviceRoleType; +import eu.teraflow.automation.model.DeviceState; import java.util.stream.Collectors; import javax.inject.Singleton; import kpi_sample_types.KpiSampleTypes; @@ -132,6 +135,36 @@ public class Serializer { } } + public Automation.ZtpDeviceState serialize(DeviceState deviceState) { + switch (deviceState) { + case CREATED: + return ZtpDeviceState.ZTP_DEV_STATE_CREATED; + case UPDATED: + return ZtpDeviceState.ZTP_DEV_STATE_UPDATED; + case DELETED: + return ZtpDeviceState.ZTP_DEV_STATE_DELETED; + case UNDEFINED: + return ZtpDeviceState.ZTP_DEV_STATE_UNDEFINED; + default: + return ZtpDeviceState.UNRECOGNIZED; + } + } + + public DeviceState deserialize(Automation.ZtpDeviceState serializedDeviceState) { + switch (serializedDeviceState) { + case ZTP_DEV_STATE_CREATED: + return DeviceState.CREATED; + case ZTP_DEV_STATE_UPDATED: + return DeviceState.UPDATED; + case ZTP_DEV_STATE_DELETED: + return DeviceState.DELETED; + case ZTP_DEV_STATE_UNDEFINED: + case UNRECOGNIZED: + default: + return DeviceState.UNDEFINED; + } + } + public Automation.DeviceRole serialize(DeviceRole deviceRole) { final var builder = Automation.DeviceRole.newBuilder(); final var serializedDeviceRoleId = serialize(deviceRole.getDeviceRoleId()); @@ -150,6 +183,24 @@ public class Serializer { return new DeviceRole(deviceRoleId, deviceRoleType); } + public Automation.DeviceRoleConfig serialize(DeviceRoleConfig deviceRoleConfig) { + final var builder = Automation.DeviceRoleConfig.newBuilder(); + final var serializedDeviceRole = serialize(deviceRoleConfig.getDeviceRole()); + final var serializedDeviceConfig = serialize(deviceRoleConfig.getDeviceConfig()); + + builder.setDevRole(serializedDeviceRole); + builder.setDevConfig(serializedDeviceConfig); + + return builder.build(); + } + + public DeviceRoleConfig deserialize(Automation.DeviceRoleConfig deviceRoleConfig) { + final var deviceRole = deserialize(deviceRoleConfig.getDevRole()); + final var deviceConfig = deserialize(deviceRoleConfig.getDevConfig()); + + return new DeviceRoleConfig(deviceRole, deviceConfig); + } + public ContextOuterClass.EventTypeEnum serialize(EventTypeEnum eventTypeEnum) { switch (eventTypeEnum) { case CREATE: diff --git a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRole.java b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRole.java index 6dffcd1c0300672a3e23fc0ee8372b77b1bb55b7..da2f1c80e2f1433fe0cff6ba5397a86dd1c2da55 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRole.java +++ b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRole.java @@ -34,4 +34,10 @@ public class DeviceRole { public DeviceRoleType getType() { return type; } + + @Override + public String toString() { + return String.format( + "%s:{%s, deviceRoleType:\"%s\"}", getClass().getSimpleName(), id, type.toString()); + } } diff --git a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleConfig.java b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..aae556fff704ec22dac16304e55f31cc185517ad --- /dev/null +++ b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleConfig.java @@ -0,0 +1,43 @@ +/* +* Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package eu.teraflow.automation.model; + +import eu.teraflow.automation.context.model.DeviceConfig; + +public class DeviceRoleConfig { + + private final DeviceRole deviceRole; + private final DeviceConfig deviceConfig; + + public DeviceRoleConfig(DeviceRole deviceRole, DeviceConfig deviceConfig) { + this.deviceRole = deviceRole; + this.deviceConfig = deviceConfig; + } + + public DeviceRole getDeviceRole() { + return deviceRole; + } + + public DeviceConfig getDeviceConfig() { + return deviceConfig; + } + + @Override + public String toString() { + return String.format("%s:{%s, %s}", getClass().getSimpleName(), deviceRole, deviceConfig); + } +} diff --git a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleId.java b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleId.java index b11f42ad054a3446370e123e37c7c13b025711f3..064c4f1e647ce6fded0f67925924d50d582f29e2 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleId.java +++ b/src/automation/src/main/java/eu/teraflow/automation/model/DeviceRoleId.java @@ -33,4 +33,10 @@ public class DeviceRoleId { public String getDeviceId() { return deviceId; } + + @Override + public String toString() { + return String.format( + "%s:{id:\"%s\", deviceId:\"%s\"}", getClass().getSimpleName(), id, deviceId); + } } diff --git a/src/automation/src/test/java/eu/teraflow/automation/AutomationServiceTest.java b/src/automation/src/test/java/eu/teraflow/automation/AutomationServiceTest.java index b1a70a7e0f0933d9d8aa6049c53d75a40ebf14d8..85ed170efbf938b11303d92a6697c89836e0bf70 100644 --- a/src/automation/src/test/java/eu/teraflow/automation/AutomationServiceTest.java +++ b/src/automation/src/test/java/eu/teraflow/automation/AutomationServiceTest.java @@ -38,6 +38,7 @@ import eu.teraflow.automation.context.model.TopologyId; import eu.teraflow.automation.device.DeviceGateway; import eu.teraflow.automation.kpi_sample_types.model.KpiSampleType; import eu.teraflow.automation.model.DeviceRole; +import eu.teraflow.automation.model.DeviceRoleConfig; import eu.teraflow.automation.model.DeviceRoleId; import eu.teraflow.automation.model.DeviceRoleType; import io.quarkus.grpc.GrpcClient; @@ -160,16 +161,68 @@ class AutomationServiceTest { @Test void shouldUpdateDeviceRole() throws ExecutionException, InterruptedException, TimeoutException { CompletableFuture<String> message = new CompletableFuture<>(); + final var DEVICE_ID = "0f14d0ab-9608-7862-a9e4-5ed26688389b"; final var DEVICE_ROLE_ID = "0f14d0ab-9608-7862-a9e4-5ed26688389a"; + final var DEVICE_TYPE = "ztp"; + + final var deviceDrivers = List.of(DeviceDriverEnum.IETF_NETWORK_TOPOLOGY, DeviceDriverEnum.P4); + + final var topologyIdA = new TopologyId("contextIdA", "idA"); + final var deviceIdA = "deviceIdA"; + final var idA = "idA"; + final var endPointIdA = new EndPointId(topologyIdA, deviceIdA, idA); + + final var endPointTypeA = "endPointTypeA"; + final var kpiSampleTypesA = + List.of(KpiSampleType.BYTES_RECEIVED, KpiSampleType.BYTES_TRANSMITTED); + final var locationTypeRegionA = new LocationTypeRegion("ATH"); + final var locationA = new Location(locationTypeRegionA); + final var endPointA = + new EndPointBuilder(endPointIdA, endPointTypeA, kpiSampleTypesA) + .location(locationA) + .build(); + + final var topologyIdB = new TopologyId("contextIdB", "idB"); + final var deviceIdB = "deviceIdB"; + final var idB = "idB"; + final var endPointIdB = new EndPointId(topologyIdB, deviceIdB, idB); + final var endPointTypeB = "endPointTypeB"; + final var kpiSampleTypesB = + List.of(KpiSampleType.BYTES_RECEIVED, KpiSampleType.BYTES_TRANSMITTED); + final var locationTypeRegionB = new LocationTypeRegion("ATH"); + final var locationB = new Location(locationTypeRegionB); + final var endPointB = + new EndPointBuilder(endPointIdB, endPointTypeB, kpiSampleTypesB) + .location(locationB) + .build(); + + final var endPoints = List.of(endPointA, endPointB); + + final var emptyDeviceConfig = new DeviceConfig(List.of()); + final var device = + new Device( + DEVICE_ID, + DEVICE_TYPE, + emptyDeviceConfig, + DeviceOperationalStatus.ENABLED, + deviceDrivers, + endPoints); + Mockito.when(contextGateway.getDevice(Mockito.any())).thenReturn(Uni.createFrom().item(device)); final var deviceRoleId = new DeviceRoleId(DEVICE_ROLE_ID, DEVICE_ID); - final var deviceRoleType = DeviceRoleType.DEV_CONF; - final var deviceRole = new DeviceRole(deviceRoleId, deviceRoleType); - final var serializedDeviceRole = serializer.serialize(deviceRole); + final var deviceRole = new DeviceRole(deviceRoleId, DeviceRoleType.DEV_OPS); + + final var configRuleCustomA = new ConfigRuleCustom("resourceKeyA", "resourceValueA"); + final var configRuleTypeA = new ConfigRuleTypeCustom(configRuleCustomA); + final var deviceConfig = + new DeviceConfig(List.of(new ConfigRule(ConfigActionEnum.SET, configRuleTypeA))); + + final var deviceRoleConfig = new DeviceRoleConfig(deviceRole, deviceConfig); + final var serializedDeviceRoleConfig = serializer.serialize(deviceRoleConfig); client - .ztpUpdate(serializedDeviceRole) + .ztpUpdate(serializedDeviceRoleConfig) .subscribe() .with( deviceRoleState -> { diff --git a/src/automation/src/test/java/eu/teraflow/automation/SerializerTest.java b/src/automation/src/test/java/eu/teraflow/automation/SerializerTest.java index f8e618cea68f0b125924e0d313b454f93b069c64..74cdc0060230f22ae6c022627a4a8be47a9705b5 100644 --- a/src/automation/src/test/java/eu/teraflow/automation/SerializerTest.java +++ b/src/automation/src/test/java/eu/teraflow/automation/SerializerTest.java @@ -21,6 +21,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import acl.Acl; import automation.Automation; +import automation.Automation.ZtpDeviceState; import context.ContextOuterClass; import context.ContextOuterClass.DeviceId; import context.ContextOuterClass.DeviceOperationalStatusEnum; @@ -55,8 +56,10 @@ import eu.teraflow.automation.context.model.LocationTypeRegion; import eu.teraflow.automation.context.model.TopologyId; import eu.teraflow.automation.kpi_sample_types.model.KpiSampleType; import eu.teraflow.automation.model.DeviceRole; +import eu.teraflow.automation.model.DeviceRoleConfig; import eu.teraflow.automation.model.DeviceRoleId; import eu.teraflow.automation.model.DeviceRoleType; +import eu.teraflow.automation.model.DeviceState; import io.quarkus.test.junit.QuarkusTest; import java.util.List; import java.util.stream.Collectors; @@ -243,6 +246,61 @@ class SerializerTest { assertThat(deviceRole).usingRecursiveComparison().isEqualTo(expectedDeviceRole); } + @Test + void shouldSerializeDeviceRoleConfig() { + final var expectedDevRoleId = new DeviceRoleId("expectedDevRoleId", "expectedDeviceId"); + final var expectedDevRoleType = DeviceRoleType.DEV_OPS; + + final var deviceRole = new DeviceRole(expectedDevRoleId, expectedDevRoleType); + final var serializedDeviceRole = serializer.serialize(deviceRole); + + final var configRuleCustomA = new ConfigRuleCustom("resourceKeyA", "resourceValueA"); + final var configRuleTypeA = new ConfigRuleTypeCustom(configRuleCustomA); + final var deviceConfig = + new DeviceConfig(List.of(new ConfigRule(ConfigActionEnum.SET, configRuleTypeA))); + final var serializedDeviceConfig = serializer.serialize(deviceConfig); + + final var expectedDeviceRoleConfig = + Automation.DeviceRoleConfig.newBuilder() + .setDevRole(serializedDeviceRole) + .setDevConfig(serializedDeviceConfig) + .build(); + + final var deviceRoleConfig = new DeviceRoleConfig(deviceRole, deviceConfig); + final var serializedDeviceRoleConfig = serializer.serialize(deviceRoleConfig); + + assertThat(serializedDeviceRoleConfig) + .usingRecursiveComparison() + .isEqualTo(expectedDeviceRoleConfig); + } + + @Test + void shouldDeserializeDeviceRoleConfig() { + final var expectedDevRoleId = new DeviceRoleId("expectedDevRoleId", "expectedDeviceId"); + final var expectedDevRoleType = DeviceRoleType.DEV_OPS; + + final var deviceRole = new DeviceRole(expectedDevRoleId, expectedDevRoleType); + final var serializedDeviceRole = serializer.serialize(deviceRole); + + final var configRuleCustomA = new ConfigRuleCustom("resourceKeyA", "resourceValueA"); + final var configRuleTypeA = new ConfigRuleTypeCustom(configRuleCustomA); + final var deviceConfig = + new DeviceConfig(List.of(new ConfigRule(ConfigActionEnum.SET, configRuleTypeA))); + final var serializedDeviceConfig = serializer.serialize(deviceConfig); + + final var expectedDeviceRoleConfig = new DeviceRoleConfig(deviceRole, deviceConfig); + + final var serializedDeviceRoleConfig = + Automation.DeviceRoleConfig.newBuilder() + .setDevRole(serializedDeviceRole) + .setDevConfig(serializedDeviceConfig) + .build(); + + final var deviceRoleConfig = serializer.deserialize(serializedDeviceRoleConfig); + + assertThat(deviceRoleConfig).usingRecursiveComparison().isEqualTo(expectedDeviceRoleConfig); + } + private static Stream<Arguments> provideEventTypeEnum() { return Stream.of( Arguments.of(EventTypeEnum.CREATE, ContextOuterClass.EventTypeEnum.EVENTTYPE_CREATE), @@ -267,6 +325,31 @@ class SerializerTest { assertThat(eventType).isEqualTo(expectedEventType); } + private static Stream<Arguments> provideDeviceState() { + return Stream.of( + Arguments.of(DeviceState.CREATED, ZtpDeviceState.ZTP_DEV_STATE_CREATED), + Arguments.of(DeviceState.UPDATED, ZtpDeviceState.ZTP_DEV_STATE_UPDATED), + Arguments.of(DeviceState.DELETED, ZtpDeviceState.ZTP_DEV_STATE_DELETED), + Arguments.of(DeviceState.UNDEFINED, ZtpDeviceState.ZTP_DEV_STATE_UNDEFINED)); + } + + @ParameterizedTest + @MethodSource("provideDeviceState") + void shouldSerializeDeviceState( + DeviceState deviceState, ZtpDeviceState expectedSerializedDeviceState) { + final var serializedDeviceState = serializer.serialize(deviceState); + assertThat(serializedDeviceState.getNumber()) + .isEqualTo(expectedSerializedDeviceState.getNumber()); + } + + @ParameterizedTest + @MethodSource("provideDeviceState") + void shouldDeserializeDeviceState( + DeviceState expectedDeviceState, ZtpDeviceState serializedDeviceState) { + final var deviceState = serializer.deserialize(serializedDeviceState); + assertThat(deviceState).isEqualTo(expectedDeviceState); + } + @Test void shouldSerializeEvent() { final var timestamp = ContextOuterClass.Timestamp.newBuilder().setTimestamp(1).build(); diff --git a/src/automation/target/generated-sources/grpc/automation/Automation.java b/src/automation/target/generated-sources/grpc/automation/Automation.java index f3918e0fc18e6d97b8fd669fb307dcb94964b0e0..cd82f7423092c72c6c2fa02836db645db52f7041 100644 --- a/src/automation/target/generated-sources/grpc/automation/Automation.java +++ b/src/automation/target/generated-sources/grpc/automation/Automation.java @@ -1818,6 +1818,830 @@ public final class Automation { } + public interface DeviceRoleConfigOrBuilder extends + // @@protoc_insertion_point(interface_extends:automation.DeviceRoleConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * <code>.automation.DeviceRole devRole = 1;</code> + * @return Whether the devRole field is set. + */ + boolean hasDevRole(); + /** + * <code>.automation.DeviceRole devRole = 1;</code> + * @return The devRole. + */ + automation.Automation.DeviceRole getDevRole(); + /** + * <code>.automation.DeviceRole devRole = 1;</code> + */ + automation.Automation.DeviceRoleOrBuilder getDevRoleOrBuilder(); + + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + * @return Whether the devConfig field is set. + */ + boolean hasDevConfig(); + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + * @return The devConfig. + */ + context.ContextOuterClass.DeviceConfig getDevConfig(); + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + */ + context.ContextOuterClass.DeviceConfigOrBuilder getDevConfigOrBuilder(); + } + /** + * Protobuf type {@code automation.DeviceRoleConfig} + */ + public static final class DeviceRoleConfig extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:automation.DeviceRoleConfig) + DeviceRoleConfigOrBuilder { + private static final long serialVersionUID = 0L; + // Use DeviceRoleConfig.newBuilder() to construct. + private DeviceRoleConfig(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { + super(builder); + } + private DeviceRoleConfig() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new DeviceRoleConfig(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DeviceRoleConfig( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + automation.Automation.DeviceRole.Builder subBuilder = null; + if (devRole_ != null) { + subBuilder = devRole_.toBuilder(); + } + devRole_ = input.readMessage(automation.Automation.DeviceRole.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(devRole_); + devRole_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + context.ContextOuterClass.DeviceConfig.Builder subBuilder = null; + if (devConfig_ != null) { + subBuilder = devConfig_.toBuilder(); + } + devConfig_ = input.readMessage(context.ContextOuterClass.DeviceConfig.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(devConfig_); + devConfig_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return automation.Automation.internal_static_automation_DeviceRoleConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return automation.Automation.internal_static_automation_DeviceRoleConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + automation.Automation.DeviceRoleConfig.class, automation.Automation.DeviceRoleConfig.Builder.class); + } + + public static final int DEVROLE_FIELD_NUMBER = 1; + private automation.Automation.DeviceRole devRole_; + /** + * <code>.automation.DeviceRole devRole = 1;</code> + * @return Whether the devRole field is set. + */ + @java.lang.Override + public boolean hasDevRole() { + return devRole_ != null; + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + * @return The devRole. + */ + @java.lang.Override + public automation.Automation.DeviceRole getDevRole() { + return devRole_ == null ? automation.Automation.DeviceRole.getDefaultInstance() : devRole_; + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + */ + @java.lang.Override + public automation.Automation.DeviceRoleOrBuilder getDevRoleOrBuilder() { + return getDevRole(); + } + + public static final int DEVCONFIG_FIELD_NUMBER = 2; + private context.ContextOuterClass.DeviceConfig devConfig_; + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + * @return Whether the devConfig field is set. + */ + @java.lang.Override + public boolean hasDevConfig() { + return devConfig_ != null; + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + * @return The devConfig. + */ + @java.lang.Override + public context.ContextOuterClass.DeviceConfig getDevConfig() { + return devConfig_ == null ? context.ContextOuterClass.DeviceConfig.getDefaultInstance() : devConfig_; + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + */ + @java.lang.Override + public context.ContextOuterClass.DeviceConfigOrBuilder getDevConfigOrBuilder() { + return getDevConfig(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (devRole_ != null) { + output.writeMessage(1, getDevRole()); + } + if (devConfig_ != null) { + output.writeMessage(2, getDevConfig()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (devRole_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getDevRole()); + } + if (devConfig_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getDevConfig()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof automation.Automation.DeviceRoleConfig)) { + return super.equals(obj); + } + automation.Automation.DeviceRoleConfig other = (automation.Automation.DeviceRoleConfig) obj; + + if (hasDevRole() != other.hasDevRole()) return false; + if (hasDevRole()) { + if (!getDevRole() + .equals(other.getDevRole())) return false; + } + if (hasDevConfig() != other.hasDevConfig()) return false; + if (hasDevConfig()) { + if (!getDevConfig() + .equals(other.getDevConfig())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasDevRole()) { + hash = (37 * hash) + DEVROLE_FIELD_NUMBER; + hash = (53 * hash) + getDevRole().hashCode(); + } + if (hasDevConfig()) { + hash = (37 * hash) + DEVCONFIG_FIELD_NUMBER; + hash = (53 * hash) + getDevConfig().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static automation.Automation.DeviceRoleConfig parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static automation.Automation.DeviceRoleConfig parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static automation.Automation.DeviceRoleConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static automation.Automation.DeviceRoleConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static automation.Automation.DeviceRoleConfig parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static automation.Automation.DeviceRoleConfig parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static automation.Automation.DeviceRoleConfig parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static automation.Automation.DeviceRoleConfig parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static automation.Automation.DeviceRoleConfig parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static automation.Automation.DeviceRoleConfig parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static automation.Automation.DeviceRoleConfig parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static automation.Automation.DeviceRoleConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(automation.Automation.DeviceRoleConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code automation.DeviceRoleConfig} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements + // @@protoc_insertion_point(builder_implements:automation.DeviceRoleConfig) + automation.Automation.DeviceRoleConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return automation.Automation.internal_static_automation_DeviceRoleConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return automation.Automation.internal_static_automation_DeviceRoleConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + automation.Automation.DeviceRoleConfig.class, automation.Automation.DeviceRoleConfig.Builder.class); + } + + // Construct using automation.Automation.DeviceRoleConfig.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (devRoleBuilder_ == null) { + devRole_ = null; + } else { + devRole_ = null; + devRoleBuilder_ = null; + } + if (devConfigBuilder_ == null) { + devConfig_ = null; + } else { + devConfig_ = null; + devConfigBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return automation.Automation.internal_static_automation_DeviceRoleConfig_descriptor; + } + + @java.lang.Override + public automation.Automation.DeviceRoleConfig getDefaultInstanceForType() { + return automation.Automation.DeviceRoleConfig.getDefaultInstance(); + } + + @java.lang.Override + public automation.Automation.DeviceRoleConfig build() { + automation.Automation.DeviceRoleConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public automation.Automation.DeviceRoleConfig buildPartial() { + automation.Automation.DeviceRoleConfig result = new automation.Automation.DeviceRoleConfig(this); + if (devRoleBuilder_ == null) { + result.devRole_ = devRole_; + } else { + result.devRole_ = devRoleBuilder_.build(); + } + if (devConfigBuilder_ == null) { + result.devConfig_ = devConfig_; + } else { + result.devConfig_ = devConfigBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof automation.Automation.DeviceRoleConfig) { + return mergeFrom((automation.Automation.DeviceRoleConfig)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(automation.Automation.DeviceRoleConfig other) { + if (other == automation.Automation.DeviceRoleConfig.getDefaultInstance()) return this; + if (other.hasDevRole()) { + mergeDevRole(other.getDevRole()); + } + if (other.hasDevConfig()) { + mergeDevConfig(other.getDevConfig()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + automation.Automation.DeviceRoleConfig parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (automation.Automation.DeviceRoleConfig) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private automation.Automation.DeviceRole devRole_; + private com.google.protobuf.SingleFieldBuilderV3< + automation.Automation.DeviceRole, automation.Automation.DeviceRole.Builder, automation.Automation.DeviceRoleOrBuilder> devRoleBuilder_; + /** + * <code>.automation.DeviceRole devRole = 1;</code> + * @return Whether the devRole field is set. + */ + public boolean hasDevRole() { + return devRoleBuilder_ != null || devRole_ != null; + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + * @return The devRole. + */ + public automation.Automation.DeviceRole getDevRole() { + if (devRoleBuilder_ == null) { + return devRole_ == null ? automation.Automation.DeviceRole.getDefaultInstance() : devRole_; + } else { + return devRoleBuilder_.getMessage(); + } + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + */ + public Builder setDevRole(automation.Automation.DeviceRole value) { + if (devRoleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + devRole_ = value; + onChanged(); + } else { + devRoleBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + */ + public Builder setDevRole( + automation.Automation.DeviceRole.Builder builderForValue) { + if (devRoleBuilder_ == null) { + devRole_ = builderForValue.build(); + onChanged(); + } else { + devRoleBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + */ + public Builder mergeDevRole(automation.Automation.DeviceRole value) { + if (devRoleBuilder_ == null) { + if (devRole_ != null) { + devRole_ = + automation.Automation.DeviceRole.newBuilder(devRole_).mergeFrom(value).buildPartial(); + } else { + devRole_ = value; + } + onChanged(); + } else { + devRoleBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + */ + public Builder clearDevRole() { + if (devRoleBuilder_ == null) { + devRole_ = null; + onChanged(); + } else { + devRole_ = null; + devRoleBuilder_ = null; + } + + return this; + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + */ + public automation.Automation.DeviceRole.Builder getDevRoleBuilder() { + + onChanged(); + return getDevRoleFieldBuilder().getBuilder(); + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + */ + public automation.Automation.DeviceRoleOrBuilder getDevRoleOrBuilder() { + if (devRoleBuilder_ != null) { + return devRoleBuilder_.getMessageOrBuilder(); + } else { + return devRole_ == null ? + automation.Automation.DeviceRole.getDefaultInstance() : devRole_; + } + } + /** + * <code>.automation.DeviceRole devRole = 1;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + automation.Automation.DeviceRole, automation.Automation.DeviceRole.Builder, automation.Automation.DeviceRoleOrBuilder> + getDevRoleFieldBuilder() { + if (devRoleBuilder_ == null) { + devRoleBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + automation.Automation.DeviceRole, automation.Automation.DeviceRole.Builder, automation.Automation.DeviceRoleOrBuilder>( + getDevRole(), + getParentForChildren(), + isClean()); + devRole_ = null; + } + return devRoleBuilder_; + } + + private context.ContextOuterClass.DeviceConfig devConfig_; + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.DeviceConfig, context.ContextOuterClass.DeviceConfig.Builder, context.ContextOuterClass.DeviceConfigOrBuilder> devConfigBuilder_; + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + * @return Whether the devConfig field is set. + */ + public boolean hasDevConfig() { + return devConfigBuilder_ != null || devConfig_ != null; + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + * @return The devConfig. + */ + public context.ContextOuterClass.DeviceConfig getDevConfig() { + if (devConfigBuilder_ == null) { + return devConfig_ == null ? context.ContextOuterClass.DeviceConfig.getDefaultInstance() : devConfig_; + } else { + return devConfigBuilder_.getMessage(); + } + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + */ + public Builder setDevConfig(context.ContextOuterClass.DeviceConfig value) { + if (devConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + devConfig_ = value; + onChanged(); + } else { + devConfigBuilder_.setMessage(value); + } + + return this; + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + */ + public Builder setDevConfig( + context.ContextOuterClass.DeviceConfig.Builder builderForValue) { + if (devConfigBuilder_ == null) { + devConfig_ = builderForValue.build(); + onChanged(); + } else { + devConfigBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + */ + public Builder mergeDevConfig(context.ContextOuterClass.DeviceConfig value) { + if (devConfigBuilder_ == null) { + if (devConfig_ != null) { + devConfig_ = + context.ContextOuterClass.DeviceConfig.newBuilder(devConfig_).mergeFrom(value).buildPartial(); + } else { + devConfig_ = value; + } + onChanged(); + } else { + devConfigBuilder_.mergeFrom(value); + } + + return this; + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + */ + public Builder clearDevConfig() { + if (devConfigBuilder_ == null) { + devConfig_ = null; + onChanged(); + } else { + devConfig_ = null; + devConfigBuilder_ = null; + } + + return this; + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + */ + public context.ContextOuterClass.DeviceConfig.Builder getDevConfigBuilder() { + + onChanged(); + return getDevConfigFieldBuilder().getBuilder(); + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + */ + public context.ContextOuterClass.DeviceConfigOrBuilder getDevConfigOrBuilder() { + if (devConfigBuilder_ != null) { + return devConfigBuilder_.getMessageOrBuilder(); + } else { + return devConfig_ == null ? + context.ContextOuterClass.DeviceConfig.getDefaultInstance() : devConfig_; + } + } + /** + * <code>.context.DeviceConfig devConfig = 2;</code> + */ + private com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.DeviceConfig, context.ContextOuterClass.DeviceConfig.Builder, context.ContextOuterClass.DeviceConfigOrBuilder> + getDevConfigFieldBuilder() { + if (devConfigBuilder_ == null) { + devConfigBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + context.ContextOuterClass.DeviceConfig, context.ContextOuterClass.DeviceConfig.Builder, context.ContextOuterClass.DeviceConfigOrBuilder>( + getDevConfig(), + getParentForChildren(), + isClean()); + devConfig_ = null; + } + return devConfigBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:automation.DeviceRoleConfig) + } + + // @@protoc_insertion_point(class_scope:automation.DeviceRoleConfig) + private static final automation.Automation.DeviceRoleConfig DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new automation.Automation.DeviceRoleConfig(); + } + + public static automation.Automation.DeviceRoleConfig getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser<DeviceRoleConfig> + PARSER = new com.google.protobuf.AbstractParser<DeviceRoleConfig>() { + @java.lang.Override + public DeviceRoleConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DeviceRoleConfig(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser<DeviceRoleConfig> parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser<DeviceRoleConfig> getParserForType() { + return PARSER; + } + + @java.lang.Override + public automation.Automation.DeviceRoleConfig getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + public interface DeviceRoleListOrBuilder extends // @@protoc_insertion_point(interface_extends:automation.DeviceRoleList) com.google.protobuf.MessageOrBuilder { @@ -3987,6 +4811,11 @@ public final class Automation { private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_automation_DeviceRole_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_automation_DeviceRoleConfig_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_automation_DeviceRoleConfig_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_automation_DeviceRoleList_descriptor; private static final @@ -4016,29 +4845,32 @@ public final class Automation { "2\r.context.Uuid\022 \n\005devId\030\002 \001(\0132\021.context" + ".DeviceId\"j\n\nDeviceRole\022+\n\tdevRoleId\030\001 \001" + "(\0132\030.automation.DeviceRoleId\022/\n\013devRoleT" + - "ype\030\002 \001(\0162\032.automation.DeviceRoleType\"9\n" + - "\016DeviceRoleList\022\'\n\007devRole\030\001 \003(\0132\026.autom" + - "ation.DeviceRole\"p\n\017DeviceRoleState\022+\n\td" + - "evRoleId\030\001 \001(\0132\030.automation.DeviceRoleId" + - "\0220\n\014devRoleState\030\002 \001(\0162\032.automation.ZtpD" + - "eviceState\"\'\n\024DeviceDeletionResult\022\017\n\007de" + - "leted\030\001 \003(\t*H\n\016DeviceRoleType\022\010\n\004NONE\020\000\022" + - "\013\n\007DEV_OPS\020\001\022\014\n\010DEV_CONF\020\002\022\021\n\rPIPELINE_C" + - "ONF\020\003*~\n\016ZtpDeviceState\022\033\n\027ZTP_DEV_STATE" + - "_UNDEFINED\020\000\022\031\n\025ZTP_DEV_STATE_CREATED\020\001\022" + - "\031\n\025ZTP_DEV_STATE_UPDATED\020\002\022\031\n\025ZTP_DEV_ST" + - "ATE_DELETED\020\0032\270\003\n\021AutomationService\022F\n\020Z" + - "tpGetDeviceRole\022\030.automation.DeviceRoleI" + - "d\032\026.automation.DeviceRole\"\000\022N\n\033ZtpGetDev" + - "iceRolesByDeviceId\022\021.context.DeviceId\032\032." + - "automation.DeviceRoleList\"\000\022?\n\006ZtpAdd\022\026." + - "automation.DeviceRole\032\033.automation.Devic" + - "eRoleState\"\000\022B\n\tZtpUpdate\022\026.automation.D" + - "eviceRole\032\033.automation.DeviceRoleState\"\000" + - "\022B\n\tZtpDelete\022\026.automation.DeviceRole\032\033." + - "automation.DeviceRoleState\"\000\022B\n\014ZtpDelet" + - "eAll\022\016.context.Empty\032 .automation.Device" + - "DeletionResult\"\000b\006proto3" + "ype\030\002 \001(\0162\032.automation.DeviceRoleType\"e\n" + + "\020DeviceRoleConfig\022\'\n\007devRole\030\001 \001(\0132\026.aut" + + "omation.DeviceRole\022(\n\tdevConfig\030\002 \001(\0132\025." + + "context.DeviceConfig\"9\n\016DeviceRoleList\022\'" + + "\n\007devRole\030\001 \003(\0132\026.automation.DeviceRole\"" + + "p\n\017DeviceRoleState\022+\n\tdevRoleId\030\001 \001(\0132\030." + + "automation.DeviceRoleId\0220\n\014devRoleState\030" + + "\002 \001(\0162\032.automation.ZtpDeviceState\"\'\n\024Dev" + + "iceDeletionResult\022\017\n\007deleted\030\001 \003(\t*H\n\016De" + + "viceRoleType\022\010\n\004NONE\020\000\022\013\n\007DEV_OPS\020\001\022\014\n\010D" + + "EV_CONF\020\002\022\021\n\rPIPELINE_CONF\020\003*~\n\016ZtpDevic" + + "eState\022\033\n\027ZTP_DEV_STATE_UNDEFINED\020\000\022\031\n\025Z" + + "TP_DEV_STATE_CREATED\020\001\022\031\n\025ZTP_DEV_STATE_" + + "UPDATED\020\002\022\031\n\025ZTP_DEV_STATE_DELETED\020\0032\276\003\n" + + "\021AutomationService\022F\n\020ZtpGetDeviceRole\022\030" + + ".automation.DeviceRoleId\032\026.automation.De" + + "viceRole\"\000\022N\n\033ZtpGetDeviceRolesByDeviceI" + + "d\022\021.context.DeviceId\032\032.automation.Device" + + "RoleList\"\000\022?\n\006ZtpAdd\022\026.automation.Device" + + "Role\032\033.automation.DeviceRoleState\"\000\022H\n\tZ" + + "tpUpdate\022\034.automation.DeviceRoleConfig\032\033" + + ".automation.DeviceRoleState\"\000\022B\n\tZtpDele" + + "te\022\026.automation.DeviceRole\032\033.automation." + + "DeviceRoleState\"\000\022B\n\014ZtpDeleteAll\022\016.cont" + + "ext.Empty\032 .automation.DeviceDeletionRes" + + "ult\"\000b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -4057,20 +4889,26 @@ public final class Automation { com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_automation_DeviceRole_descriptor, new java.lang.String[] { "DevRoleId", "DevRoleType", }); - internal_static_automation_DeviceRoleList_descriptor = + internal_static_automation_DeviceRoleConfig_descriptor = getDescriptor().getMessageTypes().get(2); + internal_static_automation_DeviceRoleConfig_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_automation_DeviceRoleConfig_descriptor, + new java.lang.String[] { "DevRole", "DevConfig", }); + internal_static_automation_DeviceRoleList_descriptor = + getDescriptor().getMessageTypes().get(3); internal_static_automation_DeviceRoleList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_automation_DeviceRoleList_descriptor, new java.lang.String[] { "DevRole", }); internal_static_automation_DeviceRoleState_descriptor = - getDescriptor().getMessageTypes().get(3); + getDescriptor().getMessageTypes().get(4); internal_static_automation_DeviceRoleState_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_automation_DeviceRoleState_descriptor, new java.lang.String[] { "DevRoleId", "DevRoleState", }); internal_static_automation_DeviceDeletionResult_descriptor = - getDescriptor().getMessageTypes().get(4); + getDescriptor().getMessageTypes().get(5); internal_static_automation_DeviceDeletionResult_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_automation_DeviceDeletionResult_descriptor, diff --git a/src/automation/target/generated-sources/grpc/automation/AutomationService.java b/src/automation/target/generated-sources/grpc/automation/AutomationService.java index 4df9e1098d2028bba58da0959512310ed3d2c4ba..8ef5784815a7b8bb6d51b05f89f6ca3a4b23f2e5 100644 --- a/src/automation/target/generated-sources/grpc/automation/AutomationService.java +++ b/src/automation/target/generated-sources/grpc/automation/AutomationService.java @@ -14,7 +14,7 @@ public interface AutomationService extends MutinyService { io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpAdd(automation.Automation.DeviceRole request); - io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRole request); + io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRoleConfig request); io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpDelete(automation.Automation.DeviceRole request); diff --git a/src/automation/target/generated-sources/grpc/automation/AutomationServiceBean.java b/src/automation/target/generated-sources/grpc/automation/AutomationServiceBean.java index 74d420a1ee8c3c11f824c30fb96f694ddddc64fe..3c7923a0ce8a1501689d1bb567c915590376cf5f 100644 --- a/src/automation/target/generated-sources/grpc/automation/AutomationServiceBean.java +++ b/src/automation/target/generated-sources/grpc/automation/AutomationServiceBean.java @@ -40,7 +40,7 @@ public class AutomationServiceBean extends MutinyAutomationServiceGrpc.Automatio } } @Override - public io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRole request) { + public io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRoleConfig request) { try { return delegate.ztpUpdate(request); } catch (UnsupportedOperationException e) { diff --git a/src/automation/target/generated-sources/grpc/automation/AutomationServiceClient.java b/src/automation/target/generated-sources/grpc/automation/AutomationServiceClient.java index 9dcad532a0238f6f14d8e6ca2aa64b445747e9e6..13d13c431b63baebd22ed7fd566b6b25395977e3 100644 --- a/src/automation/target/generated-sources/grpc/automation/AutomationServiceClient.java +++ b/src/automation/target/generated-sources/grpc/automation/AutomationServiceClient.java @@ -33,7 +33,7 @@ public class AutomationServiceClient implements AutomationService, MutinyClient< return stub.ztpAdd(request); } @Override - public io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRole request) { + public io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRoleConfig request) { return stub.ztpUpdate(request); } @Override diff --git a/src/automation/target/generated-sources/grpc/automation/AutomationServiceGrpc.java b/src/automation/target/generated-sources/grpc/automation/AutomationServiceGrpc.java index 25f5feaf327702102d1ec6cd9ca6cc8ab74cf14f..841994ea713bb9d1c0223689386d6cae35c6d014 100644 --- a/src/automation/target/generated-sources/grpc/automation/AutomationServiceGrpc.java +++ b/src/automation/target/generated-sources/grpc/automation/AutomationServiceGrpc.java @@ -107,27 +107,27 @@ public final class AutomationServiceGrpc { return getZtpAddMethod; } - private static volatile io.grpc.MethodDescriptor<automation.Automation.DeviceRole, + private static volatile io.grpc.MethodDescriptor<automation.Automation.DeviceRoleConfig, automation.Automation.DeviceRoleState> getZtpUpdateMethod; @io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "ZtpUpdate", - requestType = automation.Automation.DeviceRole.class, + requestType = automation.Automation.DeviceRoleConfig.class, responseType = automation.Automation.DeviceRoleState.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor<automation.Automation.DeviceRole, + public static io.grpc.MethodDescriptor<automation.Automation.DeviceRoleConfig, automation.Automation.DeviceRoleState> getZtpUpdateMethod() { - io.grpc.MethodDescriptor<automation.Automation.DeviceRole, automation.Automation.DeviceRoleState> getZtpUpdateMethod; + io.grpc.MethodDescriptor<automation.Automation.DeviceRoleConfig, automation.Automation.DeviceRoleState> getZtpUpdateMethod; if ((getZtpUpdateMethod = AutomationServiceGrpc.getZtpUpdateMethod) == null) { synchronized (AutomationServiceGrpc.class) { if ((getZtpUpdateMethod = AutomationServiceGrpc.getZtpUpdateMethod) == null) { AutomationServiceGrpc.getZtpUpdateMethod = getZtpUpdateMethod = - io.grpc.MethodDescriptor.<automation.Automation.DeviceRole, automation.Automation.DeviceRoleState>newBuilder() + io.grpc.MethodDescriptor.<automation.Automation.DeviceRoleConfig, automation.Automation.DeviceRoleState>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ZtpUpdate")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( - automation.Automation.DeviceRole.getDefaultInstance())) + automation.Automation.DeviceRoleConfig.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( automation.Automation.DeviceRoleState.getDefaultInstance())) .setSchemaDescriptor(new AutomationServiceMethodDescriptorSupplier("ZtpUpdate")) @@ -271,7 +271,7 @@ public final class AutomationServiceGrpc { /** */ - public void ztpUpdate(automation.Automation.DeviceRole request, + public void ztpUpdate(automation.Automation.DeviceRoleConfig request, io.grpc.stub.StreamObserver<automation.Automation.DeviceRoleState> responseObserver) { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getZtpUpdateMethod(), responseObserver); } @@ -317,7 +317,7 @@ public final class AutomationServiceGrpc { getZtpUpdateMethod(), io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< - automation.Automation.DeviceRole, + automation.Automation.DeviceRoleConfig, automation.Automation.DeviceRoleState>( this, METHODID_ZTP_UPDATE))) .addMethod( @@ -378,7 +378,7 @@ public final class AutomationServiceGrpc { /** */ - public void ztpUpdate(automation.Automation.DeviceRole request, + public void ztpUpdate(automation.Automation.DeviceRoleConfig request, io.grpc.stub.StreamObserver<automation.Automation.DeviceRoleState> responseObserver) { io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getZtpUpdateMethod(), getCallOptions()), request, responseObserver); @@ -438,7 +438,7 @@ public final class AutomationServiceGrpc { /** */ - public automation.Automation.DeviceRoleState ztpUpdate(automation.Automation.DeviceRole request) { + public automation.Automation.DeviceRoleState ztpUpdate(automation.Automation.DeviceRoleConfig request) { return io.grpc.stub.ClientCalls.blockingUnaryCall( getChannel(), getZtpUpdateMethod(), getCallOptions(), request); } @@ -499,7 +499,7 @@ public final class AutomationServiceGrpc { /** */ public com.google.common.util.concurrent.ListenableFuture<automation.Automation.DeviceRoleState> ztpUpdate( - automation.Automation.DeviceRole request) { + automation.Automation.DeviceRoleConfig request) { return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getZtpUpdateMethod(), getCallOptions()), request); } @@ -558,7 +558,7 @@ public final class AutomationServiceGrpc { (io.grpc.stub.StreamObserver<automation.Automation.DeviceRoleState>) responseObserver); break; case METHODID_ZTP_UPDATE: - serviceImpl.ztpUpdate((automation.Automation.DeviceRole) request, + serviceImpl.ztpUpdate((automation.Automation.DeviceRoleConfig) request, (io.grpc.stub.StreamObserver<automation.Automation.DeviceRoleState>) responseObserver); break; case METHODID_ZTP_DELETE: diff --git a/src/automation/target/generated-sources/grpc/automation/MutinyAutomationServiceGrpc.java b/src/automation/target/generated-sources/grpc/automation/MutinyAutomationServiceGrpc.java index 9b641fcdd7733828c58ce563651ac3d46e697287..64565286ca36fd0b820c000e466954144207ab0b 100644 --- a/src/automation/target/generated-sources/grpc/automation/MutinyAutomationServiceGrpc.java +++ b/src/automation/target/generated-sources/grpc/automation/MutinyAutomationServiceGrpc.java @@ -51,7 +51,7 @@ public final class MutinyAutomationServiceGrpc implements io.quarkus.grpc.runtim } - public io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRole request) { + public io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRoleConfig request) { return io.quarkus.grpc.runtime.ClientCalls.oneToOne(request, delegateStub::ztpUpdate); } @@ -98,7 +98,7 @@ public final class MutinyAutomationServiceGrpc implements io.quarkus.grpc.runtim } - public io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRole request) { + public io.smallrye.mutiny.Uni<automation.Automation.DeviceRoleState> ztpUpdate(automation.Automation.DeviceRoleConfig request) { throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED); } @@ -139,7 +139,7 @@ public final class MutinyAutomationServiceGrpc implements io.quarkus.grpc.runtim automation.AutomationServiceGrpc.getZtpUpdateMethod(), asyncUnaryCall( new MethodHandlers< - automation.Automation.DeviceRole, + automation.Automation.DeviceRoleConfig, automation.Automation.DeviceRoleState>( this, METHODID_ZTP_UPDATE, compression))) .addMethod( @@ -205,7 +205,7 @@ public final class MutinyAutomationServiceGrpc implements io.quarkus.grpc.runtim serviceImpl::ztpAdd); break; case METHODID_ZTP_UPDATE: - io.quarkus.grpc.runtime.ServerCalls.oneToOne((automation.Automation.DeviceRole) request, + io.quarkus.grpc.runtime.ServerCalls.oneToOne((automation.Automation.DeviceRoleConfig) request, (io.grpc.stub.StreamObserver<automation.Automation.DeviceRoleState>) responseObserver, compression, serviceImpl::ztpUpdate); diff --git a/src/automation/target/kubernetes/kubernetes.yml b/src/automation/target/kubernetes/kubernetes.yml index 399d43a2e71ba5c507a1b78bb8771f0c0f05f8c6..1fc788787ff527647cb920ffa74b270171ab1b6d 100644 --- a/src/automation/target/kubernetes/kubernetes.yml +++ b/src/automation/target/kubernetes/kubernetes.yml @@ -3,8 +3,8 @@ apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: efb79e125321a3ea074cb90221a1b1d56dee5153 - app.quarkus.io/build-timestamp: 2022-08-30 - 14:08:06 +0000 + app.quarkus.io/commit-id: 80cfc0874138153f72a2a673fc4d040be707e899 + app.quarkus.io/build-timestamp: 2022-08-31 - 09:25:37 +0000 labels: app.kubernetes.io/name: automationservice app: automationservice @@ -25,8 +25,8 @@ apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: efb79e125321a3ea074cb90221a1b1d56dee5153 - app.quarkus.io/build-timestamp: 2022-08-30 - 14:08:06 +0000 + app.quarkus.io/commit-id: 80cfc0874138153f72a2a673fc4d040be707e899 + app.quarkus.io/build-timestamp: 2022-08-31 - 09:25:37 +0000 labels: app: automationservice app.kubernetes.io/name: automationservice @@ -39,8 +39,8 @@ spec: template: metadata: annotations: - app.quarkus.io/commit-id: efb79e125321a3ea074cb90221a1b1d56dee5153 - app.quarkus.io/build-timestamp: 2022-08-30 - 14:08:06 +0000 + app.quarkus.io/commit-id: 80cfc0874138153f72a2a673fc4d040be707e899 + app.quarkus.io/build-timestamp: 2022-08-31 - 09:25:37 +0000 labels: app: automationservice app.kubernetes.io/name: automationservice