a3ff2dcd6db41b9db9bb32c299501bfa935ecadc
[so.git] / adapters / etsi-sol002-adapter / src / main / java / org / onap / so / adapters / vevnfm / event / DmaapEvent.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SO
4  * ================================================================================
5  * Copyright (C) 2020 Samsung. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.adapters.vevnfm.event;
22
23 import static java.time.temporal.ChronoField.INSTANT_SECONDS;
24 import com.fasterxml.jackson.annotation.JsonProperty;
25 import java.time.Instant;
26 import java.util.UUID;
27 import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification;
28
29 public class DmaapEvent {
30
31     public static final String MSERVICE = "microservice.stringmatcher";
32     public static final String ONSET = "ONSET";
33     public static final String VNF = "VNF";
34     public static final String VNFID = "generic-vnf.vnf-id";
35     public static final String ETSI = "ETSI";
36
37     private final String closedLoopControlName;
38     private final long closedLoopAlarmStart;
39     private final String closedLoopEventClient;
40     private final String closedLoopEventStatus;
41     private final String requestId;
42     private final String targetType;
43     private final String target;
44     private final AaiEvent aaiEvent;
45     private final String from;
46     private final String version;
47     private final VnfLcmOperationOccurrenceNotification etsiLcmEvent;
48
49     public DmaapEvent(final String closedLoopControlName, final String version,
50             final VnfLcmOperationOccurrenceNotification etsiLcmEvent, final String genericId) {
51         this.closedLoopControlName = closedLoopControlName;
52         this.closedLoopAlarmStart = Instant.now().getLong(INSTANT_SECONDS);
53         this.closedLoopEventClient = MSERVICE;
54         this.closedLoopEventStatus = ONSET;
55         this.requestId = UUID.randomUUID().toString();
56         this.targetType = VNF;
57         this.target = VNFID;
58         this.aaiEvent = (genericId == null) ? null : new AaiEvent(false, genericId);
59         this.from = ETSI;
60         this.version = version;
61         this.etsiLcmEvent = etsiLcmEvent;
62     }
63
64     public String getClosedLoopControlName() {
65         return closedLoopControlName;
66     }
67
68     public long getClosedLoopAlarmStart() {
69         return closedLoopAlarmStart;
70     }
71
72     public String getClosedLoopEventClient() {
73         return closedLoopEventClient;
74     }
75
76     public String getClosedLoopEventStatus() {
77         return closedLoopEventStatus;
78     }
79
80     @JsonProperty("requestID")
81     public String getRequestId() {
82         return requestId;
83     }
84
85     @JsonProperty("target_type")
86     public String getTargetType() {
87         return targetType;
88     }
89
90     public String getTarget() {
91         return target;
92     }
93
94     @JsonProperty("AAI")
95     public AaiEvent getAaiEvent() {
96         return aaiEvent;
97     }
98
99     public String getFrom() {
100         return from;
101     }
102
103     public String getVersion() {
104         return version;
105     }
106
107     public VnfLcmOperationOccurrenceNotification getEtsiLcmEvent() {
108         return etsiLcmEvent;
109     }
110 }