MINIFI-444 C2 Data Model and REST API The foundation of a data model and REST API that would support discussed features such as a MiNiFi Agent C2 Protocol and MiNiFi Flow Designer.
This closes #118. Signed-off-by: Aldrin Piri <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi/commit/631b5992 Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi/tree/631b5992 Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi/diff/631b5992 Branch: refs/heads/minifi-c2-server Commit: 631b59926bc28641f3277941cb6ef6e6855fe1d6 Parents: caae8d7 Author: Kevin Doran <[email protected]> Authored: Tue Feb 27 14:09:50 2018 -0500 Committer: Aldrin Piri <[email protected]> Committed: Thu Mar 22 12:17:49 2018 -0400 ---------------------------------------------------------------------- minifi-assembly/pom.xml | 1 + minifi-c2/minifi-c2-assembly/pom.xml | 13 +- minifi-c2/minifi-c2-commons/pom.xml | 7 +- .../apache/nifi/minifi/c2/model/AgentClass.java | 53 ++++++ .../apache/nifi/minifi/c2/model/AgentInfo.java | 69 ++++++++ .../nifi/minifi/c2/model/AgentManifest.java | 116 +++++++++++++ .../nifi/minifi/c2/model/AgentRepositories.java | 43 +++++ .../minifi/c2/model/AgentRepositoryStatus.java | 86 ++++++++++ .../nifi/minifi/c2/model/AgentStatus.java | 59 +++++++ .../apache/nifi/minifi/c2/model/BuildInfo.java | 83 +++++++++ .../nifi/minifi/c2/model/C2Heartbeat.java | 55 ++++++ .../minifi/c2/model/C2HeartbeatResponse.java | 35 ++++ .../nifi/minifi/c2/model/C2Operation.java | 98 +++++++++++ .../nifi/minifi/c2/model/C2OperationAck.java | 35 ++++ .../nifi/minifi/c2/model/ComponentStatus.java | 33 ++++ .../org/apache/nifi/minifi/c2/model/Device.java | 55 ++++++ .../apache/nifi/minifi/c2/model/DeviceInfo.java | 54 ++++++ .../apache/nifi/minifi/c2/model/FlowInfo.java | 56 +++++++ .../nifi/minifi/c2/model/FlowQueueStatus.java | 78 +++++++++ .../apache/nifi/minifi/c2/model/FlowStatus.java | 51 ++++++ .../apache/nifi/minifi/c2/model/FlowUri.java | 141 ++++++++++++++++ .../nifi/minifi/c2/model/NetworkInfo.java | 54 ++++++ .../nifi/minifi/c2/model/OperationRequest.java | 72 ++++++++ .../nifi/minifi/c2/model/OperationType.java | 31 ++++ .../apache/nifi/minifi/c2/model/SystemInfo.java | 67 ++++++++ .../apache/nifi/minifi/c2/model/TestObject.java | 5 +- .../nifi/minifi/c2/model/extension/Bundle.java | 115 +++++++++++++ .../c2/model/extension/ComponentManifest.java | 66 ++++++++ .../c2/model/extension/ControllerService.java | 37 ++++ .../minifi/c2/model/extension/DefinedType.java | 97 +++++++++++ .../c2/model/extension/ExtensionComponent.java | 119 +++++++++++++ .../minifi/c2/model/extension/Processor.java | 92 ++++++++++ .../model/extension/PropertyAllowableValue.java | 75 +++++++++ .../c2/model/extension/PropertyDescriptor.java | 118 +++++++++++++ .../c2/model/extension/ReportingTask.java | 67 ++++++++ minifi-c2/minifi-c2-framework/pom.xml | 2 +- minifi-c2/minifi-c2-web-api/pom.xml | 168 ++++++++++++++++++- .../nifi/minifi/c2/MinifiC2ApiApplication.java | 25 ++- .../minifi/c2/web/MinifiC2ResourceConfig.java | 60 ++++++- .../minifi/c2/web/api/AgentClassResource.java | 132 +++++++++++++++ .../c2/web/api/AgentManifestResource.java | 93 ++++++++++ .../minifi/c2/web/api/ApplicationResource.java | 32 ++++ .../minifi/c2/web/api/C2ProtocolResource.java | 119 +++++++++++++ .../nifi/minifi/c2/web/api/TestResource.java | 11 +- .../web/mapper/NotSupportedExceptionMapper.java | 43 +++++ minifi-c2/pom.xml | 4 + minifi-nar-bundles/minifi-standard-nar/pom.xml | 1 + pom.xml | 44 +---- 48 files changed, 2901 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-assembly/pom.xml ---------------------------------------------------------------------- diff --git a/minifi-assembly/pom.xml b/minifi-assembly/pom.xml index 3d651a1..487dfe2 100644 --- a/minifi-assembly/pom.xml +++ b/minifi-assembly/pom.xml @@ -259,6 +259,7 @@ limitations under the License. <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> + <version>${guava.version}</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-assembly/pom.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/pom.xml b/minifi-c2/minifi-c2-assembly/pom.xml index d9ccb4e..3f55ac2 100644 --- a/minifi-c2/minifi-c2-assembly/pom.xml +++ b/minifi-c2/minifi-c2-assembly/pom.xml @@ -93,13 +93,13 @@ limitations under the License. <scope>compile</scope> </dependency> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-annotations</artifactId> <scope>compile</scope> </dependency> <dependency> - <groupId>com.sun.jersey.contribs</groupId> - <artifactId>jersey-spring</artifactId> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> <scope>compile</scope> </dependency> <dependency> @@ -113,6 +113,11 @@ limitations under the License. <scope>compile</scope> </dependency> <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>24.0-jre</version> + </dependency> + <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>compile</scope> http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/pom.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/pom.xml b/minifi-c2/minifi-c2-commons/pom.xml index 8704090..7273891 100644 --- a/minifi-c2/minifi-c2-commons/pom.xml +++ b/minifi-c2/minifi-c2-commons/pom.xml @@ -32,23 +32,20 @@ limitations under the License. <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> + <version>${io.swagger.version}</version> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> </dependency> <dependency> - <groupId>javax.ws.rs</groupId> - <artifactId>javax.ws.rs-api</artifactId> - </dependency> - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> - <version>1.7.25</version> + <version>${org.slf4j.version}</version> </dependency> </dependencies> http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentClass.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentClass.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentClass.java new file mode 100644 index 0000000..2567b69 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentClass.java @@ -0,0 +1,53 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class AgentClass { + + private String name; + private String description; + private FlowUri trackedFlow; + + @ApiModelProperty(value = "A unique class name for the agent", required = true) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @ApiModelProperty("An optional description of this agent class") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @ApiModelProperty("The URI for the versioned MiNiFi flow mapped to this agent class") + public FlowUri getTrackedFlow() { + return trackedFlow; + } + + public void setTrackedFlow(FlowUri trackedFlow) { + this.trackedFlow = trackedFlow; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentInfo.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentInfo.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentInfo.java new file mode 100644 index 0000000..3e4c7ac --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentInfo.java @@ -0,0 +1,69 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class AgentInfo { + + private String identifier; + // TODO, do we also need identity. e.g., cert DN + private String agentClass; + private AgentManifest agentManifest; + private AgentStatus status; + // private Map<String, String> configProperties; // TODO we should add this information eventually, but we need to handle the best way to handle sharing sensitive properties. + + @ApiModelProperty( + value = "A unique identifier for the Agent", + notes = "Usually set when the agent is provisioned and deployed") + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + @ApiModelProperty( + value = "The class or category label of the agent, e.g., 'sensor-collector'", + notes = "Usually set when the agent is provisioned and deployed") + public String getAgentClass() { + return agentClass; + } + + public void setAgentClass(String agentClass) { + this.agentClass = agentClass; + } + + @ApiModelProperty("The specification of the agent's capabilities") + public AgentManifest getAgentManifest() { + return agentManifest; + } + + public void setAgentManifest(AgentManifest agentManifest) { + this.agentManifest = agentManifest; + } + + @ApiModelProperty("A summary of the runtime status of the agent") + public AgentStatus getStatus() { + return status; + } + + public void setStatus(AgentStatus status) { + this.status = status; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentManifest.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentManifest.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentManifest.java new file mode 100644 index 0000000..d5a53d2 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentManifest.java @@ -0,0 +1,116 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.nifi.minifi.c2.model.extension.Bundle; +import org.apache.nifi.minifi.c2.model.extension.ComponentManifest; + +import java.util.Collections; +import java.util.List; + +@ApiModel +public class AgentManifest { + + private String identifier; + private String agentType; + private String version; + private BuildInfo buildInfo; + private List<Bundle> bundles; + private ComponentManifest componentManifest; + + @ApiModelProperty( + value = "A unique identifier for the manifest", + readOnly = true) + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + @ApiModelProperty( + value = "The type of the agent binary, e.g., 'minifi-java' or 'minifi-cpp'", + notes = "Usually set when the agent is built.") + public String getAgentType() { + return agentType; + } + + public void setAgentType(String agentType) { + this.agentType = agentType; + } + + @ApiModelProperty( + value = "The version of the agent binary, e.g., '1.0.1'", + notes = "Usually set when the agent is built.") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @ApiModelProperty("Build summary for this agent binary") + public BuildInfo getBuildInfo() { + return buildInfo; + } + + public void setBuildInfo(BuildInfo buildInfo) { + this.buildInfo = buildInfo; + } + + @ApiModelProperty("All extension bundles included with this agent") + public List<Bundle> getBundles() { + return (bundles != null ? Collections.unmodifiableList(bundles) : null); + } + + public void setBundles(List<Bundle> bundles) { + this.bundles = bundles; + } + + @ApiModelProperty("All components of this agent that are not part of a bundle.") + public ComponentManifest getComponentManifest() { + return componentManifest; + } + + public void setComponentManifest(ComponentManifest componentManifest) { + this.componentManifest = componentManifest; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + AgentManifest that = (AgentManifest) o; + + return new EqualsBuilder() + .append(identifier, that.identifier) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(identifier) + .toHashCode(); + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentRepositories.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentRepositories.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentRepositories.java new file mode 100644 index 0000000..c34412b --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentRepositories.java @@ -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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class AgentRepositories { + + private AgentRepositoryStatus flowfile; + private AgentRepositoryStatus provenance; + + @ApiModelProperty + public AgentRepositoryStatus getFlowfile() { + return flowfile; + } + + public void setFlowfile(AgentRepositoryStatus flowfile) { + this.flowfile = flowfile; + } + + @ApiModelProperty + public AgentRepositoryStatus getProvenance() { + return provenance; + } + + public void setProvenance(AgentRepositoryStatus provenance) { + this.provenance = provenance; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentRepositoryStatus.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentRepositoryStatus.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentRepositoryStatus.java new file mode 100644 index 0000000..2750fe7 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentRepositoryStatus.java @@ -0,0 +1,86 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +@ApiModel +public class AgentRepositoryStatus { + + @Min(0) + @Max(Long.MAX_VALUE) + private Long size; + + @Min(0) + @Max(Long.MAX_VALUE) + private Long sizeMax; + + @Min(0) + @Max(Long.MAX_VALUE) + private Long dataSize; + + @Min(0) + @Max(Long.MAX_VALUE) + private Long dataSizeMax; + + @ApiModelProperty( + value = "The number of items in the repository", + allowableValues = "range[0, 9223372036854775807]") + public Long getSize() { + return size; + } + + public void setSize(Long size) { + this.size = size; + } + + @ApiModelProperty( + value = "The maximum number of items that the repository is configured to hold", + allowableValues = "range[0, 9223372036854775807]") + public Long getSizeMax() { + return sizeMax; + } + + public void setSizeMax(Long sizeMax) { + this.sizeMax = sizeMax; + } + + @ApiModelProperty( + value = "The size (in Bytes) of the data in the repository", + allowableValues = "range[0, 9223372036854775807]") + public Long getDataSize() { + return dataSize; + } + + public void setDataSize(Long dataSize) { + this.dataSize = dataSize; + } + + @ApiModelProperty( + value = "The maximum size (in Bytes) that the repository is configured to hold", + allowableValues = "range[0, 9223372036854775807]") + public Long getDataSizeMax() { + return dataSizeMax; + } + + public void setDataSizeMax(Long dataSizeMax) { + this.dataSizeMax = dataSizeMax; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentStatus.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentStatus.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentStatus.java new file mode 100644 index 0000000..606f940 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/AgentStatus.java @@ -0,0 +1,59 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * Status of the aspects of the agent, including any agent components that are controllable by the C2 server, ie: + * - Repositories that can be cleared and their current state + */ +@ApiModel +public class AgentStatus { + + private long uptime; + private AgentRepositories repositories; + private Map<String, ComponentStatus> components; + + @ApiModelProperty("The number of milliseconds since the agent started.") + public long getUptime() { + return uptime; + } + + public void setUptime(long uptime) { + this.uptime = uptime; + } + + @ApiModelProperty("Status and metrics for the agent repositories") + public AgentRepositories getRepositories() { + return repositories; + } + + public void setRepositories(AgentRepositories repositories) { + this.repositories = repositories; + } + + @ApiModelProperty("Status and for shared agent components (that is, components that exist outside the context of a specific flow).") + public Map<String, ComponentStatus> getComponents() { + return components; + } + + public void setComponents(Map<String, ComponentStatus> components) { + this.components = components; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/BuildInfo.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/BuildInfo.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/BuildInfo.java new file mode 100644 index 0000000..3f3876b --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/BuildInfo.java @@ -0,0 +1,83 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class BuildInfo { + + private String version; + private String revision; + private Long timestamp; + private String targetArch; + private String compiler; + private String compilerFlags; + + @ApiModelProperty("The version number of the built component.") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @ApiModelProperty("The SCM revision id of the source code used for this build.") + public String getRevision() { + return revision; + } + + public void setRevision(String revision) { + this.revision = revision; + } + + @ApiModelProperty("The timestamp (milliseconds since Epoch) of the build.") + public Long getTimestamp() { + return timestamp; + } + + public void setTimestamp(Long timestamp) { + this.timestamp = timestamp; + } + + @ApiModelProperty("The target architecture of the built component.") + public String getTargetArch() { + return targetArch; + } + + public void setTargetArch(String targetArch) { + this.targetArch = targetArch; + } + + @ApiModelProperty("The compiler used for the build") + public String getCompiler() { + return compiler; + } + + public void setCompiler(String compiler) { + this.compiler = compiler; + } + + @ApiModelProperty("The compiler flags used for the build.") + public String getCompilerFlags() { + return compilerFlags; + } + + public void setCompilerFlags(String compilerFlags) { + this.compilerFlags = compilerFlags; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2Heartbeat.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2Heartbeat.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2Heartbeat.java new file mode 100644 index 0000000..b68680f --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2Heartbeat.java @@ -0,0 +1,55 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class C2Heartbeat { + + // TODO, timestamp? + private DeviceInfo deviceInfo; + private AgentInfo agentInfo; + private FlowInfo flowInfo; + + @ApiModelProperty("Metadata for the device") + public DeviceInfo getDeviceInfo() { + return deviceInfo; + } + + public void setDeviceInfo(DeviceInfo deviceInfo) { + this.deviceInfo = deviceInfo; + } + + @ApiModelProperty("Metadata for the agent installed on the device") + public AgentInfo getAgentInfo() { + return agentInfo; + } + + public void setAgentInfo(AgentInfo agentInfo) { + this.agentInfo = agentInfo; + } + + @ApiModelProperty("Metadata for the flow currently deployed to the agent") + public FlowInfo getFlowInfo() { + return flowInfo; + } + + public void setFlowInfo(FlowInfo flowInfo) { + this.flowInfo = flowInfo; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2HeartbeatResponse.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2HeartbeatResponse.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2HeartbeatResponse.java new file mode 100644 index 0000000..60648b9 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2HeartbeatResponse.java @@ -0,0 +1,35 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +@ApiModel +public class C2HeartbeatResponse { + + private List<C2Operation> requestedOperations; + + @ApiModelProperty + public List<C2Operation> getRequestedOperations() { + return requestedOperations; + } + + public void setRequestedOperations(List<C2Operation> requestedOperations) { + this.requestedOperations = requestedOperations; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2Operation.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2Operation.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2Operation.java new file mode 100644 index 0000000..047ebc6 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2Operation.java @@ -0,0 +1,98 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.NotBlank; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +@ApiModel +public class C2Operation { + + private String identifier; + @NotBlank + private OperationType operation; + private String operand; + private Map<String, String> args; + + private List<String> dependencies; + + @ApiModelProperty( + value = "A unique identifier for the operation", + readOnly = true) + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + @ApiModelProperty(value = "The type of operation", required = true) + public OperationType getOperation() { + return operation; + } + + public void setOperation(OperationType operation) { + this.operation = operation; + } + + @ApiModelProperty( + value = "The primary operand of the operation", + notes = "This is an optional field which contains the name of the entity that is target of the operation. " + + "Most operations can be fully specified with zero or one operands." + + "If no operand is needed, this field will be absent." + + "If one operand is insufficient, the operation will contain an args map" + + "with additional keyword parameters and values (see 'args').") + public String getOperand() { + return operand; + } + + public void setOperand(String operand) { + this.operand = operand; + } + + @ApiModelProperty(value = "If the operation requires arguments ", + notes = "This is an optional field and only provided when an operation has arguments " + + "in additional to the primary operand or optional parameters. Arguments are " + + "arbitrary key-value pairs whose interpretation is subject to the context" + + "of the operation and operand. For example, given:" + + "operation=clear, operand=connection;" + + "the args might contain the name of the connection to clear." + + "The syntax and semantics of these arguments is defined per operation in" + + "the C2 protocol and possibly extended by an agent's implementation of the" + + "C2 protocol.") + public Map<String, String> getArgs() { + return (args != null ? Collections.unmodifiableMap(args) : null); + } + + public void setArgs(Map<String, String> args) { + this.args = args; + } + + @ApiModelProperty("Optional list operation ids that this operation depends on. " + + "Executing this operation is conditional on the success of all dependency operations.") + public List<String> getDependencies() { + return dependencies; + } + + public void setDependencies(List<String> dependencies) { + this.dependencies = dependencies; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2OperationAck.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2OperationAck.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2OperationAck.java new file mode 100644 index 0000000..d4f8cca --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/C2OperationAck.java @@ -0,0 +1,35 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class C2OperationAck { + + private String operationId; + // TODO, result, outcome, or status of the operation? eg SUCCESS/FAIL? + + @ApiModelProperty("The id of the requested operation that is being acknowledged") + public String getOperationId() { + return operationId; + } + + public void setOperationId(String operationId) { + this.operationId = operationId; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/ComponentStatus.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/ComponentStatus.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/ComponentStatus.java new file mode 100644 index 0000000..adbd147 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/ComponentStatus.java @@ -0,0 +1,33 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class ComponentStatus { + + private Boolean running; + + @ApiModelProperty + public Boolean getRunning() { + return running; + } + + public void setRunning(Boolean running) { + this.running = running; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/Device.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/Device.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/Device.java new file mode 100644 index 0000000..0505856 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/Device.java @@ -0,0 +1,55 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class Device extends DeviceInfo { + + private String name; + private Long firstSeen; + private Long lastSeen; + + @ApiModelProperty + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @ApiModelProperty("A timestamp (milliseconds since Epoch) for the first time a device was seen by this C2 server") + public Long getFirstSeen() { + return firstSeen; + } + + public void setFirstSeen(Long firstSeen) { + this.firstSeen = firstSeen; + } + + @ApiModelProperty("A timestamp (milliseconds since Epoch) for the most recent time time a device was seen by this C2 server") + public Long getLastSeen() { + return lastSeen; + } + + public void setLastSeen(Long lastSeen) { + this.lastSeen = lastSeen; + } + + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/DeviceInfo.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/DeviceInfo.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/DeviceInfo.java new file mode 100644 index 0000000..a72a347 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/DeviceInfo.java @@ -0,0 +1,54 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class DeviceInfo { + + private String identifier; + private SystemInfo systemInfo; + private NetworkInfo networkInfo; + + @ApiModelProperty("A unique, long-lived identifier for the MiNiFi-enabled device") + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + @ApiModelProperty("Metadata for the device hardware and operating system") + public SystemInfo getSystemInfo() { + return systemInfo; + } + + public void setSystemInfo(SystemInfo systemInfo) { + this.systemInfo = systemInfo; + } + + @ApiModelProperty("Metadata for the network interface of this device") + public NetworkInfo getNetworkInfo() { + return networkInfo; + } + + public void setNetworkInfo(NetworkInfo networkInfo) { + this.networkInfo = networkInfo; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowInfo.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowInfo.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowInfo.java new file mode 100644 index 0000000..6f7c0d3 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowInfo.java @@ -0,0 +1,56 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.NotBlank; + +@ApiModel +public class FlowInfo { + + @NotBlank + private String flowId; + private FlowUri versionedFlowSnapshotURI; + private FlowStatus status; + + @ApiModelProperty(value = "A unique identifier of the flow currently deployed on the agent", required = true) + public String getFlowId() { + return flowId; + } + + public void setFlowId(String flowId) { + this.flowId = flowId; + } + + @ApiModelProperty("The URI to the Versioned Flow Snapshot, when the flow corresponds to a Versioned Flow in a NiFi Registry.") + public FlowUri getVersionedFlowSnapshotURI() { + return versionedFlowSnapshotURI; + } + + public void setVersionedFlowSnapshotURI(FlowUri versionedFlowSnapshotURI) { + this.versionedFlowSnapshotURI = versionedFlowSnapshotURI; + } + + @ApiModelProperty("Current flow status and metrics") + public FlowStatus getStatus() { + return status; + } + + public void setStatus(FlowStatus status) { + this.status = status; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowQueueStatus.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowQueueStatus.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowQueueStatus.java new file mode 100644 index 0000000..43e1edb --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowQueueStatus.java @@ -0,0 +1,78 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +@ApiModel +public class FlowQueueStatus { + + @Min(0) + @Max(Long.MAX_VALUE) + private Long size; + + @Min(0) + @Max(Long.MAX_VALUE) + private Long sizeMax; + + @Min(0) + @Max(Long.MAX_VALUE) + private Long dataSize; + + @Min(0) + @Max(Long.MAX_VALUE) + private Long dataSizeMax; + + @ApiModelProperty(value = "The number of flow files in the queue", allowableValues = "range[0, 9223372036854775807]") + public Long getSize() { + return size; + } + + public void setSize(Long size) { + this.size = size; + } + + @ApiModelProperty(value = "The maximum number of flow files that the queue is configured to hold", allowableValues = "range[0, 9223372036854775807]") + public Long getSizeMax() { + return sizeMax; + } + + public void setSizeMax(Long sizeMax) { + this.sizeMax = sizeMax; + } + + @ApiModelProperty(value = "The size (in Bytes) of all flow files in the queue", allowableValues = "range[0, 9223372036854775807]") + public Long getDataSize() { + return dataSize; + } + + public void setDataSize(Long dataSize) { + this.dataSize = dataSize; + } + + @ApiModelProperty(value = "The maximum size (in Bytes) that the queue is configured to hold", allowableValues = "range[0, 9223372036854775807]") + public Long getDataSizeMax() { + return dataSizeMax; + } + + public void setDataSizeMax(Long dataSizeMax) { + this.dataSizeMax = dataSizeMax; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowStatus.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowStatus.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowStatus.java new file mode 100644 index 0000000..65908a9 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowStatus.java @@ -0,0 +1,51 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * Status of the aspects of the flow that are controllable by the C2 server, ie: + * - Processors that can be started/stopped and their current state + * - Queues that can be cleared and their current state + */ +@ApiModel +public class FlowStatus { + + private Map<String, ComponentStatus> components; + private Map<String, FlowQueueStatus> queues; + + @ApiModelProperty("Status and for each component that is part of the flow (e.g., processors)") + public Map<String, ComponentStatus> getComponents() { + return components; + } + + public void setComponents(Map<String, ComponentStatus> components) { + this.components = components; + } + + @ApiModelProperty("Status and metrics for each flow connection queue") + public Map<String, FlowQueueStatus> getQueues() { + return queues; + } + + public void setQueues(Map<String, FlowQueueStatus> queues) { + this.queues = queues; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowUri.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowUri.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowUri.java new file mode 100644 index 0000000..b8fd22b --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/FlowUri.java @@ -0,0 +1,141 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +@ApiModel("Uniform Resource Identifier for NiFi Versioned Flows saved to a NiFi Registry") +public class FlowUri { + + private String rawUriString; // This is only used if the FlowUri(String) constructor is used. This field is never exposed other than indirectly by calling toString(); + + private String registryUrl; + private String bucketId; + private String flowId; + + public FlowUri() { + } + + public FlowUri(String flowUriString) { + this.rawUriString = flowUriString; + // TODO, parse out url, bucketId, flowId + throw new UnsupportedOperationException("The FlowUri(String) constructor is not yet implemented"); + } + + public FlowUri(String registryUrl, String bucketId, String flowId) { + this.registryUrl = registryUrl; + this.bucketId = bucketId; + this.flowId = flowId; + } + + @ApiModelProperty(value = "The URL of the NiFi Registry storing the flow.", + notes = "For example, 'https://registry.myorganization.org'") + public String getRegistryUrl() { + return registryUrl; + } + + public void setRegistryUrl(String registryUrl) { + this.registryUrl = registryUrl; + } + + @ApiModelProperty("The identifier of the bucket at the NiFi Registry that contains the flow") + public String getBucketId() { + return bucketId; + } + + public void setBucketId(String bucketId) { + this.bucketId = bucketId; + } + + @ApiModelProperty("The identifier of the flow in the NiFi Registry bucket") + public String getFlowId() { + return flowId; + } + + public void setFlowId(String flowId) { + this.flowId = flowId; + } + + @Override + public String toString() { + if (rawUriString != null) { + return rawUriString; + } else { + return buildUriStringFromParts(); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + FlowUri flowUri = (FlowUri) o; + + return new EqualsBuilder() + .append(registryUrl, flowUri.registryUrl) + .append(bucketId, flowUri.bucketId) + .append(flowId, flowUri.flowId) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(registryUrl) + .append(bucketId) + .append(flowId) + .toHashCode(); + } + + private String buildUriStringFromParts() { + + if (registryUrl == null && bucketId == null && flowId == null) { + return "[empty_flow_uri]"; + } + + StringBuilder uriString = new StringBuilder(); + if (registryUrl != null) { + + if (registryUrl.endsWith("nifi-registry-api/")) { + // Do nothing, this is the form we want + } else if (registryUrl.endsWith("nifi-registry-api")) { + uriString.append("/"); + } else if (registryUrl.endsWith("/")) { + uriString.append("nifi-registry-api/"); + } else { + uriString.append("/nifi-registry-api/"); + } + } else { + uriString.append("/"); + } + + if (bucketId != null) { + uriString.append("buckets/"); + uriString.append(bucketId); + } + + if (flowId != null) { + uriString.append("flows/"); + uriString.append(flowId); + } + + return uriString.toString(); + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/NetworkInfo.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/NetworkInfo.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/NetworkInfo.java new file mode 100644 index 0000000..8a77124 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/NetworkInfo.java @@ -0,0 +1,54 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class NetworkInfo { + + private String deviceId; + private String hostname; + private String ipAddress; + + @ApiModelProperty("The device network interface ID") + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + @ApiModelProperty("The device network hostname") + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + @ApiModelProperty("The device network interface IP Address (v4 or v6)") + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/OperationRequest.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/OperationRequest.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/OperationRequest.java new file mode 100644 index 0000000..f433831 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/OperationRequest.java @@ -0,0 +1,72 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class OperationRequest { + + private C2Operation operation; + private String targetAgentIdentifier; + private String operatorIdentity; + private String operatorName; + + @ApiModelProperty("The C2 operation to perform") + public C2Operation getOperation() { + return operation; + } + + public void setOperation(C2Operation operation) { + this.operation = operation; + } + + @ApiModelProperty("The identifier of the agent to which the operation applies") + public String getTargetAgentIdentifier() { + return targetAgentIdentifier; + } + + public void setTargetAgentIdentifier(String targetAgentIdentifier) { + this.targetAgentIdentifier = targetAgentIdentifier; + } + + @ApiModelProperty(value = "The verified identity of the C2 server client that created the operation", + readOnly = true, + notes = "This field is set by the server when an operation request is submitted to identify the origin. " + + "When the C2 instance is secured, this is the client principal identity (e.g., certificate DN). " + + "When the C2 instances is unsecured, this will be 'anonymous' as client identity can not be authenticated.") + public String getOperatorIdentity() { + return operatorIdentity; + } + + public void setOperatorIdentity(String operatorIdentity) { + this.operatorIdentity = operatorIdentity; + } + + @ApiModelProperty(value = "The client-specified name of the user that created the operation", + readOnly = true, + notes = "A convenience field that the client/user can set to identify operation requests they submitted. " + + "This field cannot be trusted as the client can specify whatever they want (i.e., impersonate another user), " + + "but can be used when the operatorIdentity is ambiguous, such as when running an unsecured C2 server or " + + "when a client certificate is shared by multiple clients. (Note, sharing client certs is not a recommended best practice.)") + public String getOperatorName() { + return operatorName; + } + + public void setOperatorName(String operatorName) { + this.operatorName = operatorName; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/OperationType.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/OperationType.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/OperationType.java new file mode 100644 index 0000000..b1f2a21 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/OperationType.java @@ -0,0 +1,31 @@ +/* + * 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.nifi.minifi.c2.model; + +public enum OperationType { + + // MiNiFi Agent Status Updates -> C2 Server + ACKNOWLEDGE, + HEARTBEAT, + + // C2 Server -> MiNiFi Agent Commands + CLEAR, + DESCRIBE, + UPDATE, + RESTART, + START, + STOP, + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/SystemInfo.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/SystemInfo.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/SystemInfo.java new file mode 100644 index 0000000..3478d1d --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/SystemInfo.java @@ -0,0 +1,67 @@ +/* + * 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.nifi.minifi.c2.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +@ApiModel +public class SystemInfo { + + private String machineArch; + // TODO timezone / UTC offset? Keeping in mind it could change whereas other fields such as "machineArch" should not + + @Min(0) + @Max(Long.MAX_VALUE) + private Long physicalMem; + + @Min(0) + @Max(Integer.MAX_VALUE) + private Integer vCores; + + @ApiModelProperty("Machine architecture of the device, e.g., ARM, x86") + public String getMachineArch() { + return machineArch; + } + + public void setMachineArch(String machineArch) { + this.machineArch = machineArch; + } + + @ApiModelProperty(value = "Size of physical memory of the device in bytes", allowableValues = "range[0, 9223372036854775807]") + public long getPhysicalMem() { + return physicalMem; + } + + public void setPhysicalMem(long physicalMem) { + this.physicalMem = physicalMem; + } + + @ApiModelProperty( + value ="Number of virtual cores on the device", + name = "vCores", + allowableValues = "range[0, 2147483647]") + public Integer getvCores() { + return vCores; + } + + public void setvCores(Integer vCores) { + this.vCores = vCores; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/TestObject.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/TestObject.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/TestObject.java index 5fe4969..8c2284c 100644 --- a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/TestObject.java +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/TestObject.java @@ -20,16 +20,15 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import javax.validation.constraints.NotBlank; -import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement @ApiModel public class TestObject { @NotBlank private String identifier; - @NotBlank String name; + @NotBlank + private String name; @ApiModelProperty(value = "A unique identifier for this object generated by the server at creation time.", readOnly = true) public String getIdentifier() { http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/Bundle.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/Bundle.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/Bundle.java new file mode 100644 index 0000000..656c121 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/Bundle.java @@ -0,0 +1,115 @@ +/* + * 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.nifi.minifi.c2.model.extension; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +@ApiModel +public class Bundle { + + public static final String DEFAULT_GROUP = "default"; + public static final String DEFAULT_ARTIFACT = "unknown"; + public static final String DEFAULT_VERSION = "unversioned"; + + private String group; + private String artifact; + private String version; + // TODO md5sum? + private ComponentManifest componentManifest; + + public Bundle() {} + + public Bundle(String group, String artifact, String version) { + this.group = group; + this.artifact = artifact; + this.version = version; + } + + public static Bundle defaultBundle() { + return new Bundle(DEFAULT_GROUP, DEFAULT_ARTIFACT, DEFAULT_VERSION); + } + + @ApiModelProperty( + value = "The group id of the bundle", + notes = "A globally unique group namespace, e.g., org.apache.nifi", + required = true) + public String getGroup() { + return group; + } + + public void setGroup(String group) { + this.group = group; + } + + @ApiModelProperty( + value = "The artifact id of the bundle", + notes = "Unique within the group", + required = true) + public String getArtifact() { + return artifact; + } + + public void setArtifact(String artifact) { + this.artifact = artifact; + } + + @ApiModelProperty("The version of the bundle artifact") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @ApiModelProperty(value = "The full specification of the bundle contents", + notes = "This is optional, as the group, artifact, and version are " + + "also enough to reference a bundle in the case the bundle " + + "specification has been published to a registry.") + public ComponentManifest getComponentManifest() { + return componentManifest; + } + + public void setComponentManifest(ComponentManifest componentManifest) { + this.componentManifest = componentManifest; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + Bundle bundle = (Bundle) o; + + return new EqualsBuilder() + .append(group, bundle.group) + .append(artifact, bundle.artifact) + .append(version, bundle.version) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(group) + .append(artifact) + .append(version) + .toHashCode(); + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/ComponentManifest.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/ComponentManifest.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/ComponentManifest.java new file mode 100644 index 0000000..5fc5359 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/ComponentManifest.java @@ -0,0 +1,66 @@ +/* + * 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.nifi.minifi.c2.model.extension; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Collections; +import java.util.List; + +@ApiModel +public class ComponentManifest { + + private List<DefinedType> apis; + private List<ControllerService> controllerServices; + private List<Processor> processors; + private List<ReportingTask> reportingTasks; + + @ApiModelProperty("Public interfaces defined in this bundle") + public List<DefinedType> getApis() { + return (apis != null ? Collections.unmodifiableList(apis) : null); + } + + public void setApis(List<DefinedType> apis) { + this.apis = apis; + } + + @ApiModelProperty("Controller Services provided in this bundle") + public List<ControllerService> getControllerServices() { + return (controllerServices != null ? Collections.unmodifiableList(controllerServices) : null); + } + + public void setControllerServices(List<ControllerService> controllerServices) { + this.controllerServices = controllerServices; + } + + @ApiModelProperty("Processors provided in this bundle") + public List<Processor> getProcessors() { + return (processors != null ? Collections.unmodifiableList(processors) : null); + } + + public void setProcessors(List<Processor> processors) { + this.processors = processors; + } + + @ApiModelProperty("Reporting Tasks provided in this bundle") + public List<ReportingTask> getReportingTasks() { + return (reportingTasks != null ? Collections.unmodifiableList(reportingTasks) : null); + } + + public void setReportingTasks(List<ReportingTask> reportingTasks) { + this.reportingTasks = reportingTasks; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/ControllerService.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/ControllerService.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/ControllerService.java new file mode 100644 index 0000000..c785e52 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/ControllerService.java @@ -0,0 +1,37 @@ +/* + * 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.nifi.minifi.c2.model.extension; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Collections; +import java.util.Map; + +@ApiModel // TODO Swagger docs description +public class ControllerService extends ExtensionComponent { + + private Map<String, PropertyDescriptor> propertyDescriptors; + + @ApiModelProperty("Descriptions of configuration properties applicable to this controller service") + public Map<String, PropertyDescriptor> getPropertyDescriptors() { + return (propertyDescriptors != null ? Collections.unmodifiableMap(propertyDescriptors) : null); + } + + public void setPropertyDescriptors(Map<String, PropertyDescriptor> propertyDescriptors) { + this.propertyDescriptors = propertyDescriptors; + } + +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/631b5992/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/DefinedType.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/DefinedType.java b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/DefinedType.java new file mode 100644 index 0000000..0a57346 --- /dev/null +++ b/minifi-c2/minifi-c2-commons/src/main/java/org/apache/nifi/minifi/c2/model/extension/DefinedType.java @@ -0,0 +1,97 @@ +/* + * 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.nifi.minifi.c2.model.extension; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +/** + * A reference to a defined type identified by bundle and fully qualified class type identifiers + */ +@ApiModel +public class DefinedType { + + private String group; + private String artifact; + private String version; + private String type; + + @ApiModelProperty("The group name of the bundle that provides the referenced type.") + public String getGroup() { + return group; + } + + public void setGroup(String group) { + this.group = group; + } + + @ApiModelProperty("The artifact name of the bundle that provides the referenced type.") + public String getArtifact() { + return artifact; + } + + public void setArtifact(String artifact) { + this.artifact = artifact; + } + + @ApiModelProperty("The version of the bundle that provides the referenced type.") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @ApiModelProperty( + value = "The fully-qualified class type", + required = true, + notes = "For example, 'org.apache.nifi.GetFile' or 'org::apache:nifi::minifi::GetFile'") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + DefinedType that = (DefinedType) o; + + return new EqualsBuilder() + .append(group, that.group) + .append(artifact, that.artifact) + .append(version, that.version) + .append(type, that.type) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(group) + .append(artifact) + .append(version) + .append(type) + .toHashCode(); + } +}
