Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target/
/.idea/
import.sql
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@
<exclude>eclipse-java-formatter.xml</exclude>
<!-- log4j.xml -->
<exclude>src/main/resources/log4j2.xml</exclude>
<!-- importsql -->
<exclude>src/test/resources/import.sql</exclude>
</excludes>
</configuration>
<executions>
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/teragrep/cfe_41/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
*/
package com.teragrep.cfe_41;

import com.teragrep.cfe_41.importsql.ImportsqlFile;
import com.teragrep.cnf_01.ArgsConfiguration;
import com.teragrep.cnf_01.Configuration;
import com.teragrep.cnf_01.ConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Map;
import java.util.HashMap;

public class Main {

Expand All @@ -61,7 +62,7 @@ public class Main {
public static void main(final String[] args) throws Exception {
// Creates new ApiConfig from commandline args
final Configuration configuration = new ArgsConfiguration(args);
Map<String, String> configMap = new HashMap<>();
final Map<String, String> configMap;
try {
logger.debug("Loaded configuration <{}>", configuration.asMap());
configMap = configuration.asMap();
Expand All @@ -72,5 +73,11 @@ public static void main(final String[] args) throws Exception {
}

final ApiConfig apiConfig = new ApiConfig(configMap);
createImport(apiConfig);
}

public static void createImport(final ApiConfig apiConfig) throws IOException {
final ImportsqlFile importsqlFile = new ImportsqlFile(apiConfig);
importsqlFile.createFile();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@

public interface CaptureRequest {

CaptureResponse captureResponse(int id, String captureType) throws IOException;
public abstract CaptureResponse captureResponse(int id, String captureType) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@

public interface CaptureStorageRequest {

CaptureStorageResponse captureStorageResponse(int captureDefinitionId) throws IOException;
public abstract CaptureStorageResponse captureStorageResponse(int captureDefinitionId) throws IOException;
}
59 changes: 59 additions & 0 deletions src/main/java/com/teragrep/cfe_41/captureGroup/CaptureGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Integration Command-line tool for Teragrep
* Copyright (C) 2025 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
package com.teragrep.cfe_41.captureGroup;

import com.teragrep.cfe_41.Stored;

public interface CaptureGroup extends Stored {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the method names here could be simplified:

  • groupName -> name
  • captureGroupType -> type


public abstract String groupName();

public abstract int captureDefinitionId();

public abstract String captureGroupType();

public abstract int id();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Integration Command-line tool for Teragrep
* Copyright (C) 2025 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
package com.teragrep.cfe_41.captureGroup;

import java.io.IOException;

public interface CaptureGroupAllRequest {

public abstract CaptureGroupResponse captureGroupResponse() throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Integration Command-line tool for Teragrep
* Copyright (C) 2025 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
package com.teragrep.cfe_41.captureGroup;

import com.teragrep.cfe_41.ApiConfig;
import com.teragrep.cfe_41.RequestData;
import com.teragrep.cfe_41.Response;
import jakarta.json.JsonArray;

import java.io.IOException;
import java.util.Objects;

public class CaptureGroupAllRequestImpl implements CaptureGroupAllRequest {

private final ApiConfig apiConfig;

public CaptureGroupAllRequestImpl(final ApiConfig apiConfig) {
this.apiConfig = apiConfig;
}

@Override
public CaptureGroupResponse captureGroupResponse() throws IOException {
final JsonArray a = new Response(new RequestData("/capture/group", apiConfig).doRequest()).asJsonArray();
return new CaptureGroupResponse(a);
}

@Override
public boolean equals(final Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
final CaptureGroupAllRequestImpl that = (CaptureGroupAllRequestImpl) o;
return Objects.equals(apiConfig, that.apiConfig);
}

@Override
public int hashCode() {
return Objects.hashCode(apiConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@

public interface CaptureGroupRequest {

CaptureGroupResponse captureGroupResponse(String groupName) throws IOException;
public abstract CaptureGroupResponse captureGroupResponse(String groupName) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public CaptureGroupResponse(final JsonArray jsonArray) {
this.jsonArray = jsonArray;
}

public List<PartialCaptureResponse> partialCaptureResponses() {
final List<PartialCaptureResponse> partialCaptureResponses = new ArrayList<>();
public List<PartialCaptureGroupResponse> partialCaptureResponses() {
final List<PartialCaptureGroupResponse> partialCaptureGroupResponse = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response -> responses

for (JsonValue key : jsonArray) {
partialCaptureResponses.add(new PartialCaptureResponse(key.asJsonObject()));
partialCaptureGroupResponse.add(new PartialCaptureGroupResponse(key.asJsonObject()));
}
return partialCaptureResponses;
return partialCaptureGroupResponse;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,31 @@

import java.util.Objects;

public final class PartialCaptureResponse {
public final class PartialCaptureGroupResponse implements CaptureGroup {

private final JsonObject jsonObject;

public PartialCaptureResponse(final JsonObject jsonObject) {
public PartialCaptureGroupResponse(final JsonObject jsonObject) {
this.jsonObject = jsonObject;
}

@Override
public String groupName() {
return jsonObject.getString("capture_def_group_name");
}

@Override
public int captureDefinitionId() {
return jsonObject.getInt("capture_definition_id");
}

@Override
public String captureGroupType() {
return jsonObject.getString("capture_group_type");
}

public int groupId() {
@Override
public int id() {
return jsonObject.getInt("id");
}

Expand All @@ -78,7 +82,7 @@ public boolean equals(final Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
final PartialCaptureResponse that = (PartialCaptureResponse) o;
final PartialCaptureGroupResponse that = (PartialCaptureGroupResponse) o;
return Objects.equals(jsonObject, that.jsonObject);
}

Expand Down
53 changes: 53 additions & 0 deletions src/main/java/com/teragrep/cfe_41/host/Host.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Integration Command-line tool for Teragrep
* Copyright (C) 2025 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://github.com/teragrep/teragrep/blob/main/LICENSE>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
package com.teragrep.cfe_41.host;

public interface Host {

public abstract String md5();

public abstract String fqHost();
}
4 changes: 2 additions & 2 deletions src/main/java/com/teragrep/cfe_41/host/HostRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

import java.io.IOException;

interface HostRequest {
public interface HostRequest {

public abstract HostResponse hostResponse() throws IOException;
public abstract HostResponse hostResponse(final int id, final String hostType) throws IOException;

}
Loading