fdb387d712fc9381091e4ce108ca5a1b7e033083
[vid.git] / vid-automation / src / main / java / org / onap / simulator / presetGenerator / presets / aai / PresetAAIGetPortMirroringSourcePorts.java
1 package org.onap.simulator.presetGenerator.presets.aai;
2
3 import com.google.common.collect.ImmutableMap;
4 import java.util.Collections;
5 import java.util.List;
6 import java.util.Map;
7 import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset;
8 import org.springframework.http.HttpMethod;
9
10 public class PresetAAIGetPortMirroringSourcePorts extends BaseAAIPreset {
11     public PresetAAIGetPortMirroringSourcePorts(String configurationId, String interfaceId, String interfaceName, boolean isPortMirrored) {
12         this.configurationId = configurationId;
13         this.interfaceId = interfaceId;
14         this.interfaceName = interfaceName;
15         this.isPortMirrored = isPortMirrored;
16     }
17
18     private final String configurationId;
19     private final String interfaceId;
20     private final String interfaceName;
21     private final boolean isPortMirrored;
22
23     @Override
24     public HttpMethod getReqMethod() {
25         return HttpMethod.PUT;
26     }
27
28     @Override
29     public String getReqPath() {
30         return getRootPath() + "/query";
31     }
32
33     @Override
34     public Map<String, List> getQueryParams() {
35         return ImmutableMap.of(
36                 "format", Collections.singletonList("simple"));
37     }
38
39     @Override
40     public Object getRequestBody() {
41         return ImmutableMap.of(
42                 "start", "/network/configurations/configuration/" + getConfigurationId(),
43                 "query", "query/pserver-fromConfiguration"
44         );
45     }
46
47     public String getConfigurationId() {
48         return configurationId;
49     }
50
51     public String getInterfaceId() {
52         return interfaceId;
53     }
54
55     public String getInterfaceName() { return interfaceName; }
56
57     public boolean getIsPortMirrored() { return isPortMirrored; }
58
59     @Override
60     public Object getResponseBody() {
61         return "{\n" +
62                 "    \"results\": [\n" +
63                 "        {\n" +
64                 "            \"id\": \"4876980240\",\n" +
65                 "            \"node-type\": \"l-interface\",\n" +
66                 "            \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zolson5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\",\n" +
67                 "            \"properties\": {\n" +
68                 "                \"interface-name\": " + doubleQuoteIfNotNull(getInterfaceName()) + ",\n" +
69                 "                \"selflink\": \"https://netw.onap.org:9696/v2.0/ports/6de7bf87-6faa-4984-9492-18d1188b3d4a\",\n" +
70                 "                \"interface-id\": " + doubleQuoteIfNotNull(getInterfaceId()) + ",\n" +
71                 "                \"macaddr\": \"02:6d:e7:bf:87:6f\",\n" +
72                 "                \"network-name\": \"APP-C-24595-D-T001-vprobe_int_pktmirror_net_1\",\n" +
73                 "                \"is-port-mirrored\": " + getIsPortMirrored() + ",\n" +
74                 "                \"resource-version\": \"1519383879190\",\n" +
75                 "                \"in-maint\": false,\n" +
76                 "                \"is-ip-unnumbered\": false\n" +
77                 "            },\n" +
78                 "            \"related-to\": [\n" +
79                 "                {\n" +
80                 "                    \"id\": \"4999893128\",\n" +
81                 "                    \"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
82                 "                    \"node-type\": \"l3-interface-ipv4-address-list\",\n" +
83                 "                    \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a/l-interfaces/l-interface/zolson5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib/l3-interface-ipv4-address-list/107.244.46.254\"\n" +
84                 "                },\n" +
85                 "                {\n" +
86                 "                    \"id\": \"6150074384\",\n" +
87                 "                    \"relationship-label\": \"org.onap.relationships.inventory.Source\",\n" +
88                 "                    \"node-type\": \"logical-link\",\n" +
89                 "                    \"url\": \"/aai/v12/network/logical-links/logical-link/PMC_a22607fb-8392-42f4-bbe7-b8d845a97183_Sourcezrdm5bepdg_147_lb_2_Gn_UntrustedVrf_5_RVMI_Destzrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"\n" +
90                 "                },\n" +
91                 "                {\n" +
92                 "                    \"id\": \"6975434912\",\n" +
93                 "                    \"relationship-label\": \"tosca.relationships.network.LinksTo\",\n" +
94                 "                    \"node-type\": \"logical-link\",\n" +
95                 "                    \"url\": \"/aai/v12/network/logical-links/logical-link/PMC_a22607fb-8392-42f4-bbe7-b8d845a97183_Sourcezrdm5bepdg_147_lb_1_Gn_UntrustedVrf_5_RVMI_Destzrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"\n" +
96                 "                },\n" +
97                 "                {\n" +
98                 "                    \"id\": \"7007121568\",\n" +
99                 "                    \"relationship-label\": \"tosca.relationships.network.LinksTo\",\n" +
100                 "                    \"node-type\": \"logical-link\",\n" +
101                 "                    \"url\": \"/aai/v12/network/logical-links/logical-link/PMC_9c099448-a0e1-451d-ac20-c5e3ada8cccd_Sourcezrdm5bepdg_147_lb_2_Gn_UntrustedVrf_5_RVMI_Destzrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"\n" +
102                 "                },\n" +
103                 "                {\n" +
104                 "                    \"id\": \"7048110232\",\n" +
105                 "                    \"relationship-label\": \"tosca.relationships.network.LinksTo\",\n" +
106                 "                    \"node-type\": \"logical-link\",\n" +
107                 "                    \"url\": \"/aai/v12/network/logical-links/logical-link/PMC_9c099448-a0e1-451d-ac20-c5e3ada8cccd_Sourcezrdm5bepdg_147_lb_1_Gn_UntrustedVrf_5_RVMI_Destzrdm5bfprbVLBA005-vlbagent_aff_int_pktmirror_1_port-dr5jhyxva5ib\"\n" +
108                 "                },\n" +
109                 "                {\n" +
110                 "                    \"id\": \"5491453960\",\n" +
111                 "                    \"relationship-label\": \"tosca.relationships.network.BindsTo\",\n" +
112                 "                    \"node-type\": \"vserver\",\n" +
113                 "                    \"url\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson5b/tenants/tenant/460f35aeb53542dc9f77105066483e83/vservers/vserver/15e46e2f-4b98-4e06-9644-f0e6e35cc79a\"\n" +
114                 "                }\n" +
115                 "            ]\n" +
116                 "        }\n" +
117                 "    ]\n" +
118                 "}";
119     }
120
121     private String doubleQuoteIfNotNull(String str) {
122         if (str == null) {
123             return null;
124         } else {
125             return "\"" + str + "\"";
126         }
127     }
128 }