blob: 70744fd4b691b7e895a0468869a103e5c801cf55 [file] [log] [blame]
gururajarao79542b9d12024-11-22 14:28:41 +01001// -
2// ========================LICENSE_START=================================
3// Copyright (C) 2024: Deutsche Telecom
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16// ========================LICENSE_END===================================
17
18// The pdpattributes package provides utilities for managing and configuring attributes related to the
19// Policy Decision Point (PDP). This includes generating unique PDP names, and setting or retrieving
20// subgroup and heartbeat interval values.
21package pdpattributes
22
23import (
24 "github.com/google/uuid"
25 "policy-opa-pdp/pkg/log"
26)
27
28var (
29 PdpName string // A unique identifier for the PDP instance
30 PdpSubgroup string
31 PdpHeartbeatInterval int64 // The interval (in seconds) at which the PDP sends heartbeat signals
32)
33
34func init() {
35 PdpName = GenerateUniquePdpName()
36 log.Debugf("Name: %s", PdpName)
37}
38
39// Generates a unique PDP name by appending a randomly generated UUID
40func GenerateUniquePdpName() string {
41 return "opa-" + uuid.New().String()
42}
43
44// sets the Pdp Subgroup retrieved from the message from Pap
45func SetPdpSubgroup(pdpsubgroup string) {
46 PdpSubgroup = pdpsubgroup
47}
48
49// Retrieves the current PDP subgroup value.
50func GetPdpSubgroup() string {
51 return PdpSubgroup
52}
53
54// sets the PdpHeratbeatInterval retrieved from the message from Pap
55func SetPdpHeartbeatInterval(pdpHeartbeatInterval int64) {
56 PdpHeartbeatInterval = pdpHeartbeatInterval
57}
58
59// Retrieves the current PDP heartbeat interval value.
60func GetPdpHeartbeatInterval() int64 {
61 return PdpHeartbeatInterval
62
63}