blob: a4451d76fd0b8ad1bf9a63f90a548b31aa4dab7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// -
// ========================LICENSE_START=================================
// Copyright (C) 2024: Deutsche Telecom
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========================LICENSE_END===================================
// Defines structure for messages exchanged between PDP and PAP
// Refer: https://docs.onap.org/projects/onap-policy-parent/en/latest/pap/InternalPapPdp.html
// for attribute level details of each message.
package model
import (
"encoding/json"
"fmt"
)
// PdpMessageType represents the type of PDP message.
type PdpMessageType int
// Enumerate the possible PDP message types
// https://github.com/onap/policy-models
// models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java
const (
PDP_STATUS PdpMessageType = iota
PDP_UPDATE
PDP_STATE_CHANGE
PDP_HEALTH_CHECK
PDP_TOPIC_CHECK
)
// String representation of PdpMessageType
func (msgType PdpMessageType) String() string {
switch msgType {
case PDP_STATUS:
return "PDP_STATUS"
case PDP_UPDATE:
return "PDP_UPDATE"
case PDP_STATE_CHANGE:
return "PDP_STATE_CHANGE"
case PDP_HEALTH_CHECK:
return "PDP_HEALTH_CHECK"
case PDP_TOPIC_CHECK:
return "PDP_TOPIC_CHECK"
default:
return fmt.Sprintf("Unknown PdpMessageType: %d", msgType)
}
}
func (p PdpMessageType) MarshalJSON() ([]byte, error) {
return json.Marshal(p.String())
}
// PdpStatus represents the PDP_STATUS message sent from PDP to PAP.
// https://github.com/onap/policy-models
// models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java
type PdpStatus struct {
MessageType PdpMessageType `json:"messageName"`
PdpType string `json:"pdpType"`
State PdpState `json:"state"`
Healthy PdpHealthStatus `json:"healthy"`
Description string `json:"description"`
PdpResponse *PdpResponseDetails `json:"response"`
Policies []ToscaConceptIdentifier `json:"policies"`
Name string `json:"name"`
RequestID string `json:"requestId"`
PdpGroup string `json:"pdpGroup"`
PdpSubgroup *string `json:"pdpSubgroup"`
TimestampMs string `json:"timestampMs"`
DeploymentInstanceInfo string `json:"deploymentInstanceInfo"`
}
// PDP_UPDATE sent by PAP to PDP.
// https://github.com/onap/policy-models
// models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java
type PdpUpdate struct {
Source string `json:"source" validate:"required"`
PdpHeartbeatIntervalMs int64 `json:"pdpHeartbeatIntervalMs" validate:"required"`
MessageType string `json:"messageName" validate:"required"`
PoliciesToBeDeloyed []string `json:"policiesToBeDeployed" validate:"required"`
policiesToBeUndeployed []ToscaConceptIdentifier `json:"policiesToBeUndeployed"`
Name string `json:"name" validate:"required"`
TimestampMs int64 `json:"timestampMs" validate:"required"`
PdpGroup string `json:"pdpGroup" validate:"required"`
PdpSubgroup string `json:"pdpSubgroup" validate:"required"`
RequestId string `json:"requestId" validate:"required"`
}
// PDP_STATE_CHANGE sent by PAP to PDP.
// https://github.com/onap/policy-models
// models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java
type PdpStateChange struct {
Source string `json:"source"`
State string `json:"state"`
MessageType string `json:"messageName"`
Name string `json:"name"`
TimestampMs int64 `json:"timestampMs"`
PdpGroup string `json:"pdpGroup"`
PdpSubgroup string `json:"pdpSubgroup"`
RequestId string `json:"requestId"`
}
|