diff --git a/sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigCenterType.java b/sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigCenterType.java new file mode 100644 index 0000000000..d38aa73a31 --- /dev/null +++ b/sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigCenterType.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024-2024 Sermant Authors. All rights reserved. + * + * 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 io.sermant.backend.entity.config; + +/** + * Enum for DynamicConfigType + * + * @author zhp + * @since 2024-05-22 + */ +public enum ConfigCenterType { + /** + * zookeeper configuration center + */ + ZOOKEEPER, + + /** + * servicecomb-kie configuration center + */ + KIE, + + /** + * Nacos configuration center + */ + NACOS, + + /** + * no configuration center implementation + */ + NOP; +} diff --git a/sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigInfo.java b/sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigInfo.java new file mode 100644 index 0000000000..622421d108 --- /dev/null +++ b/sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigInfo.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2024-2024 Sermant Authors. All rights reserved. + * + * 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 io.sermant.backend.entity.config; + +import lombok.Getter; +import lombok.Setter; + +/** + * configuration information + * + * @author zhp + * @since 2024-05-16 + */ +@Getter +@Setter +public class ConfigInfo { + /** + * plugin type, the plugin to which the configuration item belongs + */ + private String pluginType; + + /** + * The namespace to which the configuration item belongs, only used by the nacos configuration center + */ + private String namespace; + + /** + * Service name, when not empty, the configuration item only takes effect on microservices + * with the same service name + */ + private String serviceName; + + /** + * Environment name, when not empty, the configuration item only takes effect for microservices in that environment + */ + private String environment; + + /** + * Application name, when not empty, the current configuration item only applies to microservices + * under that application + */ + private String appName; + + /** + * Zone name, when not empty, the configuration item only applies to microservices in that zone + */ + private String zone; + + /** + * Grouping name for configuration items + */ + private String group; + + /** + * The key of the configuration item + */ + private String key; + + /** + * Configuration Content + */ + private String content; +} diff --git a/sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigServerInfo.java b/sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigServerInfo.java new file mode 100644 index 0000000000..4bda69de2c --- /dev/null +++ b/sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigServerInfo.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024-2024 Sermant Authors. All rights reserved. + * + * 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 io.sermant.backend.entity.config; + +import lombok.Getter; +import lombok.Setter; + +/** + * Configuration Center Information + * + * @author zhp + * @since 2024-05-16 + */ +@Getter +@Setter +public class ConfigServerInfo { + /** + * Configuration Center Address + */ + private String serverAddress; + + /** + * userName, authentication for Configuration Center + */ + private String userName; + + /** + * password, authentication for Configuration Center + */ + private String password; + + /** + * secret key, used for encryption and decryption of passwords + */ + private String secretKey; + + /** + * Type of Configuration Center + */ + private String dynamicConfigType; +} diff --git a/sermant-backend/src/main/java/io/sermant/backend/entity/config/Result.java b/sermant-backend/src/main/java/io/sermant/backend/entity/config/Result.java new file mode 100644 index 0000000000..b3df1d17a5 --- /dev/null +++ b/sermant-backend/src/main/java/io/sermant/backend/entity/config/Result.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2024-2024 Sermant Authors. All rights reserved. + * + * 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 io.sermant.backend.entity.config; + +import lombok.Getter; +import lombok.Setter; + +/** + * Result information + * + * @param Result data type + * @author zhp + * @since 2024-05-16 + */ +@Getter +@Setter +public class Result { + /** + * Result Code, the corresponding enumeration is ResultCodeType + */ + private String code; + + /** + * Result message + */ + private String message; + + /** + * Result data + */ + private R data; + + /** + * Constructor + * + * @param code result code + * @param message result message + */ + public Result(String code, String message) { + this.code = code; + this.message = message; + } + + /** + * Constructor + * + * @param code result code + * @param message result message + * @param data result data + */ + public Result(String code, String message, R data) { + this.code = code; + this.message = message; + this.data = data; + } + + /** + * Is the result successful + * + * @return true:success false: fail + */ + public boolean isSuccess() { + return ResultCodeType.SUCCESS.getCode().equals(this.code); + } +} diff --git a/sermant-backend/src/main/java/io/sermant/backend/entity/config/ResultCodeType.java b/sermant-backend/src/main/java/io/sermant/backend/entity/config/ResultCodeType.java new file mode 100644 index 0000000000..a8f8846b21 --- /dev/null +++ b/sermant-backend/src/main/java/io/sermant/backend/entity/config/ResultCodeType.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2024-2024 Sermant Authors. All rights reserved. + * + * 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 io.sermant.backend.entity.config; + +import lombok.Getter; + +/** + * Result encoding type + * + * @author zhp + * @since 2024-05-16 + */ +@Getter +public enum ResultCodeType { + /** + * Interface call successful + */ + SUCCESS("00", "Success."), + + /** + * Unable to establish connection with Configuration Center + */ + CONNECT_FAIL("01", "Unable to establish connection with Configuration Center."), + + /** + * Configuration query failed + */ + QUERY_FAIL("02", "Configuration query failed."), + + /** + * configuration item already exists + */ + EXISTS("03", "configuration item already exists."), + + /** + * Failed to add configuration + */ + ADD_FAIL("04", "Failed to add configuration."), + + /** + * Failed to modify configuration + */ + MODIFY_FAIL("05", "Failed to modify configuration."), + + /** + * Failed to delete configuration + */ + DELETE_FAIL("06", "Failed to delete configuration."), + + /** + * Configuration does not exist + */ + NOT_EXISTS("07", "Configuration does not exist."), + + /** + * Missing parameter information + */ + MISS_PARAM("08", "Missing parameter information."), + + /** + * Interface call failed + */ + FAIL("09", "Failure."); + + private final String code; + + private final String message; + + ResultCodeType(String code, String message) { + this.code = code; + this.message = message; + } +}