1 package org.onap.simulator.presetGenerator.presets.aai;
3 import com.google.common.collect.ImmutableList;
4 import com.google.common.collect.ImmutableMap;
5 import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset;
6 import org.springframework.http.HttpMethod;
8 import java.util.Collections;
12 public class PresetAAIServiceInstanceDSLPut extends BaseAAIPreset {
14 public PresetAAIServiceInstanceDSLPut(String globalCustomerId, String serviceInstanceIdentifier, String instanceIdentifierType) {
15 this.serviceInstanceIdentifier = serviceInstanceIdentifier;
16 this.globalCustomerId = globalCustomerId;
17 this.instanceIdentifierType = instanceIdentifierType;
20 public String getInstanceIdentifierType() {
21 return instanceIdentifierType;
24 private final String instanceIdentifierType;
25 private final String globalCustomerId;
27 public String getGlobalCustomerId() {
28 return globalCustomerId;
31 public String getServiceInstanceIdentifier() {
32 return serviceInstanceIdentifier;
35 private final String serviceInstanceIdentifier;
38 public HttpMethod getReqMethod() {
39 return HttpMethod.PUT;
43 public String getReqPath() {
44 return getRootPath() + "/dsl";
48 public Map<String, List> getQueryParams() {
49 return ImmutableMap.of(
50 "format", Collections.singletonList("resource"),
51 "nodesOnly", Collections.singletonList("true"),
52 "depth", Collections.singletonList("0"),
53 "as-tree", Collections.singletonList("true")
58 public Object getRequestBody() {
59 String requestBody = null;
61 if(getInstanceIdentifierType().equals("Service Instance Id")) {
62 query = "customer*('global-customer-id','" + getGlobalCustomerId() + "')>" +
63 "service-subscription>service-instance*('service-instance-id','" + getServiceInstanceIdentifier() + "')";
64 requestBody = "{\"dsl\":\"" + query + "\"}";
66 query = "customer*('global-customer-id','" + getGlobalCustomerId() + "')>" +
67 "service-subscription>service-instance*('service-instance-name','" + getServiceInstanceIdentifier() + "')";
68 requestBody = "{\"dsl\":\"" + query + "\"}";
75 public Object getResponseBody() {
76 return "{\"results\": [\n"
79 + "\"global-customer-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\n"
80 + "\"subscriber-name\": \"Mobility\",\n"
81 + "\"subscriber-type\": \"INFRA\",\n"
82 + "\"resource-version\": \"1602518417955\",\n"
83 + "\"related-nodes\": [\n"
85 + "\"service-subscription\": {\n"
86 + "\"service-type\": \"VPMS\",\n"
87 + "\"resource-version\": \"1629183620246\",\n"
88 + "\"related-nodes\": [\n"
90 + "\"service-instance\": {\n"
91 + "\"service-instance-id\": \"5d942bc7-3acf-4e35-836a-393619ebde66\",\n"
92 + "\"service-instance-name\": \"dpa2actsf5001v_Port_Mirroring_dpa2a_SVC\",\n"
93 + "\"service-type\": \"PORT-MIRROR\",\n"
94 + "\"service-role\": \"VPROBE\",\n"
95 + "\"environment-context\": \"General_Revenue-Bearing\",\n"
96 + "\"workload-context\": \"Production\",\n"
97 + "\"model-invariant-id\": \"0757d856-a9c6-450d-b494-e1c0a4aab76f\",\n"
98 + "\"model-version-id\": \"a9088517-efe8-4bed-9c54-534462cb08c2\",\n"
99 + "\"resource-version\": \"1615330529236\",\n"
100 + "\"selflink\": \"SOME_SELF_LINK\",\n"
101 + "\"orchestration-status\": \"Active\"\n"