description: >
represents a policy instance identifier. UUIDs are advisable but can
be any string
+ - name: notificationDestination
+ in: query
+ type: string
+ description: >
+ URL send by non-RT RIC. This where non-RT RIC expects status updates on the policy creation
get:
description: |
Retrieve the policy instance
schema:
type: object
properties:
- instance_status:
+ enforceStatus:
type: string
enum:
- - IN EFFECT
- - NOT IN EFFECT
- has_been_deleted:
- type: boolean
- created_at:
+ - ENFORCED
+ - NOT_ENFORCED
+ enforceReason:
type: string
- format: date-time
+ enum:
+ - SCOPE_NOT_APPLICABLE
+ - STATEMENT_NOT_APPLICABLE
+ - OTHER_REASON
'404':
description: >
there is no policy instance with this policy_instance_id or there is
// Editing this file might prove futile when you re-run the swagger generate command
import (
+ "context"
+
"github.com/go-openapi/strfmt"
)
// PolicyInstanceID represents a policy instance identifier. UUIDs are advisable but can be any string
//
+// Example: 3d2157af-6a8f-4a7c-810f-38c2f824bf12
//
// swagger:model policy_instance_id
type PolicyInstanceID string
func (m PolicyInstanceID) Validate(formats strfmt.Registry) error {
return nil
}
+
+// ContextValidate validates this policy instance id based on context it is used
+func (m PolicyInstanceID) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
+ return nil
+}
// Editing this file might prove futile when you re-run the swagger generate command
import (
+ "context"
+
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/validate"
}
return nil
}
+
+// ContextValidate validates this policy type id based on context it is used
+func (m PolicyTypeID) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
+ return nil
+}
// Editing this file might prove futile when you re-run the swagger generate command
import (
+ "context"
+
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
func (m *PolicyTypeSchema) validateCreateSchema(formats strfmt.Registry) error {
- if err := validate.Required("create_schema", "body", m.CreateSchema); err != nil {
- return err
+ if m.CreateSchema == nil {
+ return errors.Required("create_schema", "body", nil)
}
return nil
return nil
}
+// ContextValidate validates this policy type schema based on context it is used
+func (m *PolicyTypeSchema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
+ return nil
+}
+
// MarshalBinary interface implementation
func (m *PolicyTypeSchema) MarshalBinary() ([]byte, error) {
if m == nil {
--- /dev/null
+package notification
+
+import (
+ "bytes"
+ "net/http"
+
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/a1"
+)
+
+func SendNotification(notificationDestination string, body string) error {
+ a1.Logger.Debug("In SendNotification")
+ client := &http.Client{}
+ req, err := http.NewRequest("POST", notificationDestination, bytes.NewBuffer([]byte(body)))
+ if err != nil {
+ return err
+ }
+ req.Header.Set("User-Agent", "a1mediator")
+ res, err := client.Do(req)
+ if err != nil {
+ a1.Logger.Debug("Error sending POST message to %v+", notificationDestination)
+ return err
+ }
+ a1.Logger.Debug("Notification response %s received from far-end", res.Status)
+ return nil
+}
package policy
import (
+ "encoding/json"
"errors"
"fmt"
"strconv"
"gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/a1"
"gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/notification"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_mediator"
"gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
)
var policyInstanceNotFoundError = errors.New("Policy Instance Not Found")
const (
- a1HandlerPrefix = "a1.policy_handler."
- a1PolicyPrefix = "a1.policy_type."
- a1MediatorNs = "A1m_ns"
- a1InstancePrefix = "a1.policy_instance."
+ a1HandlerPrefix = "a1.policy_handler."
+ a1PolicyPrefix = "a1.policy_type."
+ a1MediatorNs = "A1m_ns"
+ a1InstancePrefix = "a1.policy_instance."
+ a1NotificationDestinationPrefix = "a1.policy_notification_destination."
)
func NewPolicyManager(sdl *sdlgo.SyncStorage) *PolicyManager {
}
return pm
}
-func (pm *PolicyManager) SetPolicyInstanceStatus(policyTypeId int, policyInstanceID int, status string) error {
- a1.Logger.Debug("message recieved for %d and %d", policyTypeId, policyInstanceID)
- instancehandlerKey := a1HandlerPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + strconv.FormatInt((int64(policyInstanceID)), 10)
+func (pm *PolicyManager) SetPolicyInstanceStatus(policyTypeId int, policyInstanceID string, status string) error {
+ a1.Logger.Debug("In SetPolicyInstanceStatus message recieved for %d and %s", policyTypeId, policyInstanceID)
+ instancehandlerKey := a1HandlerPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + policyInstanceID
err := pm.db.Set(a1MediatorNs, instancehandlerKey, status)
if err != nil {
a1.Logger.Error("error1 :%+v", err)
return nil
}
+func (pm *PolicyManager) GetPolicyInstanceStatus(policyTypeId int, policyInstanceID string) (bool, error) {
+ a1.Logger.Debug("In GetPolicyInstanceStatus message recieved for %d and %s", policyTypeId, policyInstanceID)
+ instancehandlerKey := a1HandlerPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + policyInstanceID
+ keys := []string{instancehandlerKey}
+ resp, err := pm.db.Get(a1MediatorNs, keys)
+ if err != nil {
+ a1.Logger.Error("error1 :%+v", err)
+ return false, err
+ }
+ for _, key := range resp {
+ if key == "OK" {
+ return true, nil
+ }
+ }
+ return false, nil
+}
+
+func (pm *PolicyManager) SendPolicyStatusNotification(policyTypeId int, policyInstanceID string, handler string, status string) error {
+ a1.Logger.Debug("In SendPolicyStatusNotification status message recieved for %d and %s", policyTypeId, policyInstanceID)
+ notificationDestinationkey := a1NotificationDestinationPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + fmt.Sprint(policyInstanceID)
+ keys := [1]string{notificationDestinationkey}
+ data, err := pm.db.Get(a1MediatorNs, keys[:])
+ if err != nil {
+ a1.Logger.Error("error1 :%+v", err)
+ return err
+ }
+
+ if data[notificationDestinationkey] == nil {
+ // notificationDestination URL is not available. Not an error, non-RT RIC
+ // possibly not expecting any callback.
+ return nil
+ }
+
+ notificationDestination, ok := data[notificationDestinationkey].(string)
+ if !ok {
+ return errors.New("failed to process notificationDestination URL")
+ }
+
+ policyInstanceStatus := a1_mediator.A1ControllerGetPolicyInstanceStatusOKBody{EnforceStatus: "ENFORCED"}
+ enforced, err := pm.GetPolicyInstanceStatus(policyTypeId, policyInstanceID)
+ if err != nil {
+ return err
+ }
+
+ if !enforced {
+ policyInstanceStatus.EnforceStatus = "NOT ENFORCED"
+ policyInstanceStatus.EnforceReason = "OTHER_REASON"
+ }
+
+ jsonbody, err := json.Marshal(policyInstanceStatus)
+ if err != nil {
+ return err
+ }
+ err = notification.SendNotification(notificationDestination, string(jsonbody))
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
func (im *PolicyManager) GetAllPolicyInstance(policyTypeId int) ([]models.PolicyInstanceID, error) {
a1.Logger.Debug("GetAllPolicyInstance")
var policyTypeInstances = []models.PolicyInstanceID{}
-
keys, err := im.db.GetAll("A1m_ns")
if err != nil {
func TestSetPolicyInstance(t *testing.T) {
var policyTypeId int
policyTypeId = 20001
- var policyInstanceID int
- policyInstanceID = 123456
+ policyInstanceID := "123456"
var status string
status = "OK"
- instancehandlerKey := a1HandlerPrefix + strconv.FormatInt(20001, 10) + "." + strconv.FormatInt(int64(policyInstanceID), 10)
+ instancehandlerKey := a1HandlerPrefix + strconv.FormatInt(20001, 10) + "." + policyInstanceID
instancearr := []interface{}{instancehandlerKey, status}
sdlInst.On("Set", "A1m_ns", instancearr).Return(nil)
errresp := pm.SetPolicyInstanceStatus(policyTypeId, policyInstanceID, status)
"name": "policy_instance_id",
"in": "path",
"required": true
+ },
+ {
+ "type": "string",
+ "description": "URL send by non-RT RIC. This where non-RT RIC expects status updates on the policy creation\n",
+ "name": "notificationDestination",
+ "in": "query"
}
]
},
"schema": {
"type": "object",
"properties": {
- "created_at": {
+ "enforceReason": {
"type": "string",
- "format": "date-time"
- },
- "has_been_deleted": {
- "type": "boolean"
+ "enum": [
+ "SCOPE_NOT_APPLICABLE",
+ "STATEMENT_NOT_APPLICABLE",
+ "OTHER_REASON"
+ ]
},
- "instance_status": {
+ "enforceStatus": {
"type": "string",
"enum": [
- "IN EFFECT",
- "NOT IN EFFECT"
+ "ENFORCED",
+ "NOT_ENFORCED"
]
}
}
"name": "policy_instance_id",
"in": "path",
"required": true
+ },
+ {
+ "type": "string",
+ "description": "URL send by non-RT RIC. This where non-RT RIC expects status updates on the policy creation\n",
+ "name": "notificationDestination",
+ "in": "query"
}
]
},
"schema": {
"type": "object",
"properties": {
- "created_at": {
+ "enforceReason": {
"type": "string",
- "format": "date-time"
- },
- "has_been_deleted": {
- "type": "boolean"
+ "enum": [
+ "SCOPE_NOT_APPLICABLE",
+ "STATEMENT_NOT_APPLICABLE",
+ "OTHER_REASON"
+ ]
},
- "instance_status": {
+ "enforceStatus": {
"type": "string",
"enum": [
- "IN EFFECT",
- "NOT IN EFFECT"
+ "ENFORCED",
+ "NOT_ENFORCED"
]
}
}
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
- "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_e_i_data_delivery"
- "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_mediator"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_e_i_data_delivery"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_mediator"
)
// NewA1API creates a new A1 instance
PreServerShutdown: func() {},
ServerShutdown: func() {},
spec: spec,
+ useSwaggerUI: false,
ServeError: errors.ServeError,
BasicAuthenticator: security.BasicAuth,
APIKeyAuthenticator: security.APIKeyAuth,
defaultConsumes string
defaultProduces string
Middleware func(middleware.Builder) http.Handler
+ useSwaggerUI bool
// BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function.
// It has a default implementation in the security package, however you can replace it for your particular usage.
BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
+
// APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function.
// It has a default implementation in the security package, however you can replace it for your particular usage.
APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator
+
// BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function.
// It has a default implementation in the security package, however you can replace it for your particular usage.
BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator
A1MediatorA1ControllerGetPolicyInstanceStatusHandler a1_mediator.A1ControllerGetPolicyInstanceStatusHandler
// A1MediatorA1ControllerGetPolicyTypeHandler sets the operation handler for the a1 controller get policy type operation
A1MediatorA1ControllerGetPolicyTypeHandler a1_mediator.A1ControllerGetPolicyTypeHandler
+
// ServeError is called when an error is received, there is a default handler
// but you can set your own with this
ServeError func(http.ResponseWriter, *http.Request, error)
Logger func(string, ...interface{})
}
+// UseRedoc for documentation at /docs
+func (o *A1API) UseRedoc() {
+ o.useSwaggerUI = false
+}
+
+// UseSwaggerUI for documentation at /docs
+func (o *A1API) UseSwaggerUI() {
+ o.useSwaggerUI = true
+}
+
// SetDefaultProduces sets the default produces media type
func (o *A1API) SetDefaultProduces(mediaType string) {
o.defaultProduces = mediaType
if o.Middleware != nil {
return o.Middleware(builder)
}
+ if o.useSwaggerUI {
+ return o.context.APIHandlerSwaggerUI(builder)
+ }
return o.context.APIHandler(builder)
}
return &A1ControllerDataDelivery{Context: ctx, Handler: handler}
}
-/*A1ControllerDataDelivery swagger:route POST /data-delivery A1 EI Data Delivery a1ControllerDataDelivery
+/* A1ControllerDataDelivery swagger:route POST /data-delivery A1 EI Data Delivery a1ControllerDataDelivery
Deliver data produced by data producer.
func (o *A1ControllerDataDelivery) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerDataDeliveryParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
)
// NewA1ControllerDataDeliveryParams creates a new A1ControllerDataDeliveryParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerDataDeliveryParams() A1ControllerDataDeliveryParams {
return A1ControllerDataDeliveryParams{}
return &A1ControllerCreateOrReplacePolicyInstance{Context: ctx, Handler: handler}
}
-/*A1ControllerCreateOrReplacePolicyInstance swagger:route PUT /a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id} A1 Mediator a1ControllerCreateOrReplacePolicyInstance
+/* A1ControllerCreateOrReplacePolicyInstance swagger:route PUT /a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id} A1 Mediator a1ControllerCreateOrReplacePolicyInstance
Create or replace a policy instance of type policy_type_id. The schema of the PUT body is defined by the create_schema field of the policy type.
func (o *A1ControllerCreateOrReplacePolicyInstance) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerCreateOrReplacePolicyInstanceParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
)
// NewA1ControllerCreateOrReplacePolicyInstanceParams creates a new A1ControllerCreateOrReplacePolicyInstanceParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerCreateOrReplacePolicyInstanceParams() A1ControllerCreateOrReplacePolicyInstanceParams {
return A1ControllerCreateOrReplacePolicyInstanceParams{}
In: body
*/
Body interface{}
+ /*URL send by non-RT RIC. This where non-RT RIC expects status updates on the policy creation
+
+ In: query
+ */
+ NotificationDestination *string
/*represents a policy instance identifier. UUIDs are advisable but can be any string
Required: true
o.HTTPRequest = r
+ qs := runtime.Values(r.URL.Query())
+
if runtime.HasBody(r) {
defer r.Body.Close()
var body interface{}
o.Body = body
}
}
+
+ qNotificationDestination, qhkNotificationDestination, _ := qs.GetOK("notificationDestination")
+ if err := o.bindNotificationDestination(qNotificationDestination, qhkNotificationDestination, route.Formats); err != nil {
+ res = append(res, err)
+ }
+
rPolicyInstanceID, rhkPolicyInstanceID, _ := route.Params.GetOK("policy_instance_id")
if err := o.bindPolicyInstanceID(rPolicyInstanceID, rhkPolicyInstanceID, route.Formats); err != nil {
res = append(res, err)
if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
res = append(res, err)
}
-
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
+// bindNotificationDestination binds and validates parameter NotificationDestination from query.
+func (o *A1ControllerCreateOrReplacePolicyInstanceParams) bindNotificationDestination(rawData []string, hasKey bool, formats strfmt.Registry) error {
+ var raw string
+ if len(rawData) > 0 {
+ raw = rawData[len(rawData)-1]
+ }
+
+ // Required: false
+ // AllowEmptyValue: false
+
+ if raw == "" { // empty values pass all other validations
+ return nil
+ }
+ o.NotificationDestination = &raw
+
+ return nil
+}
+
// bindPolicyInstanceID binds and validates parameter PolicyInstanceID from path.
func (o *A1ControllerCreateOrReplacePolicyInstanceParams) bindPolicyInstanceID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
// Required: true
// Parameter is provided by construction from the route
-
o.PolicyInstanceID = raw
return nil
// validatePolicyTypeID carries on validations for parameter PolicyTypeID
func (o *A1ControllerCreateOrReplacePolicyInstanceParams) validatePolicyTypeID(formats strfmt.Registry) error {
- if err := validate.MinimumInt("policy_type_id", "path", int64(o.PolicyTypeID), 1, false); err != nil {
+ if err := validate.MinimumInt("policy_type_id", "path", o.PolicyTypeID, 1, false); err != nil {
return err
}
- if err := validate.MaximumInt("policy_type_id", "path", int64(o.PolicyTypeID), 2.147483647e+09, false); err != nil {
+ if err := validate.MaximumInt("policy_type_id", "path", o.PolicyTypeID, 2.147483647e+09, false); err != nil {
return err
}
PolicyInstanceID string
PolicyTypeID int64
+ NotificationDestination *string
+
_basePath string
// avoid unkeyed usage
_ struct{}
_basePath := o._basePath
_result.Path = golangswaggerpaths.Join(_basePath, _path)
+ qs := make(url.Values)
+
+ var notificationDestinationQ string
+ if o.NotificationDestination != nil {
+ notificationDestinationQ = *o.NotificationDestination
+ }
+ if notificationDestinationQ != "" {
+ qs.Set("notificationDestination", notificationDestinationQ)
+ }
+
+ _result.RawQuery = qs.Encode()
+
return &_result, nil
}
return &A1ControllerCreatePolicyType{Context: ctx, Handler: handler}
}
-/*A1ControllerCreatePolicyType swagger:route PUT /a1-p/policytypes/{policy_type_id} A1 Mediator a1ControllerCreatePolicyType
+/* A1ControllerCreatePolicyType swagger:route PUT /a1-p/policytypes/{policy_type_id} A1 Mediator a1ControllerCreatePolicyType
Create a new policy type . Replace is not currently allowed; to replace, for now do a DELETE and then a PUT again.
func (o *A1ControllerCreatePolicyType) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerCreatePolicyTypeParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
// Editing this file might prove futile when you re-run the swagger generate command
import (
+ "context"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
- "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
)
// NewA1ControllerCreatePolicyTypeParams creates a new A1ControllerCreatePolicyTypeParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerCreatePolicyTypeParams() A1ControllerCreatePolicyTypeParams {
return A1ControllerCreatePolicyTypeParams{}
res = append(res, err)
}
+ ctx := validate.WithOperationRequest(context.Background())
+ if err := body.ContextValidate(ctx, route.Formats); err != nil {
+ res = append(res, err)
+ }
+
if len(res) == 0 {
o.Body = &body
}
}
}
+
rPolicyTypeID, rhkPolicyTypeID, _ := route.Params.GetOK("policy_type_id")
if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
res = append(res, err)
}
-
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
// validatePolicyTypeID carries on validations for parameter PolicyTypeID
func (o *A1ControllerCreatePolicyTypeParams) validatePolicyTypeID(formats strfmt.Registry) error {
- if err := validate.MinimumInt("policy_type_id", "path", int64(o.PolicyTypeID), 1, false); err != nil {
+ if err := validate.MinimumInt("policy_type_id", "path", o.PolicyTypeID, 1, false); err != nil {
return err
}
- if err := validate.MaximumInt("policy_type_id", "path", int64(o.PolicyTypeID), 2.147483647e+09, false); err != nil {
+ if err := validate.MaximumInt("policy_type_id", "path", o.PolicyTypeID, 2.147483647e+09, false); err != nil {
return err
}
return &A1ControllerDeletePolicyInstance{Context: ctx, Handler: handler}
}
-/*A1ControllerDeletePolicyInstance swagger:route DELETE /a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id} A1 Mediator a1ControllerDeletePolicyInstance
+/* A1ControllerDeletePolicyInstance swagger:route DELETE /a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id} A1 Mediator a1ControllerDeletePolicyInstance
Delete this policy instance
func (o *A1ControllerDeletePolicyInstance) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerDeletePolicyInstanceParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
"net/http"
"github.com/go-openapi/errors"
+ "github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewA1ControllerDeletePolicyInstanceParams creates a new A1ControllerDeletePolicyInstanceParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerDeletePolicyInstanceParams() A1ControllerDeletePolicyInstanceParams {
return A1ControllerDeletePolicyInstanceParams{}
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
+ /*URL send by non-RT RIC. This where non-RT RIC expects status updates on the policy creation
+
+ In: query
+ */
+ NotificationDestination *string
/*represents a policy instance identifier. UUIDs are advisable but can be any string
Required: true
o.HTTPRequest = r
+ qs := runtime.Values(r.URL.Query())
+
+ qNotificationDestination, qhkNotificationDestination, _ := qs.GetOK("notificationDestination")
+ if err := o.bindNotificationDestination(qNotificationDestination, qhkNotificationDestination, route.Formats); err != nil {
+ res = append(res, err)
+ }
+
rPolicyInstanceID, rhkPolicyInstanceID, _ := route.Params.GetOK("policy_instance_id")
if err := o.bindPolicyInstanceID(rPolicyInstanceID, rhkPolicyInstanceID, route.Formats); err != nil {
res = append(res, err)
if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
res = append(res, err)
}
-
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
+// bindNotificationDestination binds and validates parameter NotificationDestination from query.
+func (o *A1ControllerDeletePolicyInstanceParams) bindNotificationDestination(rawData []string, hasKey bool, formats strfmt.Registry) error {
+ var raw string
+ if len(rawData) > 0 {
+ raw = rawData[len(rawData)-1]
+ }
+
+ // Required: false
+ // AllowEmptyValue: false
+
+ if raw == "" { // empty values pass all other validations
+ return nil
+ }
+ o.NotificationDestination = &raw
+
+ return nil
+}
+
// bindPolicyInstanceID binds and validates parameter PolicyInstanceID from path.
func (o *A1ControllerDeletePolicyInstanceParams) bindPolicyInstanceID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
// Required: true
// Parameter is provided by construction from the route
-
o.PolicyInstanceID = raw
return nil
// validatePolicyTypeID carries on validations for parameter PolicyTypeID
func (o *A1ControllerDeletePolicyInstanceParams) validatePolicyTypeID(formats strfmt.Registry) error {
- if err := validate.MinimumInt("policy_type_id", "path", int64(o.PolicyTypeID), 1, false); err != nil {
+ if err := validate.MinimumInt("policy_type_id", "path", o.PolicyTypeID, 1, false); err != nil {
return err
}
- if err := validate.MaximumInt("policy_type_id", "path", int64(o.PolicyTypeID), 2.147483647e+09, false); err != nil {
+ if err := validate.MaximumInt("policy_type_id", "path", o.PolicyTypeID, 2.147483647e+09, false); err != nil {
return err
}
PolicyInstanceID string
PolicyTypeID int64
+ NotificationDestination *string
+
_basePath string
// avoid unkeyed usage
_ struct{}
_basePath := o._basePath
_result.Path = golangswaggerpaths.Join(_basePath, _path)
+ qs := make(url.Values)
+
+ var notificationDestinationQ string
+ if o.NotificationDestination != nil {
+ notificationDestinationQ = *o.NotificationDestination
+ }
+ if notificationDestinationQ != "" {
+ qs.Set("notificationDestination", notificationDestinationQ)
+ }
+
+ _result.RawQuery = qs.Encode()
+
return &_result, nil
}
return &A1ControllerDeletePolicyType{Context: ctx, Handler: handler}
}
-/*A1ControllerDeletePolicyType swagger:route DELETE /a1-p/policytypes/{policy_type_id} A1 Mediator a1ControllerDeletePolicyType
+/* A1ControllerDeletePolicyType swagger:route DELETE /a1-p/policytypes/{policy_type_id} A1 Mediator a1ControllerDeletePolicyType
Delete this policy type. Can only be performed if there are no instances of this type
func (o *A1ControllerDeletePolicyType) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerDeletePolicyTypeParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
)
// NewA1ControllerDeletePolicyTypeParams creates a new A1ControllerDeletePolicyTypeParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerDeletePolicyTypeParams() A1ControllerDeletePolicyTypeParams {
return A1ControllerDeletePolicyTypeParams{}
if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
res = append(res, err)
}
-
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
// validatePolicyTypeID carries on validations for parameter PolicyTypeID
func (o *A1ControllerDeletePolicyTypeParams) validatePolicyTypeID(formats strfmt.Registry) error {
- if err := validate.MinimumInt("policy_type_id", "path", int64(o.PolicyTypeID), 1, false); err != nil {
+ if err := validate.MinimumInt("policy_type_id", "path", o.PolicyTypeID, 1, false); err != nil {
return err
}
- if err := validate.MaximumInt("policy_type_id", "path", int64(o.PolicyTypeID), 2.147483647e+09, false); err != nil {
+ if err := validate.MaximumInt("policy_type_id", "path", o.PolicyTypeID, 2.147483647e+09, false); err != nil {
return err
}
return &A1ControllerGetAllInstancesForType{Context: ctx, Handler: handler}
}
-/*A1ControllerGetAllInstancesForType swagger:route GET /a1-p/policytypes/{policy_type_id}/policies A1 Mediator a1ControllerGetAllInstancesForType
+/* A1ControllerGetAllInstancesForType swagger:route GET /a1-p/policytypes/{policy_type_id}/policies A1 Mediator a1ControllerGetAllInstancesForType
get a list of all policy instance ids for this policy type id
func (o *A1ControllerGetAllInstancesForType) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerGetAllInstancesForTypeParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
)
// NewA1ControllerGetAllInstancesForTypeParams creates a new A1ControllerGetAllInstancesForTypeParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerGetAllInstancesForTypeParams() A1ControllerGetAllInstancesForTypeParams {
return A1ControllerGetAllInstancesForTypeParams{}
if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
res = append(res, err)
}
-
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
// validatePolicyTypeID carries on validations for parameter PolicyTypeID
func (o *A1ControllerGetAllInstancesForTypeParams) validatePolicyTypeID(formats strfmt.Registry) error {
- if err := validate.MinimumInt("policy_type_id", "path", int64(o.PolicyTypeID), 1, false); err != nil {
+ if err := validate.MinimumInt("policy_type_id", "path", o.PolicyTypeID, 1, false); err != nil {
return err
}
- if err := validate.MaximumInt("policy_type_id", "path", int64(o.PolicyTypeID), 2.147483647e+09, false); err != nil {
+ if err := validate.MaximumInt("policy_type_id", "path", o.PolicyTypeID, 2.147483647e+09, false); err != nil {
return err
}
"github.com/go-openapi/runtime"
- "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
)
// A1ControllerGetAllInstancesForTypeOKCode is the HTTP code returned for type A1ControllerGetAllInstancesForTypeOK
return &A1ControllerGetAllPolicyTypes{Context: ctx, Handler: handler}
}
-/*A1ControllerGetAllPolicyTypes swagger:route GET /a1-p/policytypes A1 Mediator a1ControllerGetAllPolicyTypes
+/* A1ControllerGetAllPolicyTypes swagger:route GET /a1-p/policytypes A1 Mediator a1ControllerGetAllPolicyTypes
Get a list of all registered policy type ids
func (o *A1ControllerGetAllPolicyTypes) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerGetAllPolicyTypesParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
)
// NewA1ControllerGetAllPolicyTypesParams creates a new A1ControllerGetAllPolicyTypesParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerGetAllPolicyTypesParams() A1ControllerGetAllPolicyTypesParams {
return A1ControllerGetAllPolicyTypesParams{}
"github.com/go-openapi/runtime"
- "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
)
// A1ControllerGetAllPolicyTypesOKCode is the HTTP code returned for type A1ControllerGetAllPolicyTypesOK
return &A1ControllerGetHealthcheck{Context: ctx, Handler: handler}
}
-/*A1ControllerGetHealthcheck swagger:route GET /a1-p/healthcheck A1 Mediator a1ControllerGetHealthcheck
+/* A1ControllerGetHealthcheck swagger:route GET /a1-p/healthcheck A1 Mediator a1ControllerGetHealthcheck
Perform a healthcheck on a1
func (o *A1ControllerGetHealthcheck) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerGetHealthcheckParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
)
// NewA1ControllerGetHealthcheckParams creates a new A1ControllerGetHealthcheckParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerGetHealthcheckParams() A1ControllerGetHealthcheckParams {
return A1ControllerGetHealthcheckParams{}
// A1ControllerGetHealthcheckOKCode is the HTTP code returned for type A1ControllerGetHealthcheckOK
const A1ControllerGetHealthcheckOKCode int = 200
-/*A1ControllerGetHealthcheckOK A1 is healthy. Anything other than a 200 should be considered a1 as failing
-
+/*
+A1ControllerGetHealthcheckOK A1 is healthy. Anything other than a 200 should be considered a1 as failing
swagger:response a1ControllerGetHealthcheckOK
*/
rw.WriteHeader(200)
}
-
// A1ControllerGetHealthcheckInternalServerErrorCode is the HTTP code returned for type A1ControllerGetHealthcheckInternalServerError
const A1ControllerGetHealthcheckInternalServerErrorCode int = 500
rw.WriteHeader(500)
}
+
return &A1ControllerGetPolicyInstance{Context: ctx, Handler: handler}
}
-/*A1ControllerGetPolicyInstance swagger:route GET /a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id} A1 Mediator a1ControllerGetPolicyInstance
+/* A1ControllerGetPolicyInstance swagger:route GET /a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id} A1 Mediator a1ControllerGetPolicyInstance
Retrieve the policy instance
func (o *A1ControllerGetPolicyInstance) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerGetPolicyInstanceParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
"net/http"
"github.com/go-openapi/errors"
+ "github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewA1ControllerGetPolicyInstanceParams creates a new A1ControllerGetPolicyInstanceParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerGetPolicyInstanceParams() A1ControllerGetPolicyInstanceParams {
return A1ControllerGetPolicyInstanceParams{}
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
+ /*URL send by non-RT RIC. This where non-RT RIC expects status updates on the policy creation
+
+ In: query
+ */
+ NotificationDestination *string
/*represents a policy instance identifier. UUIDs are advisable but can be any string
Required: true
o.HTTPRequest = r
+ qs := runtime.Values(r.URL.Query())
+
+ qNotificationDestination, qhkNotificationDestination, _ := qs.GetOK("notificationDestination")
+ if err := o.bindNotificationDestination(qNotificationDestination, qhkNotificationDestination, route.Formats); err != nil {
+ res = append(res, err)
+ }
+
rPolicyInstanceID, rhkPolicyInstanceID, _ := route.Params.GetOK("policy_instance_id")
if err := o.bindPolicyInstanceID(rPolicyInstanceID, rhkPolicyInstanceID, route.Formats); err != nil {
res = append(res, err)
if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
res = append(res, err)
}
-
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
+// bindNotificationDestination binds and validates parameter NotificationDestination from query.
+func (o *A1ControllerGetPolicyInstanceParams) bindNotificationDestination(rawData []string, hasKey bool, formats strfmt.Registry) error {
+ var raw string
+ if len(rawData) > 0 {
+ raw = rawData[len(rawData)-1]
+ }
+
+ // Required: false
+ // AllowEmptyValue: false
+
+ if raw == "" { // empty values pass all other validations
+ return nil
+ }
+ o.NotificationDestination = &raw
+
+ return nil
+}
+
// bindPolicyInstanceID binds and validates parameter PolicyInstanceID from path.
func (o *A1ControllerGetPolicyInstanceParams) bindPolicyInstanceID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
// Required: true
// Parameter is provided by construction from the route
-
o.PolicyInstanceID = raw
return nil
// validatePolicyTypeID carries on validations for parameter PolicyTypeID
func (o *A1ControllerGetPolicyInstanceParams) validatePolicyTypeID(formats strfmt.Registry) error {
- if err := validate.MinimumInt("policy_type_id", "path", int64(o.PolicyTypeID), 1, false); err != nil {
+ if err := validate.MinimumInt("policy_type_id", "path", o.PolicyTypeID, 1, false); err != nil {
return err
}
- if err := validate.MaximumInt("policy_type_id", "path", int64(o.PolicyTypeID), 2.147483647e+09, false); err != nil {
+ if err := validate.MaximumInt("policy_type_id", "path", o.PolicyTypeID, 2.147483647e+09, false); err != nil {
return err
}
// Editing this file might prove futile when you re-run the generate command
import (
+ "context"
"encoding/json"
"net/http"
return &A1ControllerGetPolicyInstanceStatus{Context: ctx, Handler: handler}
}
-/*A1ControllerGetPolicyInstanceStatus swagger:route GET /a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}/status A1 Mediator a1ControllerGetPolicyInstanceStatus
+/* A1ControllerGetPolicyInstanceStatus swagger:route GET /a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}/status A1 Mediator a1ControllerGetPolicyInstanceStatus
Retrieve the policy instance status across all handlers of the policy If this endpoint returns successfully (200), it is either IN EFFECT or NOT IN EFFECT. IN EFFECT is returned if at least one policy handler in the RIC is implementing the policy NOT IN EFFECT is returned otherwise If a policy instance is successfully deleted, this endpoint will return a 404 (not a 200)
func (o *A1ControllerGetPolicyInstanceStatus) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerGetPolicyInstanceStatusParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
// swagger:model A1ControllerGetPolicyInstanceStatusOKBody
type A1ControllerGetPolicyInstanceStatusOKBody struct {
- // created at
- // Format: date-time
- CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
+ // enforce reason
+ // Enum: [SCOPE_NOT_APPLICABLE STATEMENT_NOT_APPLICABLE OTHER_REASON]
+ EnforceReason string `json:"enforceReason,omitempty"`
- // has been deleted
- HasBeenDeleted bool `json:"has_been_deleted,omitempty"`
-
- // instance status
- // Enum: [IN EFFECT NOT IN EFFECT]
- InstanceStatus string `json:"instance_status,omitempty"`
+ // enforce status
+ // Enum: [ENFORCED NOT_ENFORCED]
+ EnforceStatus string `json:"enforceStatus,omitempty"`
}
// Validate validates this a1 controller get policy instance status o k body
func (o *A1ControllerGetPolicyInstanceStatusOKBody) Validate(formats strfmt.Registry) error {
var res []error
- if err := o.validateCreatedAt(formats); err != nil {
+ if err := o.validateEnforceReason(formats); err != nil {
res = append(res, err)
}
- if err := o.validateInstanceStatus(formats); err != nil {
+ if err := o.validateEnforceStatus(formats); err != nil {
res = append(res, err)
}
return nil
}
-func (o *A1ControllerGetPolicyInstanceStatusOKBody) validateCreatedAt(formats strfmt.Registry) error {
+var a1ControllerGetPolicyInstanceStatusOKBodyTypeEnforceReasonPropEnum []interface{}
+
+func init() {
+ var res []string
+ if err := json.Unmarshal([]byte(`["SCOPE_NOT_APPLICABLE","STATEMENT_NOT_APPLICABLE","OTHER_REASON"]`), &res); err != nil {
+ panic(err)
+ }
+ for _, v := range res {
+ a1ControllerGetPolicyInstanceStatusOKBodyTypeEnforceReasonPropEnum = append(a1ControllerGetPolicyInstanceStatusOKBodyTypeEnforceReasonPropEnum, v)
+ }
+}
+
+const (
+
+ // A1ControllerGetPolicyInstanceStatusOKBodyEnforceReasonSCOPENOTAPPLICABLE captures enum value "SCOPE_NOT_APPLICABLE"
+ A1ControllerGetPolicyInstanceStatusOKBodyEnforceReasonSCOPENOTAPPLICABLE string = "SCOPE_NOT_APPLICABLE"
- if swag.IsZero(o.CreatedAt) { // not required
+ // A1ControllerGetPolicyInstanceStatusOKBodyEnforceReasonSTATEMENTNOTAPPLICABLE captures enum value "STATEMENT_NOT_APPLICABLE"
+ A1ControllerGetPolicyInstanceStatusOKBodyEnforceReasonSTATEMENTNOTAPPLICABLE string = "STATEMENT_NOT_APPLICABLE"
+
+ // A1ControllerGetPolicyInstanceStatusOKBodyEnforceReasonOTHERREASON captures enum value "OTHER_REASON"
+ A1ControllerGetPolicyInstanceStatusOKBodyEnforceReasonOTHERREASON string = "OTHER_REASON"
+)
+
+// prop value enum
+func (o *A1ControllerGetPolicyInstanceStatusOKBody) validateEnforceReasonEnum(path, location string, value string) error {
+ if err := validate.EnumCase(path, location, value, a1ControllerGetPolicyInstanceStatusOKBodyTypeEnforceReasonPropEnum, true); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (o *A1ControllerGetPolicyInstanceStatusOKBody) validateEnforceReason(formats strfmt.Registry) error {
+ if swag.IsZero(o.EnforceReason) { // not required
return nil
}
- if err := validate.FormatOf("a1ControllerGetPolicyInstanceStatusOK"+"."+"created_at", "body", "date-time", o.CreatedAt.String(), formats); err != nil {
+ // value enum
+ if err := o.validateEnforceReasonEnum("a1ControllerGetPolicyInstanceStatusOK"+"."+"enforceReason", "body", o.EnforceReason); err != nil {
return err
}
return nil
}
-var a1ControllerGetPolicyInstanceStatusOKBodyTypeInstanceStatusPropEnum []interface{}
+var a1ControllerGetPolicyInstanceStatusOKBodyTypeEnforceStatusPropEnum []interface{}
func init() {
var res []string
- if err := json.Unmarshal([]byte(`["IN EFFECT","NOT IN EFFECT"]`), &res); err != nil {
+ if err := json.Unmarshal([]byte(`["ENFORCED","NOT_ENFORCED"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
- a1ControllerGetPolicyInstanceStatusOKBodyTypeInstanceStatusPropEnum = append(a1ControllerGetPolicyInstanceStatusOKBodyTypeInstanceStatusPropEnum, v)
+ a1ControllerGetPolicyInstanceStatusOKBodyTypeEnforceStatusPropEnum = append(a1ControllerGetPolicyInstanceStatusOKBodyTypeEnforceStatusPropEnum, v)
}
}
const (
- // A1ControllerGetPolicyInstanceStatusOKBodyInstanceStatusINEFFECT captures enum value "IN EFFECT"
- A1ControllerGetPolicyInstanceStatusOKBodyInstanceStatusINEFFECT string = "IN EFFECT"
+ // A1ControllerGetPolicyInstanceStatusOKBodyEnforceStatusENFORCED captures enum value "ENFORCED"
+ A1ControllerGetPolicyInstanceStatusOKBodyEnforceStatusENFORCED string = "ENFORCED"
- // A1ControllerGetPolicyInstanceStatusOKBodyInstanceStatusNOTINEFFECT captures enum value "NOT IN EFFECT"
- A1ControllerGetPolicyInstanceStatusOKBodyInstanceStatusNOTINEFFECT string = "NOT IN EFFECT"
+ // A1ControllerGetPolicyInstanceStatusOKBodyEnforceStatusNOTENFORCED captures enum value "NOT_ENFORCED"
+ A1ControllerGetPolicyInstanceStatusOKBodyEnforceStatusNOTENFORCED string = "NOT_ENFORCED"
)
// prop value enum
-func (o *A1ControllerGetPolicyInstanceStatusOKBody) validateInstanceStatusEnum(path, location string, value string) error {
- if err := validate.Enum(path, location, value, a1ControllerGetPolicyInstanceStatusOKBodyTypeInstanceStatusPropEnum); err != nil {
+func (o *A1ControllerGetPolicyInstanceStatusOKBody) validateEnforceStatusEnum(path, location string, value string) error {
+ if err := validate.EnumCase(path, location, value, a1ControllerGetPolicyInstanceStatusOKBodyTypeEnforceStatusPropEnum, true); err != nil {
return err
}
return nil
}
-func (o *A1ControllerGetPolicyInstanceStatusOKBody) validateInstanceStatus(formats strfmt.Registry) error {
-
- if swag.IsZero(o.InstanceStatus) { // not required
+func (o *A1ControllerGetPolicyInstanceStatusOKBody) validateEnforceStatus(formats strfmt.Registry) error {
+ if swag.IsZero(o.EnforceStatus) { // not required
return nil
}
// value enum
- if err := o.validateInstanceStatusEnum("a1ControllerGetPolicyInstanceStatusOK"+"."+"instance_status", "body", o.InstanceStatus); err != nil {
+ if err := o.validateEnforceStatusEnum("a1ControllerGetPolicyInstanceStatusOK"+"."+"enforceStatus", "body", o.EnforceStatus); err != nil {
return err
}
return nil
}
+// ContextValidate validates this a1 controller get policy instance status o k body based on context it is used
+func (o *A1ControllerGetPolicyInstanceStatusOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
+ return nil
+}
+
// MarshalBinary interface implementation
func (o *A1ControllerGetPolicyInstanceStatusOKBody) MarshalBinary() ([]byte, error) {
if o == nil {
)
// NewA1ControllerGetPolicyInstanceStatusParams creates a new A1ControllerGetPolicyInstanceStatusParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerGetPolicyInstanceStatusParams() A1ControllerGetPolicyInstanceStatusParams {
return A1ControllerGetPolicyInstanceStatusParams{}
if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
res = append(res, err)
}
-
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
// Required: true
// Parameter is provided by construction from the route
-
o.PolicyInstanceID = raw
return nil
// validatePolicyTypeID carries on validations for parameter PolicyTypeID
func (o *A1ControllerGetPolicyInstanceStatusParams) validatePolicyTypeID(formats strfmt.Registry) error {
- if err := validate.MinimumInt("policy_type_id", "path", int64(o.PolicyTypeID), 1, false); err != nil {
+ if err := validate.MinimumInt("policy_type_id", "path", o.PolicyTypeID, 1, false); err != nil {
return err
}
- if err := validate.MaximumInt("policy_type_id", "path", int64(o.PolicyTypeID), 2.147483647e+09, false); err != nil {
+ if err := validate.MaximumInt("policy_type_id", "path", o.PolicyTypeID, 2.147483647e+09, false); err != nil {
return err
}
PolicyInstanceID string
PolicyTypeID int64
+ NotificationDestination *string
+
_basePath string
// avoid unkeyed usage
_ struct{}
_basePath := o._basePath
_result.Path = golangswaggerpaths.Join(_basePath, _path)
+ qs := make(url.Values)
+
+ var notificationDestinationQ string
+ if o.NotificationDestination != nil {
+ notificationDestinationQ = *o.NotificationDestination
+ }
+ if notificationDestinationQ != "" {
+ qs.Set("notificationDestination", notificationDestinationQ)
+ }
+
+ _result.RawQuery = qs.Encode()
+
return &_result, nil
}
return &A1ControllerGetPolicyType{Context: ctx, Handler: handler}
}
-/*A1ControllerGetPolicyType swagger:route GET /a1-p/policytypes/{policy_type_id} A1 Mediator a1ControllerGetPolicyType
+/* A1ControllerGetPolicyType swagger:route GET /a1-p/policytypes/{policy_type_id} A1 Mediator a1ControllerGetPolicyType
Get this policy type
func (o *A1ControllerGetPolicyType) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
- r = rCtx
+ *r = *rCtx
}
var Params = NewA1ControllerGetPolicyTypeParams()
-
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
-
o.Context.Respond(rw, r, route.Produces, route, res)
}
)
// NewA1ControllerGetPolicyTypeParams creates a new A1ControllerGetPolicyTypeParams object
-// no default values defined in spec.
+//
+// There are no default values defined in the spec.
func NewA1ControllerGetPolicyTypeParams() A1ControllerGetPolicyTypeParams {
return A1ControllerGetPolicyTypeParams{}
if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
res = append(res, err)
}
-
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
// validatePolicyTypeID carries on validations for parameter PolicyTypeID
func (o *A1ControllerGetPolicyTypeParams) validatePolicyTypeID(formats strfmt.Registry) error {
- if err := validate.MinimumInt("policy_type_id", "path", int64(o.PolicyTypeID), 1, false); err != nil {
+ if err := validate.MinimumInt("policy_type_id", "path", o.PolicyTypeID, 1, false); err != nil {
return err
}
- if err := validate.MaximumInt("policy_type_id", "path", int64(o.PolicyTypeID), 2.147483647e+09, false); err != nil {
+ if err := validate.MaximumInt("policy_type_id", "path", o.PolicyTypeID, 2.147483647e+09, false); err != nil {
return err
}
"github.com/go-openapi/runtime"
- "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
)
// A1ControllerGetPolicyTypeOKCode is the HTTP code returned for type A1ControllerGetPolicyTypeOK
flags "github.com/jessevdk/go-flags"
"golang.org/x/net/netutil"
- "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations"
)
const (
s.Fatalf("no certificate was configured for TLS")
}
- // must have at least one certificate or panics
- httpsServer.TLSConfig.BuildNameToCertificate()
-
configureServer(httpsServer, "https", s.httpsServerL.Addr().String())
servers = append(servers, httpsServer)
/*
==================================================================================
- Copyright (c) 2021 Samsung
- 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
+ Copyright (c) 2021 Samsung
- http://www.apache.org/licenses/LICENSE-2.0
+ 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
- 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.
+ 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.
+
+ This source code is part of the near-RT RIC (RAN Intelligent Controller)
+ platform project (RICP).
- This source code is part of the near-RT RIC (RAN Intelligent Controller)
- platform project (RICP).
==================================================================================
*/
package restful
api.A1MediatorA1ControllerCreateOrReplacePolicyInstanceHandler = a1_mediator.A1ControllerCreateOrReplacePolicyInstanceHandlerFunc(func(params a1_mediator.A1ControllerCreateOrReplacePolicyInstanceParams) middleware.Responder {
a1.Logger.Debug("handler for create policy type instance ")
- if err = r.rh.CreatePolicyInstance(models.PolicyTypeID(params.PolicyTypeID), models.PolicyInstanceID(params.PolicyInstanceID), params.Body); err == nil {
+ var notificationDestination string
+ if params.NotificationDestination != nil {
+ notificationDestination = *params.NotificationDestination
+ }
+ if err = r.rh.CreatePolicyInstance(models.PolicyTypeID(params.PolicyTypeID), models.PolicyInstanceID(params.PolicyInstanceID), params.Body, notificationDestination); err == nil {
+
return a1_mediator.NewA1ControllerCreateOrReplacePolicyInstanceAccepted()
}
if r.rh.IsValidJson(err) {
a1.Logger.Debug("handler for get policy instance status")
if resp, err := r.rh.GetPolicyInstanceStatus(models.PolicyTypeID(params.PolicyTypeID), models.PolicyInstanceID(params.PolicyInstanceID)); err == nil {
return a1_mediator.NewA1ControllerGetPolicyInstanceStatusOK().WithPayload(resp)
- }
- if r.rh.IsPolicyInstanceNotFound(err) {
+ } else if r.rh.IsPolicyInstanceNotFound(err) {
return a1_mediator.NewA1ControllerGetPolicyInstanceStatusNotFound()
}
return a1_mediator.NewA1ControllerGetPolicyInstanceStatusServiceUnavailable()
/*
==================================================================================
- Copyright (c) 2021 Samsung
- 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
+ Copyright (c) 2021 Samsung
- http://www.apache.org/licenses/LICENSE-2.0
+ 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
- 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.
+ 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.
+
+ This source code is part of the near-RT RIC (RAN Intelligent Controller)
+ platform project (RICP).
- This source code is part of the near-RT RIC (RAN Intelligent Controller)
- platform project (RICP).
==================================================================================
*/
package restful
import (
- "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations"
- resthook "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/resthooks"
+ "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations"
+ resthook "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/resthooks"
)
type Restful struct {
/*
==================================================================================
- Copyright (c) 2021 Samsung
- 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
+ Copyright (c) 2021 Samsung
- http://www.apache.org/licenses/LICENSE-2.0
+ 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
- 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.
+ 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.
+
+ This source code is part of the near-RT RIC (RAN Intelligent Controller)
+ platform project (RICP).
- This source code is part of the near-RT RIC (RAN Intelligent Controller)
- platform project (RICP).
==================================================================================
*/
package resthooks
)
const (
- a1PolicyPrefix = "a1.policy_type."
- a1MediatorNs = "A1m_ns"
- a1InstancePrefix = "a1.policy_instance."
- a1InstanceMetadataPrefix = "a1.policy_inst_metadata."
- a1HandlerPrefix = "a1.policy_handler."
- a1PolicyRequest = 20010
- a1EIDataDelivery = 20017
+ a1PolicyPrefix = "a1.policy_type."
+ a1MediatorNs = "A1m_ns"
+ a1InstancePrefix = "a1.policy_instance."
+ a1NotificationDestinationPrefix = "a1.policy_notification_destination."
+ a1InstanceMetadataPrefix = "a1.policy_inst_metadata."
+ a1HandlerPrefix = "a1.policy_handler."
+ a1PolicyRequest = 20010
+ a1EIDataDelivery = 20017
)
var typeAlreadyError = errors.New("Policy Type already exists")
return err == policyTypeCanNotBeDeletedError
}
-func (rh *Resthook) IsPolicyTypePresent(err error) bool {
+func (rh *Resthook) IsPolicyTypeNotFound(err error) bool {
return err == policyTypeNotFoundError
}
return true
}
-func (rh *Resthook) storePolicyInstance(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID, httpBody interface{}) (string, error) {
+func (rh *Resthook) storePolicyInstance(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID, httpBody interface{}, notificationDestination string) (string, error) {
var keys [1]string
operation := "CREATE"
typekey := a1PolicyPrefix + strconv.FormatInt((int64(policyTypeId)), 10)
// TODO : rmr creation_timestamp := time.Now() // will be needed for rmr to notify the creation of instance
instancekey := a1InstancePrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + string(policyInstanceID)
+ notificationDestinationkey := a1NotificationDestinationPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + string(policyInstanceID)
keys[0] = typekey
instanceMap, err := rh.db.Get(a1MediatorNs, keys[:])
if err != nil {
data, _ := json.Marshal(httpBody)
a1.Logger.Debug("Marshaled String : %+v", string(data))
a1.Logger.Debug("key : %+v", instancekey)
- success, err1 := rh.db.SetIf(a1MediatorNs, instancekey, instanceMap[instancekey], string(data))
- if err1 != nil {
- a1.Logger.Error("error2 :%+v", err1)
- return operation, err1
+ success, err := rh.db.SetIf(a1MediatorNs, instancekey, instanceMap[instancekey], string(data))
+ if err != nil {
+ a1.Logger.Error("error2 :%+v", err)
+ return operation, err
}
if !success {
a1.Logger.Debug("Policy instance %+v already exist", policyInstanceID)
return operation, InstanceAlreadyError
}
+
+ if len(notificationDestination) > 0 {
+ if err = rh.db.Set(a1MediatorNs, notificationDestinationkey, notificationDestination); err != nil {
+ a1.Logger.Error("error3 :%+v", err)
+ return operation, err
+ }
+ }
} else {
data, _ := json.Marshal(httpBody)
a1.Logger.Debug("Marshaled String : %+v", string(data))
a1.Logger.Debug("policyinstancetype map : %+v", instance_map[1])
a1.Logger.Debug("policyinstancetype to create : %+v", instance_map)
- err1 := rh.db.Set(a1MediatorNs, instancekey, string(data))
- if err1 != nil {
- a1.Logger.Error("error1 :%+v", err1)
- return operation, err1
+ if err = rh.db.Set(a1MediatorNs, instancekey, string(data)); err != nil {
+ a1.Logger.Error("error4 :%+v", err)
+ return operation, err
+ }
+ if len(notificationDestination) > 0 {
+ if err := rh.db.Set(a1MediatorNs, notificationDestinationkey, notificationDestination); err != nil {
+ a1.Logger.Error("error :%+v", err)
+ return operation, err
+ }
}
}
a1.Logger.Debug("Policy Instance created ")
return true, nil
}
-func (rh *Resthook) CreatePolicyInstance(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID, httpBody interface{}) error {
+func (rh *Resthook) CreatePolicyInstance(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID, httpBody interface{}, notificationDestination string) error {
a1.Logger.Debug("CreatePolicyInstance function")
// validate the PUT against the schema
var policyTypeSchema *models.PolicyTypeSchema
isvalid := validate(httpBodyString, schemaString)
if isvalid {
var operation string
- operation, err = rh.storePolicyInstance(policyTypeId, policyInstanceID, httpBody)
+ operation, err = rh.storePolicyInstance(policyTypeId, policyInstanceID, httpBody, notificationDestination)
if err != nil {
a1.Logger.Error("error :%+v", err)
return err
func (rh *Resthook) GetPolicyInstanceStatus(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID) (*a1_mediator.A1ControllerGetPolicyInstanceStatusOKBody, error) {
err := rh.instanceValidity(policyTypeId, policyInstanceID)
policyInstanceStatus := a1_mediator.A1ControllerGetPolicyInstanceStatusOKBody{}
- policyInstanceStatus.InstanceStatus = "NOT IN EFFECT"
- if err != nil && err == policyInstanceNotFoundError || err == policyTypeNotFoundError {
+ policyInstanceStatus.EnforceStatus = "NOT_ENFORCED"
+ policyInstanceStatus.EnforceReason = "OTHER_REASON"
+ if err != nil && (err == policyInstanceNotFoundError || err == policyTypeNotFoundError) {
return &policyInstanceStatus, err
}
metadata, err := rh.getMetaData(policyTypeId, policyInstanceID)
//this error maps to 503 error but can be mapped to 500: internal error
return &policyInstanceStatus, err
}
- resp, err := rh.getPolicyInstanceStatus(policyTypeId, policyInstanceID)
- if err != nil || (err == nil && resp == false) {
+ enforced, err := rh.getPolicyInstanceStatus(policyTypeId, policyInstanceID)
+ if err != nil || (err == nil && !enforced) {
a1.Logger.Error("marshal error : %v", err)
return &policyInstanceStatus, err
- } else if policyInstanceStatus.HasBeenDeleted == true {
- policyInstanceStatus.InstanceStatus = "IN EFFECT"
}
+ policyInstanceStatus.EnforceStatus = "ENFORCED"
+ policyInstanceStatus.EnforceReason = ""
return &policyInstanceStatus, nil
}
keys[0] = instancekey
err := rh.db.Remove(a1MediatorNs, keys[:])
if err != nil {
- a1.Logger.Error("error in deleting policy type err: %v", err)
+ a1.Logger.Error("error in deleting policy instance err: %v", err)
return err
}
return nil
}
+func (rh *Resthook) deleteNotificationDestination(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID) error {
+ var keys [1]string
+ notificationDestinationkey := a1NotificationDestinationPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + string(policyInstanceID)
+ keys[0] = notificationDestinationkey
+ err := rh.db.Remove(a1MediatorNs, keys[:])
+ if err != nil {
+ a1.Logger.Error("error in deleting notificationDestination err: %v", err)
+ return err
+ }
+
+ return nil
+}
+
func (rh *Resthook) deleteMetadata(policyTypeId models.PolicyTypeID, policyInstanceID models.PolicyInstanceID) error {
var keys [1]string
instanceMetadataKey := a1InstanceMetadataPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + string(policyInstanceID)
rh.deleteInstancedata(policyTypeId, policyInstanceID)
+ rh.deleteNotificationDestination(policyTypeId, policyInstanceID)
+
rh.storeDeletedPolicyInstanceMetadata(policyTypeId, policyInstanceID, creation_timestamp.(string))
message := rmr.Message{}
/*
==================================================================================
- Copyright (c) 2021 Samsung
- 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
+ Copyright (c) 2021 Samsung
- http://www.apache.org/licenses/LICENSE-2.0
+ 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
- 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.
+ 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.
+
+ This source code is part of the near-RT RIC (RAN Intelligent Controller)
+ platform project (RICP).
- This source code is part of the near-RT RIC (RAN Intelligent Controller)
- platform project (RICP).
==================================================================================
*/
package resthooks
sdlInst.On("Set", "A1m_ns", metadatainstancearr).Return(nil)
rmrSenderInst.On("RmrSendToXapp", "httpBodyString", 20010, int(policyTypeId)).Return(true)
- errresp := rh.CreatePolicyInstance(policyTypeId, policyInstanceID, instancedata)
+ errresp := rh.CreatePolicyInstance(policyTypeId, policyInstanceID, instancedata, "")
assert.Nil(t, errresp)
sdlInst.AssertExpectations(t)
description := "various parameters to control admission of dual connection"
policyTypeSchema.Description = &description
schema := `{"$schema": "http://json-schema.org/draft-07/schema#","type":"object","properties": {"enforce": {"type":"boolean","default":"true",},"window_length": {"type": "integer","default":1,"minimum":1,"maximum":60,"description": "Sliding window length (in minutes)",},
+
"blocking_rate": {"type":"number","default":10,"minimum":1,"maximum":100,"description": "% Connections to block",},"additionalProperties": false,},}`
+
policyTypeSchema.CreateSchema = schema
key := a1PolicyPrefix + strconv.FormatInt((int64(policyTypeId)), 10)
sdlInst.On("Get", a1MediatorNs, policytypekeys[:]).Return(map[string]interface{}{key: policyTypeSchema}, nil)
httpBody := `{
- "enforce":true,
- "window_length":20,
- "blocking_rate":20,
- "trigger_threshold":10
- }`
+ "enforce":true,
+ "window_length":20,
+ "blocking_rate":20,
+ "trigger_threshold":10
+ }`
instancekey := a1InstancePrefix + strconv.FormatInt(20001, 10) + "." + string(policyInstanceID)
var instancekeys [1]string
instancekeys[0] = instancekey
instanceMetadataKey := a1InstanceMetadataPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + string(policyInstanceID)
instanceMetadataKeys[0] = instanceMetadataKey
httpBody = `{
- "created_at":"2022-11-02 10:30:20",
- "instance_status":"NOT IN EFFECT"
- }`
+ "created_at":"2022-11-02 10:30:20",
+ "instance_status":"NOT IN EFFECT"
+ }`
sdlInst.On("Get", a1MediatorNs, instanceMetadataKeys[:]).Return(httpBody, nil)
httpBodyString := `{"operation":"DELETE","payload":"","policy_instance_id":"123456","policy_type_id":"20001"}`
rmrSenderInst.On("RmrSendToXapp", httpBodyString, 20010, int(policyTypeId)).Return(true)
-
+ notificationDestinationkey := a1NotificationDestinationPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + string(policyInstanceID)
+ var notificationDestinationkeys [1]string
+ notificationDestinationkeys[0] = notificationDestinationkey
+ sdlInst.On("Remove", a1MediatorNs, notificationDestinationkeys[:]).Return(nil)
errresp := rh.DeletePolicyInstance(policyTypeId, policyInstanceID)
assert.Nil(t, errresp)
a1.Logger.Error("Unmarshal error : %+v", err)
return err
}
- a1.Logger.Debug("message recieved for %d and %d with status : %s", result["policy_type_id"], result["policy_instance_id"], result["status"])
- rmr.policyManager.SetPolicyInstanceStatus(int(result["policy_type_id"].(float64)), int(result["policy_instance_id"].(float64)), result["status"].(string))
+ policyTypeId := int(result["policy_type_id"].(float64))
+ policyInstanceId := result["policy_instance_id"].(string)
+ policyHandlerId := result["handler_id"].(string)
+ policyStatus := result["status"].(string)
+
+ a1.Logger.Debug("message recieved for %d and %s with status : %s", policyTypeId, policyInstanceId, policyStatus)
+ rmr.policyManager.SetPolicyInstanceStatus(policyTypeId, policyInstanceId, policyStatus)
+ err = rmr.policyManager.SendPolicyStatusNotification(policyTypeId, policyInstanceId, policyHandlerId, policyStatus)
+ if err != nil {
+ a1.Logger.Debug("failed to send policy status notification %v+", err)
+ }
+
case "A1_POLICY_QUERY":
a1.Logger.Debug("Recived policy query")
a1.Logger.Debug("message recieved ", msg.Payload)