forked from apache/hertzbeat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Implement custom parameters for plugins (apache#2616)
Signed-off-by: liutianyou <[email protected]> Co-authored-by: shown <[email protected]> Co-authored-by: Kerwin Bryant <[email protected]> Co-authored-by: Logic <[email protected]> Co-authored-by: liutianyou <[email protected]>
- Loading branch information
1 parent
24678c2
commit 0e49e10
Showing
17 changed files
with
491 additions
and
26 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
48 changes: 48 additions & 0 deletions
48
manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.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,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.hertzbeat.manager.dao; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
import org.apache.hertzbeat.manager.pojo.dto.PluginParam; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
/** | ||
* PluginParamDao database operations | ||
*/ | ||
public interface PluginParamDao extends JpaRepository<PluginParam, Long> { | ||
|
||
/** | ||
* Query the list of parameters associated with the monitoring ID' | ||
* @param pluginMetadataId Monitor ID | ||
* @return list of parameter values | ||
*/ | ||
List<PluginParam> findParamsByPluginMetadataId(Long pluginMetadataId); | ||
|
||
/** | ||
* Remove the parameter list associated with the pluginMetadata ID based on it | ||
* @param pluginMetadataId Monitor Id | ||
*/ | ||
void deletePluginParamsByPluginMetadataId(long pluginMetadataId); | ||
|
||
/** | ||
* Remove the parameter list associated with the pluginMetadata ID list based on it | ||
* @param pluginMetadataIds Monitoring ID List | ||
*/ | ||
void deletePluginParamsByPluginMetadataIdIn(Set<Long> pluginMetadataIds); | ||
} |
110 changes: 110 additions & 0 deletions
110
manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParam.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,110 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.hertzbeat.manager.pojo.dto; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY; | ||
import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_WRITE; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Index; | ||
import jakarta.persistence.Table; | ||
import jakarta.persistence.UniqueConstraint; | ||
import jakarta.validation.constraints.Min; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
/** | ||
* PluginParam | ||
*/ | ||
@Entity | ||
@Table(name = "hzb_plugin_param", indexes = { @Index(columnList = "pluginMetadataId") }, | ||
uniqueConstraints = @UniqueConstraint(columnNames = {"pluginMetadataId", "field"})) | ||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Schema(description = "Parameter Entity") | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class PluginParam { | ||
|
||
/** | ||
* Parameter primary key index ID | ||
*/ | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Schema(title = "Parameter primary key index ID", example = "87584674384", accessMode = READ_ONLY) | ||
private Long id; | ||
/** | ||
* Monitor ID | ||
*/ | ||
@Schema(title = "Plugin task ID", example = "875846754543", accessMode = READ_WRITE) | ||
@NotNull | ||
private Long pluginMetadataId; | ||
|
||
/** | ||
* Parameter Field Identifier | ||
*/ | ||
@Schema(title = "Parameter identifier field", example = "port", accessMode = READ_WRITE) | ||
@Size(max = 100) | ||
@NotNull | ||
private String field; | ||
|
||
/** | ||
* Param Value | ||
*/ | ||
@Schema(title = "parameter values", example = "8080", accessMode = READ_WRITE) | ||
@Size(max = 8126) | ||
@Column(length = 8126) | ||
private String paramValue; | ||
|
||
/** | ||
* Parameter type 0: number 1: string 2: encrypted string 3: json string mapped by map | ||
*/ | ||
@Schema(title = "Parameter types 0: number 1: string 2: encrypted string 3:map mapped json string 4:arrays string", | ||
accessMode = READ_WRITE) | ||
@Min(0) | ||
private byte type; | ||
|
||
/** | ||
* Record create time | ||
*/ | ||
@Schema(title = "Record create time", example = "1612198922000", accessMode = READ_ONLY) | ||
@CreatedDate | ||
private LocalDateTime gmtCreate; | ||
|
||
/** | ||
* Record the latest modification time | ||
*/ | ||
@Schema(title = "Record modify time", example = "1612198444000", accessMode = READ_ONLY) | ||
@LastModifiedDate | ||
private LocalDateTime gmtUpdate; | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParametersVO.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 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.hertzbeat.manager.pojo.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.hertzbeat.common.entity.manager.ParamDefine; | ||
import java.util.List; | ||
|
||
/** | ||
* Popup rendering and parameter values | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class PluginParametersVO { | ||
|
||
/** | ||
* Stencil rendering | ||
*/ | ||
private List<ParamDefine> paramDefines; | ||
|
||
/** | ||
* specific parameter | ||
*/ | ||
private List<PluginParam> pluginParams; | ||
} |
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
Oops, something went wrong.