All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cisco.trex.stateful.api.lowlevel.ASTFTemplate Maven / Gradle / Ivy

package com.cisco.trex.stateful.api.lowlevel;

import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils;

/**
 * Java implementation for TRex python sdk ASTFTemplate class
 *
 * 

ASTFTemplate class * *

One manual template client commands ASTFProgram progC =new ASTFProgram(); * progC.send(http_req); * progC.recv(http_response.length()); * * *

ip generator ASTFIpGenDist ipGenC =new ASTFIpGenDist("16.0.0.0", "16.0.0.255"); * ASTFIpGenDist ipGenS =new ASTFIpGenDist("48.0.0.0", "48.0.255.255"); * ASTFIpGen ipGen = new ASTFIpGen(new ASTFIpGenGlobal("1.0.0.0"); * * *

template ASTFTCPClientTemplate tempC=new ASTFTCPClientTemplate(progC, ipGen); * ASTFTCPServerTemplate tempS=new ASTFTCPServerTemplate(progC, ipGen); * ASTFTemplate astfTemplate=mew ASTFTemplate(tempC,tempS); * */ public class ASTFTemplate { private ASTFTCPClientTemplate astfTcpClientTemplate; private ASTFTCPServerTemplate astfTcpServerTemplate; private String tgName; private Integer tgId; public ASTFTemplate( ASTFTCPClientTemplate astfTcpClientTemplate, ASTFTCPServerTemplate astfTcpServerTemplate) { this(astfTcpClientTemplate, astfTcpServerTemplate, null); } public ASTFTemplate( ASTFTCPClientTemplate astfTcpClientTemplate, ASTFTCPServerTemplate astfTcpServerTemplate, String tgName) { if (astfTcpClientTemplate.isStream() != astfTcpServerTemplate.isStream()) { throw new IllegalStateException( String.format( " Client template stream mode is %s and different from server template mode %s", astfTcpClientTemplate.isStream(), astfTcpServerTemplate.isStream())); } if (!StringUtils.isEmpty(tgName) && tgName.length() > 20) { throw new IllegalStateException("tgName is longer than 20"); } this.astfTcpClientTemplate = astfTcpClientTemplate; this.astfTcpServerTemplate = astfTcpServerTemplate; this.tgName = tgName; } public String getTgName() { return tgName; } public void setTgId(int tgId) { this.tgId = tgId; } public int getTgId() { return tgId; } public ASTFTCPClientTemplate getAstfTcpClientTemplate() { return astfTcpClientTemplate; } public ASTFTCPServerTemplate getAstfTcpServerTemplate() { return astfTcpServerTemplate; } public JsonObject toJson() { JsonObject jsonObject = new JsonObject(); jsonObject.add("client_template", astfTcpClientTemplate.toJson()); jsonObject.add("server_template", astfTcpServerTemplate.toJson()); if (this.tgId != 0) { jsonObject.addProperty("tg_id", tgId); } return jsonObject; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy