From: Mohamed Abukar Date: Sun, 4 Apr 2021 15:07:52 +0000 (+0300) Subject: Enhancements of REST-based E2 subscription interface X-Git-Tag: v0.8.0^0 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=3602bf801fef17e317cb35a4c710118ec80908b9;p=ric-plt%2Fxapp-frame.git Enhancements of REST-based E2 subscription interface Change-Id: I8a8d7f7367315163fedffe9d12440afa44eecb73 Signed-off-by: Mohamed Abukar --- diff --git a/api/xapp_rest_api.yaml b/api/xapp_rest_api.yaml index 6f7211e..74db6b9 100755 --- a/api/xapp_rest_api.yaml +++ b/api/xapp_rest_api.yaml @@ -31,7 +31,7 @@ paths: get: summary: Returns list of subscriptions tags: - - "query" + - "common" operationId: getAllSubscriptions produces: - application/json @@ -42,22 +42,21 @@ paths: $ref: '#/definitions/SubscriptionList' '500': description: Internal error - /subscriptions/report: post: tags: - - "report" - summary: Subscribe a list of X2AP event triggers to receive "REPORT" messages sent by RAN or Subscribe to receive the content of gNB NRT table in REPORT message sent by RAN - operationId: subscribeReport + - "common" + operationId: Subscribe + summary: Subscribe a list of X2AP event triggers to receive messages sent by RAN consumes: - application/json produces: - application/json parameters: - - name: ReportParams + - name: SubscriptionParams in: body - description: Subscription report parameters + description: Subscription parameters schema: - $ref: '#/definitions/ReportParams' + $ref: '#/definitions/SubscriptionParams' responses: '201': description: Subscription successfully created @@ -67,35 +66,10 @@ paths: description: Invalid input '500': description: Internal error - /subscriptions/policy: - post: - tags: - - "policy" - summary: Subscribe and send "POLICY" message to RAN to execute a specific POLICY during call processing in RAN after each occurrence of a defined SUBSCRIPTION - operationId: subscribePolicy - consumes: - - application/json - produces: - - application/json - parameters: - - name: PolicyParams - in: body - description: Subscription policy parameters - schema: - $ref: '#/definitions/PolicyParams' - responses: - '201': - description: Subscription successfully created - schema: - $ref: '#/definitions/SubscriptionResponse' - '400': - description: Invalid input - '500': - description: Internal error - /subscriptions/{subscriptionId}: + '/subscriptions/{subscriptionId}': delete: tags: - - "common" + - "common" summary: Unsubscribe X2AP events from Subscription Manager operationId: Unsubscribe consumes: @@ -147,174 +121,161 @@ definitions: type: array items: $ref: '#/definitions/XAppConfig' - SubscriptionType: - type: string - enum: - - insert - - policy - - report - ReportParams: + + ActionDefinition: + type: object + description: E2SM Octet string. ActionDefinition is an OPTIONAL IE + properties: + OctetString: + type: string + SubsequentAction: + description: SubsequentAction is an OPTIONAL IE type: object required: - - RANFunctionID - - ClientEndpoint - - EventTriggers + - SubsequentActionType + - TimeToWait properties: - Meid: + SubsequentActionType: type: string - RANFunctionID: - type: integer - ClientEndpoint: + enum: + - continue + - wait + TimeToWait: type: string - EventTriggers: - $ref: '#/definitions/EventTriggerList' - ReportActionDefinitions: - $ref: '#/definitions/ReportActionDefinition' - EventTrigger: + enum: + - zero + - w1ms + - w2ms + - w5ms + - w10ms + - w20ms + - w30ms + - w40ms + - w50ms + - w100ms + - w200ms + - w500ms + - w1s + - w2s + - w5s + - w10s + - w20s + - w60s + ActionToBeSetup: type: object + required: + - ActionID + - ActionType properties: - InterfaceDirection: - type: integer - ProcedureCode: - type: integer - TypeOfMessage: + ActionID: type: integer - TriggerNature: + minimum: 0 + maximum: 255 + ActionType: type: string enum: - - now - - on change - PlmnId: - type: string - ENBId: - type: string - EventTriggerList: + - insert + - policy + - report + ActionDefinition: + $ref: '#/definitions/ActionDefinition' + SubsequentAction: + $ref: '#/definitions/SubsequentAction' + ActionsToBeSetup: type: array items: - $ref: '#/definitions/EventTrigger' - ActionParameters: + $ref: '#/definitions/ActionToBeSetup' + EventTriggerDefinition: type: object - required: - - ActionParameterID - - ActionParameterValue + description: E2SM Octet string properties: - ActionParameterID: - type: integer - ActionParameterValue: - type: boolean - Format1ActionDefinition: + OctetString: + type: string + SubscriptionDetails: type: object required: - - StyleID - - ActionParameters + - EventTriggerList + - ActionToBeSetupList properties: - StyleID: - type: integer - ActionParameters: - type: array - items: - $ref: '#/definitions/ActionParameters' - ReportActionDefinition: - type: object - properties: - ActionDefinitionFormat1: - $ref: '#/definitions/Format1ActionDefinition' - PolicyParams: + EventTriggerList: + $ref: '#/definitions/EventTriggerDefinition' + ActionToBeSetupList: + $ref: '#/definitions/ActionsToBeSetup' + SubscriptionDetailsList: + type: array + items: + $ref: '#/definitions/SubscriptionDetails' + SubscriptionParams: type: object required: + - ClientEndpoint - Meid + - RequestorId + - InstanceId - RANFunctionID - - ClientEndpoint - - EventTriggers - - PolicyActionDefinitions + - SubscriptionDetails properties: + ClientEndpoint: + type: object + description: xApp service address and port + properties: + ServiceName: + description: >- + xApp service address name like + 'service-ricxapp-xappname-http.ricxapp' + type: string + Port: + description: xApp service address port + type: integer + minimum: 0 + maximum: 65535 Meid: type: string + RequestorId: + type: integer + minimum: 0 + maximum: 65535 + InstanceId: + type: integer + minimum: 0 + maximum: 65535 RANFunctionID: type: integer - ClientEndpoint: - type: string - EventTriggers: - $ref: '#/definitions/EventTriggerList' - PolicyActionDefinitions: - $ref: '#/definitions/PolicyActionDefinition' - PolicyActionDefinition: - type: object - properties: - ActionDefinitionFormat2: - $ref: '#/definitions/Format2ActionDefinition' - Format2ActionDefinition: + minimum: 0 + maximum: 4095 + SubscriptionDetails: + $ref: '#/definitions/SubscriptionDetailsList' + SubscriptionResponse: type: object required: - - RANUeGroupParameters + - SubscriptionId + - SubscriptionInstances properties: - RANUeGroupParameters: + SubscriptionId: + type: string + SubscriptionInstances: type: array items: - $ref: '#/definitions/RANUeGroupList' - RANUeGroupList: - type: object - required: - - RANUeGroupID - - RANUeGroupDefinition - - RANImperativePolicy - properties: - RANUeGroupID: - type: integer - RANUeGroupDefinition: - $ref: '#/definitions/RANUeGroupParams' - RANImperativePolicy: - $ref: '#/definitions/ImperativePolicyDefinition' - RANUeGroupParams: - type: object - required: - - RANParameterID - - RANParameterValue - properties: - RANParameterID: - type: integer - RANParameterTestCondition: - type: string - enum: - - equal - - greaterthan - - lessthan - - contains - - present - RANParameterValue: - type: integer - ImperativePolicyDefinition: - type: object - required: - - PolicyParameterID - - PolicyParameterValue - properties: - PolicyParameterID: - type: integer - PolicyParameterValue: - type: integer + $ref: '#/definitions/SubscriptionInstance' SubscriptionInstance: type: object required: - RequestorId - InstanceId + - ErrorCause properties: RequestorId: type: integer + minimum: 0 + maximum: 65535 InstanceId: type: integer - SubscriptionResponse: - type: object - required: - - SubscriptionId - - SubscriptionInstances - properties: - SubscriptionId: + minimum: 0 + maximum: 65535 + ErrorCause: + description: Empty string when no error. type: string - SubscriptionInstances: - type: array - items: - $ref: '#/definitions/SubscriptionInstance' + SubscriptionData: type: object properties: diff --git a/config/config-file.json b/config/config-file.json index e644caf..08a204e 100755 --- a/config/config-file.json +++ b/config/config-file.json @@ -63,7 +63,8 @@ }, "controls": { "logger": { - "level": 3 + "level": 3, + "noFormat": true }, "subscription": { "subscriptionActive": true, diff --git a/pkg/clientapi/common/common_client.go b/pkg/clientapi/common/common_client.go index 8db6f11..de4a4d7 100644 --- a/pkg/clientapi/common/common_client.go +++ b/pkg/clientapi/common/common_client.go @@ -24,6 +24,34 @@ type Client struct { formats strfmt.Registry } +/* +Subscribe subscribes a list of x2 a p event triggers to receive messages sent by r a n +*/ +func (a *Client) Subscribe(params *SubscribeParams) (*SubscribeCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewSubscribeParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "Subscribe", + Method: "POST", + PathPattern: "/subscriptions", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &SubscribeReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*SubscribeCreated), nil + +} + /* Unsubscribe unsubscribes x2 a p events from subscription manager */ @@ -52,6 +80,34 @@ func (a *Client) Unsubscribe(params *UnsubscribeParams) (*UnsubscribeNoContent, } +/* +GetAllSubscriptions returns list of subscriptions +*/ +func (a *Client) GetAllSubscriptions(params *GetAllSubscriptionsParams) (*GetAllSubscriptionsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetAllSubscriptionsParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getAllSubscriptions", + Method: "GET", + PathPattern: "/subscriptions", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{""}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetAllSubscriptionsReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetAllSubscriptionsOK), nil + +} + // SetTransport changes the transport on the client func (a *Client) SetTransport(transport runtime.ClientTransport) { a.transport = transport diff --git a/pkg/clientapi/query/get_all_subscriptions_parameters.go b/pkg/clientapi/common/get_all_subscriptions_parameters.go similarity index 99% rename from pkg/clientapi/query/get_all_subscriptions_parameters.go rename to pkg/clientapi/common/get_all_subscriptions_parameters.go index 94f3b84..1139f90 100644 --- a/pkg/clientapi/query/get_all_subscriptions_parameters.go +++ b/pkg/clientapi/common/get_all_subscriptions_parameters.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package query +package common // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command diff --git a/pkg/clientapi/query/get_all_subscriptions_responses.go b/pkg/clientapi/common/get_all_subscriptions_responses.go similarity index 99% rename from pkg/clientapi/query/get_all_subscriptions_responses.go rename to pkg/clientapi/common/get_all_subscriptions_responses.go index 801104a..2c774de 100644 --- a/pkg/clientapi/query/get_all_subscriptions_responses.go +++ b/pkg/clientapi/common/get_all_subscriptions_responses.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package query +package common // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command diff --git a/pkg/clientapi/common/subscribe_parameters.go b/pkg/clientapi/common/subscribe_parameters.go new file mode 100644 index 0000000..81ad7b3 --- /dev/null +++ b/pkg/clientapi/common/subscribe_parameters.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package common + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" + + clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" +) + +// NewSubscribeParams creates a new SubscribeParams object +// with the default values initialized. +func NewSubscribeParams() *SubscribeParams { + var () + return &SubscribeParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewSubscribeParamsWithTimeout creates a new SubscribeParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewSubscribeParamsWithTimeout(timeout time.Duration) *SubscribeParams { + var () + return &SubscribeParams{ + + timeout: timeout, + } +} + +// NewSubscribeParamsWithContext creates a new SubscribeParams object +// with the default values initialized, and the ability to set a context for a request +func NewSubscribeParamsWithContext(ctx context.Context) *SubscribeParams { + var () + return &SubscribeParams{ + + Context: ctx, + } +} + +// NewSubscribeParamsWithHTTPClient creates a new SubscribeParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewSubscribeParamsWithHTTPClient(client *http.Client) *SubscribeParams { + var () + return &SubscribeParams{ + HTTPClient: client, + } +} + +/*SubscribeParams contains all the parameters to send to the API endpoint +for the subscribe operation typically these are written to a http.Request +*/ +type SubscribeParams struct { + + /*SubscriptionParams + Subscription parameters + + */ + SubscriptionParams *clientmodel.SubscriptionParams + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the subscribe params +func (o *SubscribeParams) WithTimeout(timeout time.Duration) *SubscribeParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the subscribe params +func (o *SubscribeParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the subscribe params +func (o *SubscribeParams) WithContext(ctx context.Context) *SubscribeParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the subscribe params +func (o *SubscribeParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the subscribe params +func (o *SubscribeParams) WithHTTPClient(client *http.Client) *SubscribeParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the subscribe params +func (o *SubscribeParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithSubscriptionParams adds the subscriptionParams to the subscribe params +func (o *SubscribeParams) WithSubscriptionParams(subscriptionParams *clientmodel.SubscriptionParams) *SubscribeParams { + o.SetSubscriptionParams(subscriptionParams) + return o +} + +// SetSubscriptionParams adds the subscriptionParams to the subscribe params +func (o *SubscribeParams) SetSubscriptionParams(subscriptionParams *clientmodel.SubscriptionParams) { + o.SubscriptionParams = subscriptionParams +} + +// WriteToRequest writes these params to a swagger request +func (o *SubscribeParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.SubscriptionParams != nil { + if err := r.SetBodyParam(o.SubscriptionParams); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/clientapi/common/subscribe_responses.go b/pkg/clientapi/common/subscribe_responses.go new file mode 100644 index 0000000..5fb377d --- /dev/null +++ b/pkg/clientapi/common/subscribe_responses.go @@ -0,0 +1,123 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package common + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" + + clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" +) + +// SubscribeReader is a Reader for the Subscribe structure. +type SubscribeReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *SubscribeReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 201: + result := NewSubscribeCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 400: + result := NewSubscribeBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewSubscribeInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewSubscribeCreated creates a SubscribeCreated with default headers values +func NewSubscribeCreated() *SubscribeCreated { + return &SubscribeCreated{} +} + +/*SubscribeCreated handles this case with default header values. + +Subscription successfully created +*/ +type SubscribeCreated struct { + Payload *clientmodel.SubscriptionResponse +} + +func (o *SubscribeCreated) Error() string { + return fmt.Sprintf("[POST /subscriptions][%d] subscribeCreated %+v", 201, o.Payload) +} + +func (o *SubscribeCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(clientmodel.SubscriptionResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewSubscribeBadRequest creates a SubscribeBadRequest with default headers values +func NewSubscribeBadRequest() *SubscribeBadRequest { + return &SubscribeBadRequest{} +} + +/*SubscribeBadRequest handles this case with default header values. + +Invalid input +*/ +type SubscribeBadRequest struct { +} + +func (o *SubscribeBadRequest) Error() string { + return fmt.Sprintf("[POST /subscriptions][%d] subscribeBadRequest ", 400) +} + +func (o *SubscribeBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewSubscribeInternalServerError creates a SubscribeInternalServerError with default headers values +func NewSubscribeInternalServerError() *SubscribeInternalServerError { + return &SubscribeInternalServerError{} +} + +/*SubscribeInternalServerError handles this case with default header values. + +Internal error +*/ +type SubscribeInternalServerError struct { +} + +func (o *SubscribeInternalServerError) Error() string { + return fmt.Sprintf("[POST /subscriptions][%d] subscribeInternalServerError ", 500) +} + +func (o *SubscribeInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/pkg/clientapi/policy/policy_client.go b/pkg/clientapi/policy/policy_client.go deleted file mode 100644 index b8ca3bb..0000000 --- a/pkg/clientapi/policy/policy_client.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package policy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" -) - -// New creates a new policy API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { - return &Client{transport: transport, formats: formats} -} - -/* -Client for policy API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -/* -SubscribePolicy subscribes and send p o l i c y message to r a n to execute a specific p o l i c y during call processing in r a n after each occurrence of a defined s u b s c r IP t i o n -*/ -func (a *Client) SubscribePolicy(params *SubscribePolicyParams) (*SubscribePolicyCreated, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewSubscribePolicyParams() - } - - result, err := a.transport.Submit(&runtime.ClientOperation{ - ID: "subscribePolicy", - Method: "POST", - PathPattern: "/subscriptions/policy", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"http"}, - Params: params, - Reader: &SubscribePolicyReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - }) - if err != nil { - return nil, err - } - return result.(*SubscribePolicyCreated), nil - -} - -// SetTransport changes the transport on the client -func (a *Client) SetTransport(transport runtime.ClientTransport) { - a.transport = transport -} diff --git a/pkg/clientapi/policy/subscribe_policy_parameters.go b/pkg/clientapi/policy/subscribe_policy_parameters.go deleted file mode 100644 index 9d4cf92..0000000 --- a/pkg/clientapi/policy/subscribe_policy_parameters.go +++ /dev/null @@ -1,139 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package policy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" - - clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" -) - -// NewSubscribePolicyParams creates a new SubscribePolicyParams object -// with the default values initialized. -func NewSubscribePolicyParams() *SubscribePolicyParams { - var () - return &SubscribePolicyParams{ - - timeout: cr.DefaultTimeout, - } -} - -// NewSubscribePolicyParamsWithTimeout creates a new SubscribePolicyParams object -// with the default values initialized, and the ability to set a timeout on a request -func NewSubscribePolicyParamsWithTimeout(timeout time.Duration) *SubscribePolicyParams { - var () - return &SubscribePolicyParams{ - - timeout: timeout, - } -} - -// NewSubscribePolicyParamsWithContext creates a new SubscribePolicyParams object -// with the default values initialized, and the ability to set a context for a request -func NewSubscribePolicyParamsWithContext(ctx context.Context) *SubscribePolicyParams { - var () - return &SubscribePolicyParams{ - - Context: ctx, - } -} - -// NewSubscribePolicyParamsWithHTTPClient creates a new SubscribePolicyParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request -func NewSubscribePolicyParamsWithHTTPClient(client *http.Client) *SubscribePolicyParams { - var () - return &SubscribePolicyParams{ - HTTPClient: client, - } -} - -/*SubscribePolicyParams contains all the parameters to send to the API endpoint -for the subscribe policy operation typically these are written to a http.Request -*/ -type SubscribePolicyParams struct { - - /*PolicyParams - Subscription policy parameters - - */ - PolicyParams *clientmodel.PolicyParams - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithTimeout adds the timeout to the subscribe policy params -func (o *SubscribePolicyParams) WithTimeout(timeout time.Duration) *SubscribePolicyParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the subscribe policy params -func (o *SubscribePolicyParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the subscribe policy params -func (o *SubscribePolicyParams) WithContext(ctx context.Context) *SubscribePolicyParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the subscribe policy params -func (o *SubscribePolicyParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the subscribe policy params -func (o *SubscribePolicyParams) WithHTTPClient(client *http.Client) *SubscribePolicyParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the subscribe policy params -func (o *SubscribePolicyParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithPolicyParams adds the policyParams to the subscribe policy params -func (o *SubscribePolicyParams) WithPolicyParams(policyParams *clientmodel.PolicyParams) *SubscribePolicyParams { - o.SetPolicyParams(policyParams) - return o -} - -// SetPolicyParams adds the policyParams to the subscribe policy params -func (o *SubscribePolicyParams) SetPolicyParams(policyParams *clientmodel.PolicyParams) { - o.PolicyParams = policyParams -} - -// WriteToRequest writes these params to a swagger request -func (o *SubscribePolicyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if o.PolicyParams != nil { - if err := r.SetBodyParam(o.PolicyParams); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/clientapi/policy/subscribe_policy_responses.go b/pkg/clientapi/policy/subscribe_policy_responses.go deleted file mode 100644 index 6241c82..0000000 --- a/pkg/clientapi/policy/subscribe_policy_responses.go +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package policy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" - - clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" -) - -// SubscribePolicyReader is a Reader for the SubscribePolicy structure. -type SubscribePolicyReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *SubscribePolicyReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - - case 201: - result := NewSubscribePolicyCreated() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - - case 400: - result := NewSubscribePolicyBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - - case 500: - result := NewSubscribePolicyInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - - default: - return nil, runtime.NewAPIError("unknown error", response, response.Code()) - } -} - -// NewSubscribePolicyCreated creates a SubscribePolicyCreated with default headers values -func NewSubscribePolicyCreated() *SubscribePolicyCreated { - return &SubscribePolicyCreated{} -} - -/*SubscribePolicyCreated handles this case with default header values. - -Subscription successfully created -*/ -type SubscribePolicyCreated struct { - Payload *clientmodel.SubscriptionResponse -} - -func (o *SubscribePolicyCreated) Error() string { - return fmt.Sprintf("[POST /subscriptions/policy][%d] subscribePolicyCreated %+v", 201, o.Payload) -} - -func (o *SubscribePolicyCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(clientmodel.SubscriptionResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewSubscribePolicyBadRequest creates a SubscribePolicyBadRequest with default headers values -func NewSubscribePolicyBadRequest() *SubscribePolicyBadRequest { - return &SubscribePolicyBadRequest{} -} - -/*SubscribePolicyBadRequest handles this case with default header values. - -Invalid input -*/ -type SubscribePolicyBadRequest struct { -} - -func (o *SubscribePolicyBadRequest) Error() string { - return fmt.Sprintf("[POST /subscriptions/policy][%d] subscribePolicyBadRequest ", 400) -} - -func (o *SubscribePolicyBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - return nil -} - -// NewSubscribePolicyInternalServerError creates a SubscribePolicyInternalServerError with default headers values -func NewSubscribePolicyInternalServerError() *SubscribePolicyInternalServerError { - return &SubscribePolicyInternalServerError{} -} - -/*SubscribePolicyInternalServerError handles this case with default header values. - -Internal error -*/ -type SubscribePolicyInternalServerError struct { -} - -func (o *SubscribePolicyInternalServerError) Error() string { - return fmt.Sprintf("[POST /subscriptions/policy][%d] subscribePolicyInternalServerError ", 500) -} - -func (o *SubscribePolicyInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - return nil -} diff --git a/pkg/clientapi/r_i_c_subscription_client.go b/pkg/clientapi/r_i_c_subscription_client.go index 2acd8c0..d5df71c 100644 --- a/pkg/clientapi/r_i_c_subscription_client.go +++ b/pkg/clientapi/r_i_c_subscription_client.go @@ -12,9 +12,7 @@ import ( strfmt "github.com/go-openapi/strfmt" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/common" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/policy" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/query" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/report" + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/xapp" ) // Default r i c subscription HTTP client. @@ -62,11 +60,7 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *RICSubscri cli.Common = common.New(transport, formats) - cli.Policy = policy.New(transport, formats) - - cli.Query = query.New(transport, formats) - - cli.Report = report.New(transport, formats) + cli.Xapp = xapp.New(transport, formats) return cli } @@ -114,11 +108,7 @@ func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { type RICSubscription struct { Common *common.Client - Policy *policy.Client - - Query *query.Client - - Report *report.Client + Xapp *xapp.Client Transport runtime.ClientTransport } @@ -129,10 +119,6 @@ func (c *RICSubscription) SetTransport(transport runtime.ClientTransport) { c.Common.SetTransport(transport) - c.Policy.SetTransport(transport) - - c.Query.SetTransport(transport) - - c.Report.SetTransport(transport) + c.Xapp.SetTransport(transport) } diff --git a/pkg/clientapi/report/report_client.go b/pkg/clientapi/report/report_client.go deleted file mode 100644 index 2f30071..0000000 --- a/pkg/clientapi/report/report_client.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package report - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" -) - -// New creates a new report API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { - return &Client{transport: transport, formats: formats} -} - -/* -Client for report API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -/* -SubscribeReport subscribes a list of x2 a p event triggers to receive r e p o r t messages sent by r a n or subscribe to receive the content of g n b n r t table in r e p o r t message sent by r a n -*/ -func (a *Client) SubscribeReport(params *SubscribeReportParams) (*SubscribeReportCreated, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewSubscribeReportParams() - } - - result, err := a.transport.Submit(&runtime.ClientOperation{ - ID: "subscribeReport", - Method: "POST", - PathPattern: "/subscriptions/report", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"http"}, - Params: params, - Reader: &SubscribeReportReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - }) - if err != nil { - return nil, err - } - return result.(*SubscribeReportCreated), nil - -} - -// SetTransport changes the transport on the client -func (a *Client) SetTransport(transport runtime.ClientTransport) { - a.transport = transport -} diff --git a/pkg/clientapi/report/subscribe_report_parameters.go b/pkg/clientapi/report/subscribe_report_parameters.go deleted file mode 100644 index dad7e45..0000000 --- a/pkg/clientapi/report/subscribe_report_parameters.go +++ /dev/null @@ -1,139 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package report - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - - strfmt "github.com/go-openapi/strfmt" - - clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" -) - -// NewSubscribeReportParams creates a new SubscribeReportParams object -// with the default values initialized. -func NewSubscribeReportParams() *SubscribeReportParams { - var () - return &SubscribeReportParams{ - - timeout: cr.DefaultTimeout, - } -} - -// NewSubscribeReportParamsWithTimeout creates a new SubscribeReportParams object -// with the default values initialized, and the ability to set a timeout on a request -func NewSubscribeReportParamsWithTimeout(timeout time.Duration) *SubscribeReportParams { - var () - return &SubscribeReportParams{ - - timeout: timeout, - } -} - -// NewSubscribeReportParamsWithContext creates a new SubscribeReportParams object -// with the default values initialized, and the ability to set a context for a request -func NewSubscribeReportParamsWithContext(ctx context.Context) *SubscribeReportParams { - var () - return &SubscribeReportParams{ - - Context: ctx, - } -} - -// NewSubscribeReportParamsWithHTTPClient creates a new SubscribeReportParams object -// with the default values initialized, and the ability to set a custom HTTPClient for a request -func NewSubscribeReportParamsWithHTTPClient(client *http.Client) *SubscribeReportParams { - var () - return &SubscribeReportParams{ - HTTPClient: client, - } -} - -/*SubscribeReportParams contains all the parameters to send to the API endpoint -for the subscribe report operation typically these are written to a http.Request -*/ -type SubscribeReportParams struct { - - /*ReportParams - Subscription report parameters - - */ - ReportParams *clientmodel.ReportParams - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithTimeout adds the timeout to the subscribe report params -func (o *SubscribeReportParams) WithTimeout(timeout time.Duration) *SubscribeReportParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the subscribe report params -func (o *SubscribeReportParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the subscribe report params -func (o *SubscribeReportParams) WithContext(ctx context.Context) *SubscribeReportParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the subscribe report params -func (o *SubscribeReportParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the subscribe report params -func (o *SubscribeReportParams) WithHTTPClient(client *http.Client) *SubscribeReportParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the subscribe report params -func (o *SubscribeReportParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithReportParams adds the reportParams to the subscribe report params -func (o *SubscribeReportParams) WithReportParams(reportParams *clientmodel.ReportParams) *SubscribeReportParams { - o.SetReportParams(reportParams) - return o -} - -// SetReportParams adds the reportParams to the subscribe report params -func (o *SubscribeReportParams) SetReportParams(reportParams *clientmodel.ReportParams) { - o.ReportParams = reportParams -} - -// WriteToRequest writes these params to a swagger request -func (o *SubscribeReportParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if o.ReportParams != nil { - if err := r.SetBodyParam(o.ReportParams); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/clientapi/report/subscribe_report_responses.go b/pkg/clientapi/report/subscribe_report_responses.go deleted file mode 100644 index bace786..0000000 --- a/pkg/clientapi/report/subscribe_report_responses.go +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package report - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - - strfmt "github.com/go-openapi/strfmt" - - clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" -) - -// SubscribeReportReader is a Reader for the SubscribeReport structure. -type SubscribeReportReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *SubscribeReportReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - - case 201: - result := NewSubscribeReportCreated() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - - case 400: - result := NewSubscribeReportBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - - case 500: - result := NewSubscribeReportInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - - default: - return nil, runtime.NewAPIError("unknown error", response, response.Code()) - } -} - -// NewSubscribeReportCreated creates a SubscribeReportCreated with default headers values -func NewSubscribeReportCreated() *SubscribeReportCreated { - return &SubscribeReportCreated{} -} - -/*SubscribeReportCreated handles this case with default header values. - -Subscription successfully created -*/ -type SubscribeReportCreated struct { - Payload *clientmodel.SubscriptionResponse -} - -func (o *SubscribeReportCreated) Error() string { - return fmt.Sprintf("[POST /subscriptions/report][%d] subscribeReportCreated %+v", 201, o.Payload) -} - -func (o *SubscribeReportCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(clientmodel.SubscriptionResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewSubscribeReportBadRequest creates a SubscribeReportBadRequest with default headers values -func NewSubscribeReportBadRequest() *SubscribeReportBadRequest { - return &SubscribeReportBadRequest{} -} - -/*SubscribeReportBadRequest handles this case with default header values. - -Invalid input -*/ -type SubscribeReportBadRequest struct { -} - -func (o *SubscribeReportBadRequest) Error() string { - return fmt.Sprintf("[POST /subscriptions/report][%d] subscribeReportBadRequest ", 400) -} - -func (o *SubscribeReportBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - return nil -} - -// NewSubscribeReportInternalServerError creates a SubscribeReportInternalServerError with default headers values -func NewSubscribeReportInternalServerError() *SubscribeReportInternalServerError { - return &SubscribeReportInternalServerError{} -} - -/*SubscribeReportInternalServerError handles this case with default header values. - -Internal error -*/ -type SubscribeReportInternalServerError struct { -} - -func (o *SubscribeReportInternalServerError) Error() string { - return fmt.Sprintf("[POST /subscriptions/report][%d] subscribeReportInternalServerError ", 500) -} - -func (o *SubscribeReportInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - return nil -} diff --git a/pkg/clientapi/xapp/get_xapp_config_list_parameters.go b/pkg/clientapi/xapp/get_xapp_config_list_parameters.go new file mode 100644 index 0000000..b577424 --- /dev/null +++ b/pkg/clientapi/xapp/get_xapp_config_list_parameters.go @@ -0,0 +1,113 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package xapp + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetXappConfigListParams creates a new GetXappConfigListParams object +// with the default values initialized. +func NewGetXappConfigListParams() *GetXappConfigListParams { + + return &GetXappConfigListParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetXappConfigListParamsWithTimeout creates a new GetXappConfigListParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetXappConfigListParamsWithTimeout(timeout time.Duration) *GetXappConfigListParams { + + return &GetXappConfigListParams{ + + timeout: timeout, + } +} + +// NewGetXappConfigListParamsWithContext creates a new GetXappConfigListParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetXappConfigListParamsWithContext(ctx context.Context) *GetXappConfigListParams { + + return &GetXappConfigListParams{ + + Context: ctx, + } +} + +// NewGetXappConfigListParamsWithHTTPClient creates a new GetXappConfigListParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetXappConfigListParamsWithHTTPClient(client *http.Client) *GetXappConfigListParams { + + return &GetXappConfigListParams{ + HTTPClient: client, + } +} + +/*GetXappConfigListParams contains all the parameters to send to the API endpoint +for the get xapp config list operation typically these are written to a http.Request +*/ +type GetXappConfigListParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get xapp config list params +func (o *GetXappConfigListParams) WithTimeout(timeout time.Duration) *GetXappConfigListParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get xapp config list params +func (o *GetXappConfigListParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get xapp config list params +func (o *GetXappConfigListParams) WithContext(ctx context.Context) *GetXappConfigListParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get xapp config list params +func (o *GetXappConfigListParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get xapp config list params +func (o *GetXappConfigListParams) WithHTTPClient(client *http.Client) *GetXappConfigListParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get xapp config list params +func (o *GetXappConfigListParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetXappConfigListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/clientapi/xapp/get_xapp_config_list_responses.go b/pkg/clientapi/xapp/get_xapp_config_list_responses.go new file mode 100644 index 0000000..3ddd2fb --- /dev/null +++ b/pkg/clientapi/xapp/get_xapp_config_list_responses.go @@ -0,0 +1,93 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package xapp + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" + + clientmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" +) + +// GetXappConfigListReader is a Reader for the GetXappConfigList structure. +type GetXappConfigListReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetXappConfigListReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetXappConfigListOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 500: + result := NewGetXappConfigListInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewGetXappConfigListOK creates a GetXappConfigListOK with default headers values +func NewGetXappConfigListOK() *GetXappConfigListOK { + return &GetXappConfigListOK{} +} + +/*GetXappConfigListOK handles this case with default header values. + +successful query of xApp config +*/ +type GetXappConfigListOK struct { + Payload clientmodel.XappConfigList +} + +func (o *GetXappConfigListOK) Error() string { + return fmt.Sprintf("[GET /config][%d] getXappConfigListOK %+v", 200, o.Payload) +} + +func (o *GetXappConfigListOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetXappConfigListInternalServerError creates a GetXappConfigListInternalServerError with default headers values +func NewGetXappConfigListInternalServerError() *GetXappConfigListInternalServerError { + return &GetXappConfigListInternalServerError{} +} + +/*GetXappConfigListInternalServerError handles this case with default header values. + +Internal error +*/ +type GetXappConfigListInternalServerError struct { +} + +func (o *GetXappConfigListInternalServerError) Error() string { + return fmt.Sprintf("[GET /config][%d] getXappConfigListInternalServerError ", 500) +} + +func (o *GetXappConfigListInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/pkg/clientapi/query/query_client.go b/pkg/clientapi/xapp/xapp_client.go similarity index 66% rename from pkg/clientapi/query/query_client.go rename to pkg/clientapi/xapp/xapp_client.go index a73fd7e..a914611 100644 --- a/pkg/clientapi/query/query_client.go +++ b/pkg/clientapi/xapp/xapp_client.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package query +package xapp // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command @@ -11,13 +11,13 @@ import ( strfmt "github.com/go-openapi/strfmt" ) -// New creates a new query API client. +// New creates a new xapp API client. func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { return &Client{transport: transport, formats: formats} } /* -Client for query API +Client for xapp API */ type Client struct { transport runtime.ClientTransport @@ -25,30 +25,30 @@ type Client struct { } /* -GetAllSubscriptions returns list of subscriptions +GetXappConfigList returns the configuration of all xapps */ -func (a *Client) GetAllSubscriptions(params *GetAllSubscriptionsParams) (*GetAllSubscriptionsOK, error) { +func (a *Client) GetXappConfigList(params *GetXappConfigListParams) (*GetXappConfigListOK, error) { // TODO: Validate the params before sending if params == nil { - params = NewGetAllSubscriptionsParams() + params = NewGetXappConfigListParams() } result, err := a.transport.Submit(&runtime.ClientOperation{ - ID: "getAllSubscriptions", + ID: "getXappConfigList", Method: "GET", - PathPattern: "/subscriptions", - ProducesMediaTypes: []string{"application/json"}, + PathPattern: "/config", + ProducesMediaTypes: []string{"application/json", "application/xml"}, ConsumesMediaTypes: []string{""}, Schemes: []string{"http"}, Params: params, - Reader: &GetAllSubscriptionsReader{formats: a.formats}, + Reader: &GetXappConfigListReader{formats: a.formats}, Context: params.Context, Client: params.HTTPClient, }) if err != nil { return nil, err } - return result.(*GetAllSubscriptionsOK), nil + return result.(*GetXappConfigListOK), nil } diff --git a/pkg/clientmodel/action_definition.go b/pkg/clientmodel/action_definition.go new file mode 100644 index 0000000..54ca9d2 --- /dev/null +++ b/pkg/clientmodel/action_definition.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ActionDefinition E2SM Octet string. ActionDefinition is an OPTIONAL IE +// swagger:model ActionDefinition +type ActionDefinition struct { + + // octet string + OctetString string `json:"OctetString,omitempty"` +} + +// Validate validates this action definition +func (m *ActionDefinition) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ActionDefinition) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ActionDefinition) UnmarshalBinary(b []byte) error { + var res ActionDefinition + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/clientmodel/action_parameters.go b/pkg/clientmodel/action_parameters.go deleted file mode 100644 index c73f60b..0000000 --- a/pkg/clientmodel/action_parameters.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ActionParameters action parameters -// swagger:model ActionParameters -type ActionParameters struct { - - // action parameter ID - // Required: true - ActionParameterID *int64 `json:"ActionParameterID"` - - // action parameter value - // Required: true - ActionParameterValue *bool `json:"ActionParameterValue"` -} - -// Validate validates this action parameters -func (m *ActionParameters) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateActionParameterID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateActionParameterValue(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ActionParameters) validateActionParameterID(formats strfmt.Registry) error { - - if err := validate.Required("ActionParameterID", "body", m.ActionParameterID); err != nil { - return err - } - - return nil -} - -func (m *ActionParameters) validateActionParameterValue(formats strfmt.Registry) error { - - if err := validate.Required("ActionParameterValue", "body", m.ActionParameterValue); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ActionParameters) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ActionParameters) UnmarshalBinary(b []byte) error { - var res ActionParameters - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/action_to_be_setup.go b/pkg/clientmodel/action_to_be_setup.go new file mode 100644 index 0000000..88a0b4b --- /dev/null +++ b/pkg/clientmodel/action_to_be_setup.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ActionToBeSetup action to be setup +// swagger:model ActionToBeSetup +type ActionToBeSetup struct { + + // action definition + ActionDefinition *ActionDefinition `json:"ActionDefinition,omitempty"` + + // action ID + // Required: true + // Maximum: 255 + // Minimum: 0 + ActionID *int64 `json:"ActionID"` + + // action type + // Required: true + // Enum: [insert policy report] + ActionType *string `json:"ActionType"` + + // subsequent action + SubsequentAction *SubsequentAction `json:"SubsequentAction,omitempty"` +} + +// Validate validates this action to be setup +func (m *ActionToBeSetup) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateActionDefinition(formats); err != nil { + res = append(res, err) + } + + if err := m.validateActionID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateActionType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSubsequentAction(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ActionToBeSetup) validateActionDefinition(formats strfmt.Registry) error { + + if swag.IsZero(m.ActionDefinition) { // not required + return nil + } + + if m.ActionDefinition != nil { + if err := m.ActionDefinition.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ActionDefinition") + } + return err + } + } + + return nil +} + +func (m *ActionToBeSetup) validateActionID(formats strfmt.Registry) error { + + if err := validate.Required("ActionID", "body", m.ActionID); err != nil { + return err + } + + if err := validate.MinimumInt("ActionID", "body", int64(*m.ActionID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("ActionID", "body", int64(*m.ActionID), 255, false); err != nil { + return err + } + + return nil +} + +var actionToBeSetupTypeActionTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["insert","policy","report"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + actionToBeSetupTypeActionTypePropEnum = append(actionToBeSetupTypeActionTypePropEnum, v) + } +} + +const ( + + // ActionToBeSetupActionTypeInsert captures enum value "insert" + ActionToBeSetupActionTypeInsert string = "insert" + + // ActionToBeSetupActionTypePolicy captures enum value "policy" + ActionToBeSetupActionTypePolicy string = "policy" + + // ActionToBeSetupActionTypeReport captures enum value "report" + ActionToBeSetupActionTypeReport string = "report" +) + +// prop value enum +func (m *ActionToBeSetup) validateActionTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, actionToBeSetupTypeActionTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *ActionToBeSetup) validateActionType(formats strfmt.Registry) error { + + if err := validate.Required("ActionType", "body", m.ActionType); err != nil { + return err + } + + // value enum + if err := m.validateActionTypeEnum("ActionType", "body", *m.ActionType); err != nil { + return err + } + + return nil +} + +func (m *ActionToBeSetup) validateSubsequentAction(formats strfmt.Registry) error { + + if swag.IsZero(m.SubsequentAction) { // not required + return nil + } + + if m.SubsequentAction != nil { + if err := m.SubsequentAction.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("SubsequentAction") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ActionToBeSetup) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ActionToBeSetup) UnmarshalBinary(b []byte) error { + var res ActionToBeSetup + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/clientmodel/event_trigger_list.go b/pkg/clientmodel/actions_to_be_setup.go similarity index 76% rename from pkg/clientmodel/event_trigger_list.go rename to pkg/clientmodel/actions_to_be_setup.go index f205322..397022e 100644 --- a/pkg/clientmodel/event_trigger_list.go +++ b/pkg/clientmodel/actions_to_be_setup.go @@ -14,12 +14,12 @@ import ( "github.com/go-openapi/swag" ) -// EventTriggerList event trigger list -// swagger:model EventTriggerList -type EventTriggerList []*EventTrigger +// ActionsToBeSetup actions to be setup +// swagger:model ActionsToBeSetup +type ActionsToBeSetup []*ActionToBeSetup -// Validate validates this event trigger list -func (m EventTriggerList) Validate(formats strfmt.Registry) error { +// Validate validates this actions to be setup +func (m ActionsToBeSetup) Validate(formats strfmt.Registry) error { var res []error for i := 0; i < len(m); i++ { diff --git a/pkg/clientmodel/config_metadata.go b/pkg/clientmodel/config_metadata.go new file mode 100644 index 0000000..c75f0d1 --- /dev/null +++ b/pkg/clientmodel/config_metadata.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ConfigMetadata config metadata +// swagger:model ConfigMetadata +type ConfigMetadata struct { + + // The type of the content + // Required: true + // Enum: [json xml other] + ConfigType *string `json:"configType"` + + // Name of the xApp + // Required: true + XappName *string `json:"xappName"` +} + +// Validate validates this config metadata +func (m *ConfigMetadata) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateConfigType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateXappName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var configMetadataTypeConfigTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["json","xml","other"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + configMetadataTypeConfigTypePropEnum = append(configMetadataTypeConfigTypePropEnum, v) + } +} + +const ( + + // ConfigMetadataConfigTypeJSON captures enum value "json" + ConfigMetadataConfigTypeJSON string = "json" + + // ConfigMetadataConfigTypeXML captures enum value "xml" + ConfigMetadataConfigTypeXML string = "xml" + + // ConfigMetadataConfigTypeOther captures enum value "other" + ConfigMetadataConfigTypeOther string = "other" +) + +// prop value enum +func (m *ConfigMetadata) validateConfigTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, configMetadataTypeConfigTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *ConfigMetadata) validateConfigType(formats strfmt.Registry) error { + + if err := validate.Required("configType", "body", m.ConfigType); err != nil { + return err + } + + // value enum + if err := m.validateConfigTypeEnum("configType", "body", *m.ConfigType); err != nil { + return err + } + + return nil +} + +func (m *ConfigMetadata) validateXappName(formats strfmt.Registry) error { + + if err := validate.Required("xappName", "body", m.XappName); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ConfigMetadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ConfigMetadata) UnmarshalBinary(b []byte) error { + var res ConfigMetadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/clientmodel/event_trigger.go b/pkg/clientmodel/event_trigger.go deleted file mode 100644 index 02955ce..0000000 --- a/pkg/clientmodel/event_trigger.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// EventTrigger event trigger -// swagger:model EventTrigger -type EventTrigger struct { - - // e n b Id - ENBID string `json:"ENBId,omitempty"` - - // interface direction - InterfaceDirection int64 `json:"InterfaceDirection,omitempty"` - - // plmn Id - PlmnID string `json:"PlmnId,omitempty"` - - // procedure code - ProcedureCode int64 `json:"ProcedureCode,omitempty"` - - // trigger nature - // Enum: [now on change] - TriggerNature string `json:"TriggerNature,omitempty"` - - // type of message - TypeOfMessage int64 `json:"TypeOfMessage,omitempty"` -} - -// Validate validates this event trigger -func (m *EventTrigger) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateTriggerNature(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -var eventTriggerTypeTriggerNaturePropEnum []interface{} - -func init() { - var res []string - if err := json.Unmarshal([]byte(`["now","on change"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - eventTriggerTypeTriggerNaturePropEnum = append(eventTriggerTypeTriggerNaturePropEnum, v) - } -} - -const ( - - // EventTriggerTriggerNatureNow captures enum value "now" - EventTriggerTriggerNatureNow string = "now" - - // EventTriggerTriggerNatureOnChange captures enum value "on change" - EventTriggerTriggerNatureOnChange string = "on change" -) - -// prop value enum -func (m *EventTrigger) validateTriggerNatureEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, eventTriggerTypeTriggerNaturePropEnum); err != nil { - return err - } - return nil -} - -func (m *EventTrigger) validateTriggerNature(formats strfmt.Registry) error { - - if swag.IsZero(m.TriggerNature) { // not required - return nil - } - - // value enum - if err := m.validateTriggerNatureEnum("TriggerNature", "body", m.TriggerNature); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *EventTrigger) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *EventTrigger) UnmarshalBinary(b []byte) error { - var res EventTrigger - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/event_trigger_definition.go b/pkg/clientmodel/event_trigger_definition.go new file mode 100644 index 0000000..b9c82a6 --- /dev/null +++ b/pkg/clientmodel/event_trigger_definition.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// EventTriggerDefinition E2SM Octet string +// swagger:model EventTriggerDefinition +type EventTriggerDefinition struct { + + // octet string + OctetString string `json:"OctetString,omitempty"` +} + +// Validate validates this event trigger definition +func (m *EventTriggerDefinition) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *EventTriggerDefinition) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EventTriggerDefinition) UnmarshalBinary(b []byte) error { + var res EventTriggerDefinition + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/clientmodel/format1_action_definition.go b/pkg/clientmodel/format1_action_definition.go deleted file mode 100644 index f28039e..0000000 --- a/pkg/clientmodel/format1_action_definition.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "strconv" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// Format1ActionDefinition format1 action definition -// swagger:model Format1ActionDefinition -type Format1ActionDefinition struct { - - // action parameters - // Required: true - ActionParameters []*ActionParameters `json:"ActionParameters"` - - // style ID - // Required: true - StyleID *int64 `json:"StyleID"` -} - -// Validate validates this format1 action definition -func (m *Format1ActionDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateActionParameters(formats); err != nil { - res = append(res, err) - } - - if err := m.validateStyleID(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *Format1ActionDefinition) validateActionParameters(formats strfmt.Registry) error { - - if err := validate.Required("ActionParameters", "body", m.ActionParameters); err != nil { - return err - } - - for i := 0; i < len(m.ActionParameters); i++ { - if swag.IsZero(m.ActionParameters[i]) { // not required - continue - } - - if m.ActionParameters[i] != nil { - if err := m.ActionParameters[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("ActionParameters" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -func (m *Format1ActionDefinition) validateStyleID(formats strfmt.Registry) error { - - if err := validate.Required("StyleID", "body", m.StyleID); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *Format1ActionDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *Format1ActionDefinition) UnmarshalBinary(b []byte) error { - var res Format1ActionDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/format2_action_definition.go b/pkg/clientmodel/format2_action_definition.go deleted file mode 100644 index 075d07f..0000000 --- a/pkg/clientmodel/format2_action_definition.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "strconv" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// Format2ActionDefinition format2 action definition -// swagger:model Format2ActionDefinition -type Format2ActionDefinition struct { - - // r a n ue group parameters - // Required: true - RANUeGroupParameters []*RANUeGroupList `json:"RANUeGroupParameters"` -} - -// Validate validates this format2 action definition -func (m *Format2ActionDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateRANUeGroupParameters(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *Format2ActionDefinition) validateRANUeGroupParameters(formats strfmt.Registry) error { - - if err := validate.Required("RANUeGroupParameters", "body", m.RANUeGroupParameters); err != nil { - return err - } - - for i := 0; i < len(m.RANUeGroupParameters); i++ { - if swag.IsZero(m.RANUeGroupParameters[i]) { // not required - continue - } - - if m.RANUeGroupParameters[i] != nil { - if err := m.RANUeGroupParameters[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("RANUeGroupParameters" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *Format2ActionDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *Format2ActionDefinition) UnmarshalBinary(b []byte) error { - var res Format2ActionDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/imperative_policy_definition.go b/pkg/clientmodel/imperative_policy_definition.go deleted file mode 100644 index 3163bf9..0000000 --- a/pkg/clientmodel/imperative_policy_definition.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ImperativePolicyDefinition imperative policy definition -// swagger:model ImperativePolicyDefinition -type ImperativePolicyDefinition struct { - - // policy parameter ID - // Required: true - PolicyParameterID *int64 `json:"PolicyParameterID"` - - // policy parameter value - // Required: true - PolicyParameterValue *int64 `json:"PolicyParameterValue"` -} - -// Validate validates this imperative policy definition -func (m *ImperativePolicyDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validatePolicyParameterID(formats); err != nil { - res = append(res, err) - } - - if err := m.validatePolicyParameterValue(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ImperativePolicyDefinition) validatePolicyParameterID(formats strfmt.Registry) error { - - if err := validate.Required("PolicyParameterID", "body", m.PolicyParameterID); err != nil { - return err - } - - return nil -} - -func (m *ImperativePolicyDefinition) validatePolicyParameterValue(formats strfmt.Registry) error { - - if err := validate.Required("PolicyParameterValue", "body", m.PolicyParameterValue); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ImperativePolicyDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ImperativePolicyDefinition) UnmarshalBinary(b []byte) error { - var res ImperativePolicyDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/policy_action_definition.go b/pkg/clientmodel/policy_action_definition.go deleted file mode 100644 index 4190913..0000000 --- a/pkg/clientmodel/policy_action_definition.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" -) - -// PolicyActionDefinition policy action definition -// swagger:model PolicyActionDefinition -type PolicyActionDefinition struct { - - // action definition format2 - ActionDefinitionFormat2 *Format2ActionDefinition `json:"ActionDefinitionFormat2,omitempty"` -} - -// Validate validates this policy action definition -func (m *PolicyActionDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateActionDefinitionFormat2(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *PolicyActionDefinition) validateActionDefinitionFormat2(formats strfmt.Registry) error { - - if swag.IsZero(m.ActionDefinitionFormat2) { // not required - return nil - } - - if m.ActionDefinitionFormat2 != nil { - if err := m.ActionDefinitionFormat2.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("ActionDefinitionFormat2") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *PolicyActionDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *PolicyActionDefinition) UnmarshalBinary(b []byte) error { - var res PolicyActionDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/policy_params.go b/pkg/clientmodel/policy_params.go deleted file mode 100644 index 210fba7..0000000 --- a/pkg/clientmodel/policy_params.go +++ /dev/null @@ -1,148 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// PolicyParams policy params -// swagger:model PolicyParams -type PolicyParams struct { - - // client endpoint - // Required: true - ClientEndpoint *string `json:"ClientEndpoint"` - - // event triggers - // Required: true - EventTriggers EventTriggerList `json:"EventTriggers"` - - // meid - // Required: true - Meid *string `json:"Meid"` - - // policy action definitions - // Required: true - PolicyActionDefinitions *PolicyActionDefinition `json:"PolicyActionDefinitions"` - - // r a n function ID - // Required: true - RANFunctionID *int64 `json:"RANFunctionID"` -} - -// Validate validates this policy params -func (m *PolicyParams) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateClientEndpoint(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEventTriggers(formats); err != nil { - res = append(res, err) - } - - if err := m.validateMeid(formats); err != nil { - res = append(res, err) - } - - if err := m.validatePolicyActionDefinitions(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANFunctionID(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *PolicyParams) validateClientEndpoint(formats strfmt.Registry) error { - - if err := validate.Required("ClientEndpoint", "body", m.ClientEndpoint); err != nil { - return err - } - - return nil -} - -func (m *PolicyParams) validateEventTriggers(formats strfmt.Registry) error { - - if err := validate.Required("EventTriggers", "body", m.EventTriggers); err != nil { - return err - } - - if err := m.EventTriggers.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("EventTriggers") - } - return err - } - - return nil -} - -func (m *PolicyParams) validateMeid(formats strfmt.Registry) error { - - if err := validate.Required("Meid", "body", m.Meid); err != nil { - return err - } - - return nil -} - -func (m *PolicyParams) validatePolicyActionDefinitions(formats strfmt.Registry) error { - - if err := validate.Required("PolicyActionDefinitions", "body", m.PolicyActionDefinitions); err != nil { - return err - } - - if m.PolicyActionDefinitions != nil { - if err := m.PolicyActionDefinitions.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("PolicyActionDefinitions") - } - return err - } - } - - return nil -} - -func (m *PolicyParams) validateRANFunctionID(formats strfmt.Registry) error { - - if err := validate.Required("RANFunctionID", "body", m.RANFunctionID); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *PolicyParams) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *PolicyParams) UnmarshalBinary(b []byte) error { - var res PolicyParams - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/r_a_n_ue_group_list.go b/pkg/clientmodel/r_a_n_ue_group_list.go deleted file mode 100644 index d9d612f..0000000 --- a/pkg/clientmodel/r_a_n_ue_group_list.go +++ /dev/null @@ -1,116 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// RANUeGroupList r a n ue group list -// swagger:model RANUeGroupList -type RANUeGroupList struct { - - // r a n imperative policy - // Required: true - RANImperativePolicy *ImperativePolicyDefinition `json:"RANImperativePolicy"` - - // r a n ue group definition - // Required: true - RANUeGroupDefinition *RANUeGroupParams `json:"RANUeGroupDefinition"` - - // r a n ue group ID - // Required: true - RANUeGroupID *int64 `json:"RANUeGroupID"` -} - -// Validate validates this r a n ue group list -func (m *RANUeGroupList) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateRANImperativePolicy(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANUeGroupDefinition(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANUeGroupID(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *RANUeGroupList) validateRANImperativePolicy(formats strfmt.Registry) error { - - if err := validate.Required("RANImperativePolicy", "body", m.RANImperativePolicy); err != nil { - return err - } - - if m.RANImperativePolicy != nil { - if err := m.RANImperativePolicy.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("RANImperativePolicy") - } - return err - } - } - - return nil -} - -func (m *RANUeGroupList) validateRANUeGroupDefinition(formats strfmt.Registry) error { - - if err := validate.Required("RANUeGroupDefinition", "body", m.RANUeGroupDefinition); err != nil { - return err - } - - if m.RANUeGroupDefinition != nil { - if err := m.RANUeGroupDefinition.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("RANUeGroupDefinition") - } - return err - } - } - - return nil -} - -func (m *RANUeGroupList) validateRANUeGroupID(formats strfmt.Registry) error { - - if err := validate.Required("RANUeGroupID", "body", m.RANUeGroupID); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *RANUeGroupList) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *RANUeGroupList) UnmarshalBinary(b []byte) error { - var res RANUeGroupList - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/r_a_n_ue_group_params.go b/pkg/clientmodel/r_a_n_ue_group_params.go deleted file mode 100644 index ba24f98..0000000 --- a/pkg/clientmodel/r_a_n_ue_group_params.go +++ /dev/null @@ -1,143 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// RANUeGroupParams r a n ue group params -// swagger:model RANUeGroupParams -type RANUeGroupParams struct { - - // r a n parameter ID - // Required: true - RANParameterID *int64 `json:"RANParameterID"` - - // r a n parameter test condition - // Enum: [equal greaterthan lessthan contains present] - RANParameterTestCondition string `json:"RANParameterTestCondition,omitempty"` - - // r a n parameter value - // Required: true - RANParameterValue *int64 `json:"RANParameterValue"` -} - -// Validate validates this r a n ue group params -func (m *RANUeGroupParams) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateRANParameterID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANParameterTestCondition(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANParameterValue(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *RANUeGroupParams) validateRANParameterID(formats strfmt.Registry) error { - - if err := validate.Required("RANParameterID", "body", m.RANParameterID); err != nil { - return err - } - - return nil -} - -var rANUeGroupParamsTypeRANParameterTestConditionPropEnum []interface{} - -func init() { - var res []string - if err := json.Unmarshal([]byte(`["equal","greaterthan","lessthan","contains","present"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - rANUeGroupParamsTypeRANParameterTestConditionPropEnum = append(rANUeGroupParamsTypeRANParameterTestConditionPropEnum, v) - } -} - -const ( - - // RANUeGroupParamsRANParameterTestConditionEqual captures enum value "equal" - RANUeGroupParamsRANParameterTestConditionEqual string = "equal" - - // RANUeGroupParamsRANParameterTestConditionGreaterthan captures enum value "greaterthan" - RANUeGroupParamsRANParameterTestConditionGreaterthan string = "greaterthan" - - // RANUeGroupParamsRANParameterTestConditionLessthan captures enum value "lessthan" - RANUeGroupParamsRANParameterTestConditionLessthan string = "lessthan" - - // RANUeGroupParamsRANParameterTestConditionContains captures enum value "contains" - RANUeGroupParamsRANParameterTestConditionContains string = "contains" - - // RANUeGroupParamsRANParameterTestConditionPresent captures enum value "present" - RANUeGroupParamsRANParameterTestConditionPresent string = "present" -) - -// prop value enum -func (m *RANUeGroupParams) validateRANParameterTestConditionEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, rANUeGroupParamsTypeRANParameterTestConditionPropEnum); err != nil { - return err - } - return nil -} - -func (m *RANUeGroupParams) validateRANParameterTestCondition(formats strfmt.Registry) error { - - if swag.IsZero(m.RANParameterTestCondition) { // not required - return nil - } - - // value enum - if err := m.validateRANParameterTestConditionEnum("RANParameterTestCondition", "body", m.RANParameterTestCondition); err != nil { - return err - } - - return nil -} - -func (m *RANUeGroupParams) validateRANParameterValue(formats strfmt.Registry) error { - - if err := validate.Required("RANParameterValue", "body", m.RANParameterValue); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *RANUeGroupParams) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *RANUeGroupParams) UnmarshalBinary(b []byte) error { - var res RANUeGroupParams - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/report_action_definition.go b/pkg/clientmodel/report_action_definition.go deleted file mode 100644 index 1657b44..0000000 --- a/pkg/clientmodel/report_action_definition.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" -) - -// ReportActionDefinition report action definition -// swagger:model ReportActionDefinition -type ReportActionDefinition struct { - - // action definition format1 - ActionDefinitionFormat1 *Format1ActionDefinition `json:"ActionDefinitionFormat1,omitempty"` -} - -// Validate validates this report action definition -func (m *ReportActionDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateActionDefinitionFormat1(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ReportActionDefinition) validateActionDefinitionFormat1(formats strfmt.Registry) error { - - if swag.IsZero(m.ActionDefinitionFormat1) { // not required - return nil - } - - if m.ActionDefinitionFormat1 != nil { - if err := m.ActionDefinitionFormat1.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("ActionDefinitionFormat1") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ReportActionDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ReportActionDefinition) UnmarshalBinary(b []byte) error { - var res ReportActionDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/report_params.go b/pkg/clientmodel/report_params.go deleted file mode 100644 index 151c2d0..0000000 --- a/pkg/clientmodel/report_params.go +++ /dev/null @@ -1,133 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ReportParams report params -// swagger:model ReportParams -type ReportParams struct { - - // client endpoint - // Required: true - ClientEndpoint *string `json:"ClientEndpoint"` - - // event triggers - // Required: true - EventTriggers EventTriggerList `json:"EventTriggers"` - - // meid - Meid string `json:"Meid,omitempty"` - - // r a n function ID - // Required: true - RANFunctionID *int64 `json:"RANFunctionID"` - - // report action definitions - ReportActionDefinitions *ReportActionDefinition `json:"ReportActionDefinitions,omitempty"` -} - -// Validate validates this report params -func (m *ReportParams) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateClientEndpoint(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEventTriggers(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANFunctionID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateReportActionDefinitions(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ReportParams) validateClientEndpoint(formats strfmt.Registry) error { - - if err := validate.Required("ClientEndpoint", "body", m.ClientEndpoint); err != nil { - return err - } - - return nil -} - -func (m *ReportParams) validateEventTriggers(formats strfmt.Registry) error { - - if err := validate.Required("EventTriggers", "body", m.EventTriggers); err != nil { - return err - } - - if err := m.EventTriggers.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("EventTriggers") - } - return err - } - - return nil -} - -func (m *ReportParams) validateRANFunctionID(formats strfmt.Registry) error { - - if err := validate.Required("RANFunctionID", "body", m.RANFunctionID); err != nil { - return err - } - - return nil -} - -func (m *ReportParams) validateReportActionDefinitions(formats strfmt.Registry) error { - - if swag.IsZero(m.ReportActionDefinitions) { // not required - return nil - } - - if m.ReportActionDefinitions != nil { - if err := m.ReportActionDefinitions.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("ReportActionDefinitions") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ReportParams) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ReportParams) UnmarshalBinary(b []byte) error { - var res ReportParams - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/subscription_details.go b/pkg/clientmodel/subscription_details.go new file mode 100644 index 0000000..05677cd --- /dev/null +++ b/pkg/clientmodel/subscription_details.go @@ -0,0 +1,97 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SubscriptionDetails subscription details +// swagger:model SubscriptionDetails +type SubscriptionDetails struct { + + // action to be setup list + // Required: true + ActionToBeSetupList ActionsToBeSetup `json:"ActionToBeSetupList"` + + // event trigger list + // Required: true + EventTriggerList *EventTriggerDefinition `json:"EventTriggerList"` +} + +// Validate validates this subscription details +func (m *SubscriptionDetails) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateActionToBeSetupList(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEventTriggerList(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SubscriptionDetails) validateActionToBeSetupList(formats strfmt.Registry) error { + + if err := validate.Required("ActionToBeSetupList", "body", m.ActionToBeSetupList); err != nil { + return err + } + + if err := m.ActionToBeSetupList.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ActionToBeSetupList") + } + return err + } + + return nil +} + +func (m *SubscriptionDetails) validateEventTriggerList(formats strfmt.Registry) error { + + if err := validate.Required("EventTriggerList", "body", m.EventTriggerList); err != nil { + return err + } + + if m.EventTriggerList != nil { + if err := m.EventTriggerList.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("EventTriggerList") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SubscriptionDetails) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SubscriptionDetails) UnmarshalBinary(b []byte) error { + var res SubscriptionDetails + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/clientmodel/subscription_details_list.go b/pkg/clientmodel/subscription_details_list.go new file mode 100644 index 0000000..450e08f --- /dev/null +++ b/pkg/clientmodel/subscription_details_list.go @@ -0,0 +1,45 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// SubscriptionDetailsList subscription details list +// swagger:model SubscriptionDetailsList +type SubscriptionDetailsList []*SubscriptionDetails + +// Validate validates this subscription details list +func (m SubscriptionDetailsList) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/clientmodel/subscription_instance.go b/pkg/clientmodel/subscription_instance.go index 4606479..7853a3b 100644 --- a/pkg/clientmodel/subscription_instance.go +++ b/pkg/clientmodel/subscription_instance.go @@ -17,12 +17,20 @@ import ( // swagger:model SubscriptionInstance type SubscriptionInstance struct { + // Empty string when no error. + // Required: true + ErrorCause *string `json:"ErrorCause"` + // instance Id // Required: true + // Maximum: 65535 + // Minimum: 0 InstanceID *int64 `json:"InstanceId"` // requestor Id // Required: true + // Maximum: 65535 + // Minimum: 0 RequestorID *int64 `json:"RequestorId"` } @@ -30,6 +38,10 @@ type SubscriptionInstance struct { func (m *SubscriptionInstance) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateErrorCause(formats); err != nil { + res = append(res, err) + } + if err := m.validateInstanceID(formats); err != nil { res = append(res, err) } @@ -44,12 +56,29 @@ func (m *SubscriptionInstance) Validate(formats strfmt.Registry) error { return nil } +func (m *SubscriptionInstance) validateErrorCause(formats strfmt.Registry) error { + + if err := validate.Required("ErrorCause", "body", m.ErrorCause); err != nil { + return err + } + + return nil +} + func (m *SubscriptionInstance) validateInstanceID(formats strfmt.Registry) error { if err := validate.Required("InstanceId", "body", m.InstanceID); err != nil { return err } + if err := validate.MinimumInt("InstanceId", "body", int64(*m.InstanceID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("InstanceId", "body", int64(*m.InstanceID), 65535, false); err != nil { + return err + } + return nil } @@ -59,6 +88,14 @@ func (m *SubscriptionInstance) validateRequestorID(formats strfmt.Registry) erro return err } + if err := validate.MinimumInt("RequestorId", "body", int64(*m.RequestorID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("RequestorId", "body", int64(*m.RequestorID), 65535, false); err != nil { + return err + } + return nil } diff --git a/pkg/clientmodel/subscription_params.go b/pkg/clientmodel/subscription_params.go new file mode 100644 index 0000000..eb1d875 --- /dev/null +++ b/pkg/clientmodel/subscription_params.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SubscriptionParams subscription params +// swagger:model SubscriptionParams +type SubscriptionParams struct { + + // client endpoint + // Required: true + ClientEndpoint *SubscriptionParamsClientEndpoint `json:"ClientEndpoint"` + + // instance Id + // Required: true + // Maximum: 65535 + // Minimum: 0 + InstanceID *int64 `json:"InstanceId"` + + // meid + // Required: true + Meid *string `json:"Meid"` + + // r a n function ID + // Required: true + // Maximum: 4095 + // Minimum: 0 + RANFunctionID *int64 `json:"RANFunctionID"` + + // requestor Id + // Required: true + // Maximum: 65535 + // Minimum: 0 + RequestorID *int64 `json:"RequestorId"` + + // subscription details + // Required: true + SubscriptionDetails SubscriptionDetailsList `json:"SubscriptionDetails"` +} + +// Validate validates this subscription params +func (m *SubscriptionParams) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClientEndpoint(formats); err != nil { + res = append(res, err) + } + + if err := m.validateInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeid(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRANFunctionID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRequestorID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSubscriptionDetails(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SubscriptionParams) validateClientEndpoint(formats strfmt.Registry) error { + + if err := validate.Required("ClientEndpoint", "body", m.ClientEndpoint); err != nil { + return err + } + + if m.ClientEndpoint != nil { + if err := m.ClientEndpoint.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ClientEndpoint") + } + return err + } + } + + return nil +} + +func (m *SubscriptionParams) validateInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("InstanceId", "body", m.InstanceID); err != nil { + return err + } + + if err := validate.MinimumInt("InstanceId", "body", int64(*m.InstanceID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("InstanceId", "body", int64(*m.InstanceID), 65535, false); err != nil { + return err + } + + return nil +} + +func (m *SubscriptionParams) validateMeid(formats strfmt.Registry) error { + + if err := validate.Required("Meid", "body", m.Meid); err != nil { + return err + } + + return nil +} + +func (m *SubscriptionParams) validateRANFunctionID(formats strfmt.Registry) error { + + if err := validate.Required("RANFunctionID", "body", m.RANFunctionID); err != nil { + return err + } + + if err := validate.MinimumInt("RANFunctionID", "body", int64(*m.RANFunctionID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("RANFunctionID", "body", int64(*m.RANFunctionID), 4095, false); err != nil { + return err + } + + return nil +} + +func (m *SubscriptionParams) validateRequestorID(formats strfmt.Registry) error { + + if err := validate.Required("RequestorId", "body", m.RequestorID); err != nil { + return err + } + + if err := validate.MinimumInt("RequestorId", "body", int64(*m.RequestorID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("RequestorId", "body", int64(*m.RequestorID), 65535, false); err != nil { + return err + } + + return nil +} + +func (m *SubscriptionParams) validateSubscriptionDetails(formats strfmt.Registry) error { + + if err := validate.Required("SubscriptionDetails", "body", m.SubscriptionDetails); err != nil { + return err + } + + if err := m.SubscriptionDetails.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("SubscriptionDetails") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SubscriptionParams) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SubscriptionParams) UnmarshalBinary(b []byte) error { + var res SubscriptionParams + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// SubscriptionParamsClientEndpoint xApp service address and port +// swagger:model SubscriptionParamsClientEndpoint +type SubscriptionParamsClientEndpoint struct { + + // xApp service address port + // Maximum: 65535 + // Minimum: 0 + Port *int64 `json:"Port,omitempty"` + + // xApp service address name like 'service-ricxapp-xappname-http.ricxapp' + ServiceName string `json:"ServiceName,omitempty"` +} + +// Validate validates this subscription params client endpoint +func (m *SubscriptionParamsClientEndpoint) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePort(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SubscriptionParamsClientEndpoint) validatePort(formats strfmt.Registry) error { + + if swag.IsZero(m.Port) { // not required + return nil + } + + if err := validate.MinimumInt("ClientEndpoint"+"."+"Port", "body", int64(*m.Port), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("ClientEndpoint"+"."+"Port", "body", int64(*m.Port), 65535, false); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SubscriptionParamsClientEndpoint) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SubscriptionParamsClientEndpoint) UnmarshalBinary(b []byte) error { + var res SubscriptionParamsClientEndpoint + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/clientmodel/subscription_response_item.go b/pkg/clientmodel/subscription_response_item.go deleted file mode 100644 index 8237495..0000000 --- a/pkg/clientmodel/subscription_response_item.go +++ /dev/null @@ -1,98 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// SubscriptionResponseItem subscription response item -// swagger:model SubscriptionResponseItem -type SubscriptionResponseItem struct { - - // instance Id - // Required: true - InstanceID *int64 `json:"InstanceId"` - - // requestor Id - // Required: true - RequestorID *int64 `json:"RequestorId"` - - // subscription Id - // Required: true - SubscriptionID *string `json:"SubscriptionId"` -} - -// Validate validates this subscription response item -func (m *SubscriptionResponseItem) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateInstanceID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRequestorID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateSubscriptionID(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SubscriptionResponseItem) validateInstanceID(formats strfmt.Registry) error { - - if err := validate.Required("InstanceId", "body", m.InstanceID); err != nil { - return err - } - - return nil -} - -func (m *SubscriptionResponseItem) validateRequestorID(formats strfmt.Registry) error { - - if err := validate.Required("RequestorId", "body", m.RequestorID); err != nil { - return err - } - - return nil -} - -func (m *SubscriptionResponseItem) validateSubscriptionID(formats strfmt.Registry) error { - - if err := validate.Required("SubscriptionId", "body", m.SubscriptionID); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *SubscriptionResponseItem) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SubscriptionResponseItem) UnmarshalBinary(b []byte) error { - var res SubscriptionResponseItem - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/clientmodel/subscription_type.go b/pkg/clientmodel/subscription_type.go deleted file mode 100644 index eafbe57..0000000 --- a/pkg/clientmodel/subscription_type.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package clientmodel - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/validate" -) - -// SubscriptionType subscription type -// swagger:model SubscriptionType -type SubscriptionType string - -const ( - - // SubscriptionTypeInsert captures enum value "insert" - SubscriptionTypeInsert SubscriptionType = "insert" - - // SubscriptionTypePolicy captures enum value "policy" - SubscriptionTypePolicy SubscriptionType = "policy" - - // SubscriptionTypeReport captures enum value "report" - SubscriptionTypeReport SubscriptionType = "report" -) - -// for schema -var subscriptionTypeEnum []interface{} - -func init() { - var res []SubscriptionType - if err := json.Unmarshal([]byte(`["insert","policy","report"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - subscriptionTypeEnum = append(subscriptionTypeEnum, v) - } -} - -func (m SubscriptionType) validateSubscriptionTypeEnum(path, location string, value SubscriptionType) error { - if err := validate.Enum(path, location, value, subscriptionTypeEnum); err != nil { - return err - } - return nil -} - -// Validate validates this subscription type -func (m SubscriptionType) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateSubscriptionTypeEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/clientmodel/subsequent_action.go b/pkg/clientmodel/subsequent_action.go new file mode 100644 index 0000000..b0c8a0f --- /dev/null +++ b/pkg/clientmodel/subsequent_action.go @@ -0,0 +1,201 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SubsequentAction SubsequentAction is an OPTIONAL IE +// swagger:model SubsequentAction +type SubsequentAction struct { + + // subsequent action type + // Required: true + // Enum: [continue wait] + SubsequentActionType *string `json:"SubsequentActionType"` + + // time to wait + // Required: true + // Enum: [zero w1ms w2ms w5ms w10ms w20ms w30ms w40ms w50ms w100ms w200ms w500ms w1s w2s w5s w10s w20s w60s] + TimeToWait *string `json:"TimeToWait"` +} + +// Validate validates this subsequent action +func (m *SubsequentAction) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSubsequentActionType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTimeToWait(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var subsequentActionTypeSubsequentActionTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["continue","wait"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + subsequentActionTypeSubsequentActionTypePropEnum = append(subsequentActionTypeSubsequentActionTypePropEnum, v) + } +} + +const ( + + // SubsequentActionSubsequentActionTypeContinue captures enum value "continue" + SubsequentActionSubsequentActionTypeContinue string = "continue" + + // SubsequentActionSubsequentActionTypeWait captures enum value "wait" + SubsequentActionSubsequentActionTypeWait string = "wait" +) + +// prop value enum +func (m *SubsequentAction) validateSubsequentActionTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, subsequentActionTypeSubsequentActionTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *SubsequentAction) validateSubsequentActionType(formats strfmt.Registry) error { + + if err := validate.Required("SubsequentActionType", "body", m.SubsequentActionType); err != nil { + return err + } + + // value enum + if err := m.validateSubsequentActionTypeEnum("SubsequentActionType", "body", *m.SubsequentActionType); err != nil { + return err + } + + return nil +} + +var subsequentActionTypeTimeToWaitPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["zero","w1ms","w2ms","w5ms","w10ms","w20ms","w30ms","w40ms","w50ms","w100ms","w200ms","w500ms","w1s","w2s","w5s","w10s","w20s","w60s"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + subsequentActionTypeTimeToWaitPropEnum = append(subsequentActionTypeTimeToWaitPropEnum, v) + } +} + +const ( + + // SubsequentActionTimeToWaitZero captures enum value "zero" + SubsequentActionTimeToWaitZero string = "zero" + + // SubsequentActionTimeToWaitW1ms captures enum value "w1ms" + SubsequentActionTimeToWaitW1ms string = "w1ms" + + // SubsequentActionTimeToWaitW2ms captures enum value "w2ms" + SubsequentActionTimeToWaitW2ms string = "w2ms" + + // SubsequentActionTimeToWaitW5ms captures enum value "w5ms" + SubsequentActionTimeToWaitW5ms string = "w5ms" + + // SubsequentActionTimeToWaitW10ms captures enum value "w10ms" + SubsequentActionTimeToWaitW10ms string = "w10ms" + + // SubsequentActionTimeToWaitW20ms captures enum value "w20ms" + SubsequentActionTimeToWaitW20ms string = "w20ms" + + // SubsequentActionTimeToWaitW30ms captures enum value "w30ms" + SubsequentActionTimeToWaitW30ms string = "w30ms" + + // SubsequentActionTimeToWaitW40ms captures enum value "w40ms" + SubsequentActionTimeToWaitW40ms string = "w40ms" + + // SubsequentActionTimeToWaitW50ms captures enum value "w50ms" + SubsequentActionTimeToWaitW50ms string = "w50ms" + + // SubsequentActionTimeToWaitW100ms captures enum value "w100ms" + SubsequentActionTimeToWaitW100ms string = "w100ms" + + // SubsequentActionTimeToWaitW200ms captures enum value "w200ms" + SubsequentActionTimeToWaitW200ms string = "w200ms" + + // SubsequentActionTimeToWaitW500ms captures enum value "w500ms" + SubsequentActionTimeToWaitW500ms string = "w500ms" + + // SubsequentActionTimeToWaitW1s captures enum value "w1s" + SubsequentActionTimeToWaitW1s string = "w1s" + + // SubsequentActionTimeToWaitW2s captures enum value "w2s" + SubsequentActionTimeToWaitW2s string = "w2s" + + // SubsequentActionTimeToWaitW5s captures enum value "w5s" + SubsequentActionTimeToWaitW5s string = "w5s" + + // SubsequentActionTimeToWaitW10s captures enum value "w10s" + SubsequentActionTimeToWaitW10s string = "w10s" + + // SubsequentActionTimeToWaitW20s captures enum value "w20s" + SubsequentActionTimeToWaitW20s string = "w20s" + + // SubsequentActionTimeToWaitW60s captures enum value "w60s" + SubsequentActionTimeToWaitW60s string = "w60s" +) + +// prop value enum +func (m *SubsequentAction) validateTimeToWaitEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, subsequentActionTypeTimeToWaitPropEnum); err != nil { + return err + } + return nil +} + +func (m *SubsequentAction) validateTimeToWait(formats strfmt.Registry) error { + + if err := validate.Required("TimeToWait", "body", m.TimeToWait); err != nil { + return err + } + + // value enum + if err := m.validateTimeToWaitEnum("TimeToWait", "body", *m.TimeToWait); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SubsequentAction) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SubsequentAction) UnmarshalBinary(b []byte) error { + var res SubsequentAction + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/clientmodel/x_app_config.go b/pkg/clientmodel/x_app_config.go new file mode 100644 index 0000000..b744f3f --- /dev/null +++ b/pkg/clientmodel/x_app_config.go @@ -0,0 +1,90 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// XAppConfig x app config +// swagger:model XAppConfig +type XAppConfig struct { + + // Configuration in JSON format + // Required: true + Config interface{} `json:"config"` + + // metadata + // Required: true + Metadata *ConfigMetadata `json:"metadata"` +} + +// Validate validates this x app config +func (m *XAppConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateConfig(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMetadata(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *XAppConfig) validateConfig(formats strfmt.Registry) error { + + if err := validate.Required("config", "body", m.Config); err != nil { + return err + } + + return nil +} + +func (m *XAppConfig) validateMetadata(formats strfmt.Registry) error { + + if err := validate.Required("metadata", "body", m.Metadata); err != nil { + return err + } + + if m.Metadata != nil { + if err := m.Metadata.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("metadata") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *XAppConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *XAppConfig) UnmarshalBinary(b []byte) error { + var res XAppConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/clientmodel/xapp_config_list.go b/pkg/clientmodel/xapp_config_list.go new file mode 100644 index 0000000..758b7ec --- /dev/null +++ b/pkg/clientmodel/xapp_config_list.go @@ -0,0 +1,45 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package clientmodel + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// XappConfigList xapp config list +// swagger:model XappConfigList +type XappConfigList []*XAppConfig + +// Validate validates this xapp config list +func (m XappConfigList) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/models/action_definition.go b/pkg/models/action_definition.go new file mode 100644 index 0000000..740196f --- /dev/null +++ b/pkg/models/action_definition.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ActionDefinition E2SM Octet string. ActionDefinition is an OPTIONAL IE +// swagger:model ActionDefinition +type ActionDefinition struct { + + // octet string + OctetString string `json:"OctetString,omitempty"` +} + +// Validate validates this action definition +func (m *ActionDefinition) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ActionDefinition) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ActionDefinition) UnmarshalBinary(b []byte) error { + var res ActionDefinition + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/action_parameters.go b/pkg/models/action_parameters.go deleted file mode 100644 index 0173bd3..0000000 --- a/pkg/models/action_parameters.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ActionParameters action parameters -// swagger:model ActionParameters -type ActionParameters struct { - - // action parameter ID - // Required: true - ActionParameterID *int64 `json:"ActionParameterID"` - - // action parameter value - // Required: true - ActionParameterValue *bool `json:"ActionParameterValue"` -} - -// Validate validates this action parameters -func (m *ActionParameters) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateActionParameterID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateActionParameterValue(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ActionParameters) validateActionParameterID(formats strfmt.Registry) error { - - if err := validate.Required("ActionParameterID", "body", m.ActionParameterID); err != nil { - return err - } - - return nil -} - -func (m *ActionParameters) validateActionParameterValue(formats strfmt.Registry) error { - - if err := validate.Required("ActionParameterValue", "body", m.ActionParameterValue); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ActionParameters) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ActionParameters) UnmarshalBinary(b []byte) error { - var res ActionParameters - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/action_to_be_setup.go b/pkg/models/action_to_be_setup.go new file mode 100644 index 0000000..be945b0 --- /dev/null +++ b/pkg/models/action_to_be_setup.go @@ -0,0 +1,181 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ActionToBeSetup action to be setup +// swagger:model ActionToBeSetup +type ActionToBeSetup struct { + + // action definition + ActionDefinition *ActionDefinition `json:"ActionDefinition,omitempty"` + + // action ID + // Required: true + // Maximum: 255 + // Minimum: 0 + ActionID *int64 `json:"ActionID"` + + // action type + // Required: true + // Enum: [insert policy report] + ActionType *string `json:"ActionType"` + + // subsequent action + SubsequentAction *SubsequentAction `json:"SubsequentAction,omitempty"` +} + +// Validate validates this action to be setup +func (m *ActionToBeSetup) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateActionDefinition(formats); err != nil { + res = append(res, err) + } + + if err := m.validateActionID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateActionType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSubsequentAction(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ActionToBeSetup) validateActionDefinition(formats strfmt.Registry) error { + + if swag.IsZero(m.ActionDefinition) { // not required + return nil + } + + if m.ActionDefinition != nil { + if err := m.ActionDefinition.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ActionDefinition") + } + return err + } + } + + return nil +} + +func (m *ActionToBeSetup) validateActionID(formats strfmt.Registry) error { + + if err := validate.Required("ActionID", "body", m.ActionID); err != nil { + return err + } + + if err := validate.MinimumInt("ActionID", "body", int64(*m.ActionID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("ActionID", "body", int64(*m.ActionID), 255, false); err != nil { + return err + } + + return nil +} + +var actionToBeSetupTypeActionTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["insert","policy","report"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + actionToBeSetupTypeActionTypePropEnum = append(actionToBeSetupTypeActionTypePropEnum, v) + } +} + +const ( + + // ActionToBeSetupActionTypeInsert captures enum value "insert" + ActionToBeSetupActionTypeInsert string = "insert" + + // ActionToBeSetupActionTypePolicy captures enum value "policy" + ActionToBeSetupActionTypePolicy string = "policy" + + // ActionToBeSetupActionTypeReport captures enum value "report" + ActionToBeSetupActionTypeReport string = "report" +) + +// prop value enum +func (m *ActionToBeSetup) validateActionTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, actionToBeSetupTypeActionTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *ActionToBeSetup) validateActionType(formats strfmt.Registry) error { + + if err := validate.Required("ActionType", "body", m.ActionType); err != nil { + return err + } + + // value enum + if err := m.validateActionTypeEnum("ActionType", "body", *m.ActionType); err != nil { + return err + } + + return nil +} + +func (m *ActionToBeSetup) validateSubsequentAction(formats strfmt.Registry) error { + + if swag.IsZero(m.SubsequentAction) { // not required + return nil + } + + if m.SubsequentAction != nil { + if err := m.SubsequentAction.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("SubsequentAction") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ActionToBeSetup) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ActionToBeSetup) UnmarshalBinary(b []byte) error { + var res ActionToBeSetup + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/event_trigger_list.go b/pkg/models/actions_to_be_setup.go similarity index 76% rename from pkg/models/event_trigger_list.go rename to pkg/models/actions_to_be_setup.go index c3c3dbc..d6ba1a7 100644 --- a/pkg/models/event_trigger_list.go +++ b/pkg/models/actions_to_be_setup.go @@ -14,12 +14,12 @@ import ( "github.com/go-openapi/swag" ) -// EventTriggerList event trigger list -// swagger:model EventTriggerList -type EventTriggerList []*EventTrigger +// ActionsToBeSetup actions to be setup +// swagger:model ActionsToBeSetup +type ActionsToBeSetup []*ActionToBeSetup -// Validate validates this event trigger list -func (m EventTriggerList) Validate(formats strfmt.Registry) error { +// Validate validates this actions to be setup +func (m ActionsToBeSetup) Validate(formats strfmt.Registry) error { var res []error for i := 0; i < len(m); i++ { diff --git a/pkg/models/event_trigger.go b/pkg/models/event_trigger.go deleted file mode 100644 index 43375c4..0000000 --- a/pkg/models/event_trigger.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// EventTrigger event trigger -// swagger:model EventTrigger -type EventTrigger struct { - - // e n b Id - ENBID string `json:"ENBId,omitempty"` - - // interface direction - InterfaceDirection int64 `json:"InterfaceDirection,omitempty"` - - // plmn Id - PlmnID string `json:"PlmnId,omitempty"` - - // procedure code - ProcedureCode int64 `json:"ProcedureCode,omitempty"` - - // trigger nature - // Enum: [now on change] - TriggerNature string `json:"TriggerNature,omitempty"` - - // type of message - TypeOfMessage int64 `json:"TypeOfMessage,omitempty"` -} - -// Validate validates this event trigger -func (m *EventTrigger) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateTriggerNature(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -var eventTriggerTypeTriggerNaturePropEnum []interface{} - -func init() { - var res []string - if err := json.Unmarshal([]byte(`["now","on change"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - eventTriggerTypeTriggerNaturePropEnum = append(eventTriggerTypeTriggerNaturePropEnum, v) - } -} - -const ( - - // EventTriggerTriggerNatureNow captures enum value "now" - EventTriggerTriggerNatureNow string = "now" - - // EventTriggerTriggerNatureOnChange captures enum value "on change" - EventTriggerTriggerNatureOnChange string = "on change" -) - -// prop value enum -func (m *EventTrigger) validateTriggerNatureEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, eventTriggerTypeTriggerNaturePropEnum); err != nil { - return err - } - return nil -} - -func (m *EventTrigger) validateTriggerNature(formats strfmt.Registry) error { - - if swag.IsZero(m.TriggerNature) { // not required - return nil - } - - // value enum - if err := m.validateTriggerNatureEnum("TriggerNature", "body", m.TriggerNature); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *EventTrigger) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *EventTrigger) UnmarshalBinary(b []byte) error { - var res EventTrigger - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/event_trigger_definition.go b/pkg/models/event_trigger_definition.go new file mode 100644 index 0000000..944614f --- /dev/null +++ b/pkg/models/event_trigger_definition.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// EventTriggerDefinition E2SM Octet string +// swagger:model EventTriggerDefinition +type EventTriggerDefinition struct { + + // octet string + OctetString string `json:"OctetString,omitempty"` +} + +// Validate validates this event trigger definition +func (m *EventTriggerDefinition) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *EventTriggerDefinition) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EventTriggerDefinition) UnmarshalBinary(b []byte) error { + var res EventTriggerDefinition + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/format1_action_definition.go b/pkg/models/format1_action_definition.go deleted file mode 100644 index 9d568a1..0000000 --- a/pkg/models/format1_action_definition.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "strconv" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// Format1ActionDefinition format1 action definition -// swagger:model Format1ActionDefinition -type Format1ActionDefinition struct { - - // action parameters - // Required: true - ActionParameters []*ActionParameters `json:"ActionParameters"` - - // style ID - // Required: true - StyleID *int64 `json:"StyleID"` -} - -// Validate validates this format1 action definition -func (m *Format1ActionDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateActionParameters(formats); err != nil { - res = append(res, err) - } - - if err := m.validateStyleID(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *Format1ActionDefinition) validateActionParameters(formats strfmt.Registry) error { - - if err := validate.Required("ActionParameters", "body", m.ActionParameters); err != nil { - return err - } - - for i := 0; i < len(m.ActionParameters); i++ { - if swag.IsZero(m.ActionParameters[i]) { // not required - continue - } - - if m.ActionParameters[i] != nil { - if err := m.ActionParameters[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("ActionParameters" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -func (m *Format1ActionDefinition) validateStyleID(formats strfmt.Registry) error { - - if err := validate.Required("StyleID", "body", m.StyleID); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *Format1ActionDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *Format1ActionDefinition) UnmarshalBinary(b []byte) error { - var res Format1ActionDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/format2_action_definition.go b/pkg/models/format2_action_definition.go deleted file mode 100644 index 351c7ae..0000000 --- a/pkg/models/format2_action_definition.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "strconv" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// Format2ActionDefinition format2 action definition -// swagger:model Format2ActionDefinition -type Format2ActionDefinition struct { - - // r a n ue group parameters - // Required: true - RANUeGroupParameters []*RANUeGroupList `json:"RANUeGroupParameters"` -} - -// Validate validates this format2 action definition -func (m *Format2ActionDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateRANUeGroupParameters(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *Format2ActionDefinition) validateRANUeGroupParameters(formats strfmt.Registry) error { - - if err := validate.Required("RANUeGroupParameters", "body", m.RANUeGroupParameters); err != nil { - return err - } - - for i := 0; i < len(m.RANUeGroupParameters); i++ { - if swag.IsZero(m.RANUeGroupParameters[i]) { // not required - continue - } - - if m.RANUeGroupParameters[i] != nil { - if err := m.RANUeGroupParameters[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("RANUeGroupParameters" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *Format2ActionDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *Format2ActionDefinition) UnmarshalBinary(b []byte) error { - var res Format2ActionDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/imperative_policy_definition.go b/pkg/models/imperative_policy_definition.go deleted file mode 100644 index 0b2a541..0000000 --- a/pkg/models/imperative_policy_definition.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ImperativePolicyDefinition imperative policy definition -// swagger:model ImperativePolicyDefinition -type ImperativePolicyDefinition struct { - - // policy parameter ID - // Required: true - PolicyParameterID *int64 `json:"PolicyParameterID"` - - // policy parameter value - // Required: true - PolicyParameterValue *int64 `json:"PolicyParameterValue"` -} - -// Validate validates this imperative policy definition -func (m *ImperativePolicyDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validatePolicyParameterID(formats); err != nil { - res = append(res, err) - } - - if err := m.validatePolicyParameterValue(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ImperativePolicyDefinition) validatePolicyParameterID(formats strfmt.Registry) error { - - if err := validate.Required("PolicyParameterID", "body", m.PolicyParameterID); err != nil { - return err - } - - return nil -} - -func (m *ImperativePolicyDefinition) validatePolicyParameterValue(formats strfmt.Registry) error { - - if err := validate.Required("PolicyParameterValue", "body", m.PolicyParameterValue); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ImperativePolicyDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ImperativePolicyDefinition) UnmarshalBinary(b []byte) error { - var res ImperativePolicyDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/policy_action_definition.go b/pkg/models/policy_action_definition.go deleted file mode 100644 index 841c868..0000000 --- a/pkg/models/policy_action_definition.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" -) - -// PolicyActionDefinition policy action definition -// swagger:model PolicyActionDefinition -type PolicyActionDefinition struct { - - // action definition format2 - ActionDefinitionFormat2 *Format2ActionDefinition `json:"ActionDefinitionFormat2,omitempty"` -} - -// Validate validates this policy action definition -func (m *PolicyActionDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateActionDefinitionFormat2(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *PolicyActionDefinition) validateActionDefinitionFormat2(formats strfmt.Registry) error { - - if swag.IsZero(m.ActionDefinitionFormat2) { // not required - return nil - } - - if m.ActionDefinitionFormat2 != nil { - if err := m.ActionDefinitionFormat2.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("ActionDefinitionFormat2") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *PolicyActionDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *PolicyActionDefinition) UnmarshalBinary(b []byte) error { - var res PolicyActionDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/policy_params.go b/pkg/models/policy_params.go deleted file mode 100644 index ab7b09d..0000000 --- a/pkg/models/policy_params.go +++ /dev/null @@ -1,148 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// PolicyParams policy params -// swagger:model PolicyParams -type PolicyParams struct { - - // client endpoint - // Required: true - ClientEndpoint *string `json:"ClientEndpoint"` - - // event triggers - // Required: true - EventTriggers EventTriggerList `json:"EventTriggers"` - - // meid - // Required: true - Meid *string `json:"Meid"` - - // policy action definitions - // Required: true - PolicyActionDefinitions *PolicyActionDefinition `json:"PolicyActionDefinitions"` - - // r a n function ID - // Required: true - RANFunctionID *int64 `json:"RANFunctionID"` -} - -// Validate validates this policy params -func (m *PolicyParams) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateClientEndpoint(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEventTriggers(formats); err != nil { - res = append(res, err) - } - - if err := m.validateMeid(formats); err != nil { - res = append(res, err) - } - - if err := m.validatePolicyActionDefinitions(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANFunctionID(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *PolicyParams) validateClientEndpoint(formats strfmt.Registry) error { - - if err := validate.Required("ClientEndpoint", "body", m.ClientEndpoint); err != nil { - return err - } - - return nil -} - -func (m *PolicyParams) validateEventTriggers(formats strfmt.Registry) error { - - if err := validate.Required("EventTriggers", "body", m.EventTriggers); err != nil { - return err - } - - if err := m.EventTriggers.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("EventTriggers") - } - return err - } - - return nil -} - -func (m *PolicyParams) validateMeid(formats strfmt.Registry) error { - - if err := validate.Required("Meid", "body", m.Meid); err != nil { - return err - } - - return nil -} - -func (m *PolicyParams) validatePolicyActionDefinitions(formats strfmt.Registry) error { - - if err := validate.Required("PolicyActionDefinitions", "body", m.PolicyActionDefinitions); err != nil { - return err - } - - if m.PolicyActionDefinitions != nil { - if err := m.PolicyActionDefinitions.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("PolicyActionDefinitions") - } - return err - } - } - - return nil -} - -func (m *PolicyParams) validateRANFunctionID(formats strfmt.Registry) error { - - if err := validate.Required("RANFunctionID", "body", m.RANFunctionID); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *PolicyParams) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *PolicyParams) UnmarshalBinary(b []byte) error { - var res PolicyParams - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/r_a_n_ue_group_list.go b/pkg/models/r_a_n_ue_group_list.go deleted file mode 100644 index b0bbc14..0000000 --- a/pkg/models/r_a_n_ue_group_list.go +++ /dev/null @@ -1,116 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// RANUeGroupList r a n ue group list -// swagger:model RANUeGroupList -type RANUeGroupList struct { - - // r a n imperative policy - // Required: true - RANImperativePolicy *ImperativePolicyDefinition `json:"RANImperativePolicy"` - - // r a n ue group definition - // Required: true - RANUeGroupDefinition *RANUeGroupParams `json:"RANUeGroupDefinition"` - - // r a n ue group ID - // Required: true - RANUeGroupID *int64 `json:"RANUeGroupID"` -} - -// Validate validates this r a n ue group list -func (m *RANUeGroupList) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateRANImperativePolicy(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANUeGroupDefinition(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANUeGroupID(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *RANUeGroupList) validateRANImperativePolicy(formats strfmt.Registry) error { - - if err := validate.Required("RANImperativePolicy", "body", m.RANImperativePolicy); err != nil { - return err - } - - if m.RANImperativePolicy != nil { - if err := m.RANImperativePolicy.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("RANImperativePolicy") - } - return err - } - } - - return nil -} - -func (m *RANUeGroupList) validateRANUeGroupDefinition(formats strfmt.Registry) error { - - if err := validate.Required("RANUeGroupDefinition", "body", m.RANUeGroupDefinition); err != nil { - return err - } - - if m.RANUeGroupDefinition != nil { - if err := m.RANUeGroupDefinition.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("RANUeGroupDefinition") - } - return err - } - } - - return nil -} - -func (m *RANUeGroupList) validateRANUeGroupID(formats strfmt.Registry) error { - - if err := validate.Required("RANUeGroupID", "body", m.RANUeGroupID); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *RANUeGroupList) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *RANUeGroupList) UnmarshalBinary(b []byte) error { - var res RANUeGroupList - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/r_a_n_ue_group_params.go b/pkg/models/r_a_n_ue_group_params.go deleted file mode 100644 index 411d6a3..0000000 --- a/pkg/models/r_a_n_ue_group_params.go +++ /dev/null @@ -1,143 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// RANUeGroupParams r a n ue group params -// swagger:model RANUeGroupParams -type RANUeGroupParams struct { - - // r a n parameter ID - // Required: true - RANParameterID *int64 `json:"RANParameterID"` - - // r a n parameter test condition - // Enum: [equal greaterthan lessthan contains present] - RANParameterTestCondition string `json:"RANParameterTestCondition,omitempty"` - - // r a n parameter value - // Required: true - RANParameterValue *int64 `json:"RANParameterValue"` -} - -// Validate validates this r a n ue group params -func (m *RANUeGroupParams) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateRANParameterID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANParameterTestCondition(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANParameterValue(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *RANUeGroupParams) validateRANParameterID(formats strfmt.Registry) error { - - if err := validate.Required("RANParameterID", "body", m.RANParameterID); err != nil { - return err - } - - return nil -} - -var rANUeGroupParamsTypeRANParameterTestConditionPropEnum []interface{} - -func init() { - var res []string - if err := json.Unmarshal([]byte(`["equal","greaterthan","lessthan","contains","present"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - rANUeGroupParamsTypeRANParameterTestConditionPropEnum = append(rANUeGroupParamsTypeRANParameterTestConditionPropEnum, v) - } -} - -const ( - - // RANUeGroupParamsRANParameterTestConditionEqual captures enum value "equal" - RANUeGroupParamsRANParameterTestConditionEqual string = "equal" - - // RANUeGroupParamsRANParameterTestConditionGreaterthan captures enum value "greaterthan" - RANUeGroupParamsRANParameterTestConditionGreaterthan string = "greaterthan" - - // RANUeGroupParamsRANParameterTestConditionLessthan captures enum value "lessthan" - RANUeGroupParamsRANParameterTestConditionLessthan string = "lessthan" - - // RANUeGroupParamsRANParameterTestConditionContains captures enum value "contains" - RANUeGroupParamsRANParameterTestConditionContains string = "contains" - - // RANUeGroupParamsRANParameterTestConditionPresent captures enum value "present" - RANUeGroupParamsRANParameterTestConditionPresent string = "present" -) - -// prop value enum -func (m *RANUeGroupParams) validateRANParameterTestConditionEnum(path, location string, value string) error { - if err := validate.Enum(path, location, value, rANUeGroupParamsTypeRANParameterTestConditionPropEnum); err != nil { - return err - } - return nil -} - -func (m *RANUeGroupParams) validateRANParameterTestCondition(formats strfmt.Registry) error { - - if swag.IsZero(m.RANParameterTestCondition) { // not required - return nil - } - - // value enum - if err := m.validateRANParameterTestConditionEnum("RANParameterTestCondition", "body", m.RANParameterTestCondition); err != nil { - return err - } - - return nil -} - -func (m *RANUeGroupParams) validateRANParameterValue(formats strfmt.Registry) error { - - if err := validate.Required("RANParameterValue", "body", m.RANParameterValue); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *RANUeGroupParams) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *RANUeGroupParams) UnmarshalBinary(b []byte) error { - var res RANUeGroupParams - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/report_action_definition.go b/pkg/models/report_action_definition.go deleted file mode 100644 index d578394..0000000 --- a/pkg/models/report_action_definition.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" -) - -// ReportActionDefinition report action definition -// swagger:model ReportActionDefinition -type ReportActionDefinition struct { - - // action definition format1 - ActionDefinitionFormat1 *Format1ActionDefinition `json:"ActionDefinitionFormat1,omitempty"` -} - -// Validate validates this report action definition -func (m *ReportActionDefinition) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateActionDefinitionFormat1(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ReportActionDefinition) validateActionDefinitionFormat1(formats strfmt.Registry) error { - - if swag.IsZero(m.ActionDefinitionFormat1) { // not required - return nil - } - - if m.ActionDefinitionFormat1 != nil { - if err := m.ActionDefinitionFormat1.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("ActionDefinitionFormat1") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ReportActionDefinition) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ReportActionDefinition) UnmarshalBinary(b []byte) error { - var res ReportActionDefinition - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/report_params.go b/pkg/models/report_params.go deleted file mode 100644 index b1d46b8..0000000 --- a/pkg/models/report_params.go +++ /dev/null @@ -1,133 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ReportParams report params -// swagger:model ReportParams -type ReportParams struct { - - // client endpoint - // Required: true - ClientEndpoint *string `json:"ClientEndpoint"` - - // event triggers - // Required: true - EventTriggers EventTriggerList `json:"EventTriggers"` - - // meid - Meid string `json:"Meid,omitempty"` - - // r a n function ID - // Required: true - RANFunctionID *int64 `json:"RANFunctionID"` - - // report action definitions - ReportActionDefinitions *ReportActionDefinition `json:"ReportActionDefinitions,omitempty"` -} - -// Validate validates this report params -func (m *ReportParams) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateClientEndpoint(formats); err != nil { - res = append(res, err) - } - - if err := m.validateEventTriggers(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRANFunctionID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateReportActionDefinitions(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ReportParams) validateClientEndpoint(formats strfmt.Registry) error { - - if err := validate.Required("ClientEndpoint", "body", m.ClientEndpoint); err != nil { - return err - } - - return nil -} - -func (m *ReportParams) validateEventTriggers(formats strfmt.Registry) error { - - if err := validate.Required("EventTriggers", "body", m.EventTriggers); err != nil { - return err - } - - if err := m.EventTriggers.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("EventTriggers") - } - return err - } - - return nil -} - -func (m *ReportParams) validateRANFunctionID(formats strfmt.Registry) error { - - if err := validate.Required("RANFunctionID", "body", m.RANFunctionID); err != nil { - return err - } - - return nil -} - -func (m *ReportParams) validateReportActionDefinitions(formats strfmt.Registry) error { - - if swag.IsZero(m.ReportActionDefinitions) { // not required - return nil - } - - if m.ReportActionDefinitions != nil { - if err := m.ReportActionDefinitions.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("ReportActionDefinitions") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ReportParams) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ReportParams) UnmarshalBinary(b []byte) error { - var res ReportParams - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/subscription_details.go b/pkg/models/subscription_details.go new file mode 100644 index 0000000..69f6121 --- /dev/null +++ b/pkg/models/subscription_details.go @@ -0,0 +1,97 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SubscriptionDetails subscription details +// swagger:model SubscriptionDetails +type SubscriptionDetails struct { + + // action to be setup list + // Required: true + ActionToBeSetupList ActionsToBeSetup `json:"ActionToBeSetupList"` + + // event trigger list + // Required: true + EventTriggerList *EventTriggerDefinition `json:"EventTriggerList"` +} + +// Validate validates this subscription details +func (m *SubscriptionDetails) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateActionToBeSetupList(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEventTriggerList(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SubscriptionDetails) validateActionToBeSetupList(formats strfmt.Registry) error { + + if err := validate.Required("ActionToBeSetupList", "body", m.ActionToBeSetupList); err != nil { + return err + } + + if err := m.ActionToBeSetupList.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ActionToBeSetupList") + } + return err + } + + return nil +} + +func (m *SubscriptionDetails) validateEventTriggerList(formats strfmt.Registry) error { + + if err := validate.Required("EventTriggerList", "body", m.EventTriggerList); err != nil { + return err + } + + if m.EventTriggerList != nil { + if err := m.EventTriggerList.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("EventTriggerList") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SubscriptionDetails) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SubscriptionDetails) UnmarshalBinary(b []byte) error { + var res SubscriptionDetails + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/subscription_details_list.go b/pkg/models/subscription_details_list.go new file mode 100644 index 0000000..4387022 --- /dev/null +++ b/pkg/models/subscription_details_list.go @@ -0,0 +1,45 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// SubscriptionDetailsList subscription details list +// swagger:model SubscriptionDetailsList +type SubscriptionDetailsList []*SubscriptionDetails + +// Validate validates this subscription details list +func (m SubscriptionDetailsList) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + if swag.IsZero(m[i]) { // not required + continue + } + + if m[i] != nil { + if err := m[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName(strconv.Itoa(i)) + } + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/models/subscription_instance.go b/pkg/models/subscription_instance.go index d619166..19c0afe 100644 --- a/pkg/models/subscription_instance.go +++ b/pkg/models/subscription_instance.go @@ -17,12 +17,20 @@ import ( // swagger:model SubscriptionInstance type SubscriptionInstance struct { + // Empty string when no error. + // Required: true + ErrorCause *string `json:"ErrorCause"` + // instance Id // Required: true + // Maximum: 65535 + // Minimum: 0 InstanceID *int64 `json:"InstanceId"` // requestor Id // Required: true + // Maximum: 65535 + // Minimum: 0 RequestorID *int64 `json:"RequestorId"` } @@ -30,6 +38,10 @@ type SubscriptionInstance struct { func (m *SubscriptionInstance) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateErrorCause(formats); err != nil { + res = append(res, err) + } + if err := m.validateInstanceID(formats); err != nil { res = append(res, err) } @@ -44,12 +56,29 @@ func (m *SubscriptionInstance) Validate(formats strfmt.Registry) error { return nil } +func (m *SubscriptionInstance) validateErrorCause(formats strfmt.Registry) error { + + if err := validate.Required("ErrorCause", "body", m.ErrorCause); err != nil { + return err + } + + return nil +} + func (m *SubscriptionInstance) validateInstanceID(formats strfmt.Registry) error { if err := validate.Required("InstanceId", "body", m.InstanceID); err != nil { return err } + if err := validate.MinimumInt("InstanceId", "body", int64(*m.InstanceID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("InstanceId", "body", int64(*m.InstanceID), 65535, false); err != nil { + return err + } + return nil } @@ -59,6 +88,14 @@ func (m *SubscriptionInstance) validateRequestorID(formats strfmt.Registry) erro return err } + if err := validate.MinimumInt("RequestorId", "body", int64(*m.RequestorID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("RequestorId", "body", int64(*m.RequestorID), 65535, false); err != nil { + return err + } + return nil } diff --git a/pkg/models/subscription_params.go b/pkg/models/subscription_params.go new file mode 100644 index 0000000..eb2d171 --- /dev/null +++ b/pkg/models/subscription_params.go @@ -0,0 +1,257 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SubscriptionParams subscription params +// swagger:model SubscriptionParams +type SubscriptionParams struct { + + // client endpoint + // Required: true + ClientEndpoint *SubscriptionParamsClientEndpoint `json:"ClientEndpoint"` + + // instance Id + // Required: true + // Maximum: 65535 + // Minimum: 0 + InstanceID *int64 `json:"InstanceId"` + + // meid + // Required: true + Meid *string `json:"Meid"` + + // r a n function ID + // Required: true + // Maximum: 4095 + // Minimum: 0 + RANFunctionID *int64 `json:"RANFunctionID"` + + // requestor Id + // Required: true + // Maximum: 65535 + // Minimum: 0 + RequestorID *int64 `json:"RequestorId"` + + // subscription details + // Required: true + SubscriptionDetails SubscriptionDetailsList `json:"SubscriptionDetails"` +} + +// Validate validates this subscription params +func (m *SubscriptionParams) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateClientEndpoint(formats); err != nil { + res = append(res, err) + } + + if err := m.validateInstanceID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMeid(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRANFunctionID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRequestorID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSubscriptionDetails(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SubscriptionParams) validateClientEndpoint(formats strfmt.Registry) error { + + if err := validate.Required("ClientEndpoint", "body", m.ClientEndpoint); err != nil { + return err + } + + if m.ClientEndpoint != nil { + if err := m.ClientEndpoint.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ClientEndpoint") + } + return err + } + } + + return nil +} + +func (m *SubscriptionParams) validateInstanceID(formats strfmt.Registry) error { + + if err := validate.Required("InstanceId", "body", m.InstanceID); err != nil { + return err + } + + if err := validate.MinimumInt("InstanceId", "body", int64(*m.InstanceID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("InstanceId", "body", int64(*m.InstanceID), 65535, false); err != nil { + return err + } + + return nil +} + +func (m *SubscriptionParams) validateMeid(formats strfmt.Registry) error { + + if err := validate.Required("Meid", "body", m.Meid); err != nil { + return err + } + + return nil +} + +func (m *SubscriptionParams) validateRANFunctionID(formats strfmt.Registry) error { + + if err := validate.Required("RANFunctionID", "body", m.RANFunctionID); err != nil { + return err + } + + if err := validate.MinimumInt("RANFunctionID", "body", int64(*m.RANFunctionID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("RANFunctionID", "body", int64(*m.RANFunctionID), 4095, false); err != nil { + return err + } + + return nil +} + +func (m *SubscriptionParams) validateRequestorID(formats strfmt.Registry) error { + + if err := validate.Required("RequestorId", "body", m.RequestorID); err != nil { + return err + } + + if err := validate.MinimumInt("RequestorId", "body", int64(*m.RequestorID), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("RequestorId", "body", int64(*m.RequestorID), 65535, false); err != nil { + return err + } + + return nil +} + +func (m *SubscriptionParams) validateSubscriptionDetails(formats strfmt.Registry) error { + + if err := validate.Required("SubscriptionDetails", "body", m.SubscriptionDetails); err != nil { + return err + } + + if err := m.SubscriptionDetails.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("SubscriptionDetails") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SubscriptionParams) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SubscriptionParams) UnmarshalBinary(b []byte) error { + var res SubscriptionParams + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// SubscriptionParamsClientEndpoint xApp service address and port +// swagger:model SubscriptionParamsClientEndpoint +type SubscriptionParamsClientEndpoint struct { + + // xApp service address port + // Maximum: 65535 + // Minimum: 0 + Port *int64 `json:"Port,omitempty"` + + // xApp service address name like 'service-ricxapp-xappname-http.ricxapp' + ServiceName string `json:"ServiceName,omitempty"` +} + +// Validate validates this subscription params client endpoint +func (m *SubscriptionParamsClientEndpoint) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePort(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SubscriptionParamsClientEndpoint) validatePort(formats strfmt.Registry) error { + + if swag.IsZero(m.Port) { // not required + return nil + } + + if err := validate.MinimumInt("ClientEndpoint"+"."+"Port", "body", int64(*m.Port), 0, false); err != nil { + return err + } + + if err := validate.MaximumInt("ClientEndpoint"+"."+"Port", "body", int64(*m.Port), 65535, false); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SubscriptionParamsClientEndpoint) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SubscriptionParamsClientEndpoint) UnmarshalBinary(b []byte) error { + var res SubscriptionParamsClientEndpoint + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/subscription_response_item.go b/pkg/models/subscription_response_item.go deleted file mode 100644 index 2bed019..0000000 --- a/pkg/models/subscription_response_item.go +++ /dev/null @@ -1,98 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// SubscriptionResponseItem subscription response item -// swagger:model SubscriptionResponseItem -type SubscriptionResponseItem struct { - - // instance Id - // Required: true - InstanceID *int64 `json:"InstanceId"` - - // requestor Id - // Required: true - RequestorID *int64 `json:"RequestorId"` - - // subscription Id - // Required: true - SubscriptionID *string `json:"SubscriptionId"` -} - -// Validate validates this subscription response item -func (m *SubscriptionResponseItem) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateInstanceID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateRequestorID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateSubscriptionID(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SubscriptionResponseItem) validateInstanceID(formats strfmt.Registry) error { - - if err := validate.Required("InstanceId", "body", m.InstanceID); err != nil { - return err - } - - return nil -} - -func (m *SubscriptionResponseItem) validateRequestorID(formats strfmt.Registry) error { - - if err := validate.Required("RequestorId", "body", m.RequestorID); err != nil { - return err - } - - return nil -} - -func (m *SubscriptionResponseItem) validateSubscriptionID(formats strfmt.Registry) error { - - if err := validate.Required("SubscriptionId", "body", m.SubscriptionID); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *SubscriptionResponseItem) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SubscriptionResponseItem) UnmarshalBinary(b []byte) error { - var res SubscriptionResponseItem - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/subscription_type.go b/pkg/models/subscription_type.go deleted file mode 100644 index c7dd86e..0000000 --- a/pkg/models/subscription_type.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "encoding/json" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/validate" -) - -// SubscriptionType subscription type -// swagger:model SubscriptionType -type SubscriptionType string - -const ( - - // SubscriptionTypeInsert captures enum value "insert" - SubscriptionTypeInsert SubscriptionType = "insert" - - // SubscriptionTypePolicy captures enum value "policy" - SubscriptionTypePolicy SubscriptionType = "policy" - - // SubscriptionTypeReport captures enum value "report" - SubscriptionTypeReport SubscriptionType = "report" -) - -// for schema -var subscriptionTypeEnum []interface{} - -func init() { - var res []SubscriptionType - if err := json.Unmarshal([]byte(`["insert","policy","report"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - subscriptionTypeEnum = append(subscriptionTypeEnum, v) - } -} - -func (m SubscriptionType) validateSubscriptionTypeEnum(path, location string, value SubscriptionType) error { - if err := validate.Enum(path, location, value, subscriptionTypeEnum); err != nil { - return err - } - return nil -} - -// Validate validates this subscription type -func (m SubscriptionType) Validate(formats strfmt.Registry) error { - var res []error - - // value enum - if err := m.validateSubscriptionTypeEnum("", "body", m); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/models/subsequent_action.go b/pkg/models/subsequent_action.go new file mode 100644 index 0000000..c8468c5 --- /dev/null +++ b/pkg/models/subsequent_action.go @@ -0,0 +1,201 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SubsequentAction SubsequentAction is an OPTIONAL IE +// swagger:model SubsequentAction +type SubsequentAction struct { + + // subsequent action type + // Required: true + // Enum: [continue wait] + SubsequentActionType *string `json:"SubsequentActionType"` + + // time to wait + // Required: true + // Enum: [zero w1ms w2ms w5ms w10ms w20ms w30ms w40ms w50ms w100ms w200ms w500ms w1s w2s w5s w10s w20s w60s] + TimeToWait *string `json:"TimeToWait"` +} + +// Validate validates this subsequent action +func (m *SubsequentAction) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSubsequentActionType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTimeToWait(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var subsequentActionTypeSubsequentActionTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["continue","wait"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + subsequentActionTypeSubsequentActionTypePropEnum = append(subsequentActionTypeSubsequentActionTypePropEnum, v) + } +} + +const ( + + // SubsequentActionSubsequentActionTypeContinue captures enum value "continue" + SubsequentActionSubsequentActionTypeContinue string = "continue" + + // SubsequentActionSubsequentActionTypeWait captures enum value "wait" + SubsequentActionSubsequentActionTypeWait string = "wait" +) + +// prop value enum +func (m *SubsequentAction) validateSubsequentActionTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, subsequentActionTypeSubsequentActionTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *SubsequentAction) validateSubsequentActionType(formats strfmt.Registry) error { + + if err := validate.Required("SubsequentActionType", "body", m.SubsequentActionType); err != nil { + return err + } + + // value enum + if err := m.validateSubsequentActionTypeEnum("SubsequentActionType", "body", *m.SubsequentActionType); err != nil { + return err + } + + return nil +} + +var subsequentActionTypeTimeToWaitPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["zero","w1ms","w2ms","w5ms","w10ms","w20ms","w30ms","w40ms","w50ms","w100ms","w200ms","w500ms","w1s","w2s","w5s","w10s","w20s","w60s"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + subsequentActionTypeTimeToWaitPropEnum = append(subsequentActionTypeTimeToWaitPropEnum, v) + } +} + +const ( + + // SubsequentActionTimeToWaitZero captures enum value "zero" + SubsequentActionTimeToWaitZero string = "zero" + + // SubsequentActionTimeToWaitW1ms captures enum value "w1ms" + SubsequentActionTimeToWaitW1ms string = "w1ms" + + // SubsequentActionTimeToWaitW2ms captures enum value "w2ms" + SubsequentActionTimeToWaitW2ms string = "w2ms" + + // SubsequentActionTimeToWaitW5ms captures enum value "w5ms" + SubsequentActionTimeToWaitW5ms string = "w5ms" + + // SubsequentActionTimeToWaitW10ms captures enum value "w10ms" + SubsequentActionTimeToWaitW10ms string = "w10ms" + + // SubsequentActionTimeToWaitW20ms captures enum value "w20ms" + SubsequentActionTimeToWaitW20ms string = "w20ms" + + // SubsequentActionTimeToWaitW30ms captures enum value "w30ms" + SubsequentActionTimeToWaitW30ms string = "w30ms" + + // SubsequentActionTimeToWaitW40ms captures enum value "w40ms" + SubsequentActionTimeToWaitW40ms string = "w40ms" + + // SubsequentActionTimeToWaitW50ms captures enum value "w50ms" + SubsequentActionTimeToWaitW50ms string = "w50ms" + + // SubsequentActionTimeToWaitW100ms captures enum value "w100ms" + SubsequentActionTimeToWaitW100ms string = "w100ms" + + // SubsequentActionTimeToWaitW200ms captures enum value "w200ms" + SubsequentActionTimeToWaitW200ms string = "w200ms" + + // SubsequentActionTimeToWaitW500ms captures enum value "w500ms" + SubsequentActionTimeToWaitW500ms string = "w500ms" + + // SubsequentActionTimeToWaitW1s captures enum value "w1s" + SubsequentActionTimeToWaitW1s string = "w1s" + + // SubsequentActionTimeToWaitW2s captures enum value "w2s" + SubsequentActionTimeToWaitW2s string = "w2s" + + // SubsequentActionTimeToWaitW5s captures enum value "w5s" + SubsequentActionTimeToWaitW5s string = "w5s" + + // SubsequentActionTimeToWaitW10s captures enum value "w10s" + SubsequentActionTimeToWaitW10s string = "w10s" + + // SubsequentActionTimeToWaitW20s captures enum value "w20s" + SubsequentActionTimeToWaitW20s string = "w20s" + + // SubsequentActionTimeToWaitW60s captures enum value "w60s" + SubsequentActionTimeToWaitW60s string = "w60s" +) + +// prop value enum +func (m *SubsequentAction) validateTimeToWaitEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, subsequentActionTypeTimeToWaitPropEnum); err != nil { + return err + } + return nil +} + +func (m *SubsequentAction) validateTimeToWait(formats strfmt.Registry) error { + + if err := validate.Required("TimeToWait", "body", m.TimeToWait); err != nil { + return err + } + + // value enum + if err := m.validateTimeToWaitEnum("TimeToWait", "body", *m.TimeToWait); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SubsequentAction) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SubsequentAction) UnmarshalBinary(b []byte) error { + var res SubsequentAction + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/restapi/configure_xapp_framework.go b/pkg/restapi/configure_xapp_framework.go index 89e112d..e185b0c 100644 --- a/pkg/restapi/configure_xapp_framework.go +++ b/pkg/restapi/configure_xapp_framework.go @@ -12,9 +12,7 @@ import ( "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/common" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/policy" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/query" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/report" + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/xapp" ) //go:generate swagger generate server --target ../../pkg --name XappFramework --spec ../../api/xapp_rest_api.yaml --exclude-main @@ -37,24 +35,26 @@ func configureAPI(api *operations.XappFrameworkAPI) http.Handler { api.JSONProducer = runtime.JSONProducer() + api.XMLProducer = runtime.XMLProducer() + + if api.CommonSubscribeHandler == nil { + api.CommonSubscribeHandler = common.SubscribeHandlerFunc(func(params common.SubscribeParams) middleware.Responder { + return middleware.NotImplemented("operation common.Subscribe has not yet been implemented") + }) + } if api.CommonUnsubscribeHandler == nil { api.CommonUnsubscribeHandler = common.UnsubscribeHandlerFunc(func(params common.UnsubscribeParams) middleware.Responder { return middleware.NotImplemented("operation common.Unsubscribe has not yet been implemented") }) } - if api.QueryGetAllSubscriptionsHandler == nil { - api.QueryGetAllSubscriptionsHandler = query.GetAllSubscriptionsHandlerFunc(func(params query.GetAllSubscriptionsParams) middleware.Responder { - return middleware.NotImplemented("operation query.GetAllSubscriptions has not yet been implemented") - }) - } - if api.PolicySubscribePolicyHandler == nil { - api.PolicySubscribePolicyHandler = policy.SubscribePolicyHandlerFunc(func(params policy.SubscribePolicyParams) middleware.Responder { - return middleware.NotImplemented("operation policy.SubscribePolicy has not yet been implemented") + if api.CommonGetAllSubscriptionsHandler == nil { + api.CommonGetAllSubscriptionsHandler = common.GetAllSubscriptionsHandlerFunc(func(params common.GetAllSubscriptionsParams) middleware.Responder { + return middleware.NotImplemented("operation common.GetAllSubscriptions has not yet been implemented") }) } - if api.ReportSubscribeReportHandler == nil { - api.ReportSubscribeReportHandler = report.SubscribeReportHandlerFunc(func(params report.SubscribeReportParams) middleware.Responder { - return middleware.NotImplemented("operation report.SubscribeReport has not yet been implemented") + if api.XappGetXappConfigListHandler == nil { + api.XappGetXappConfigListHandler = xapp.GetXappConfigListHandlerFunc(func(params xapp.GetXappConfigListParams) middleware.Responder { + return middleware.NotImplemented("operation xapp.GetXappConfigList has not yet been implemented") }) } diff --git a/pkg/restapi/embedded_spec.go b/pkg/restapi/embedded_spec.go index dd67843..5fcc66f 100644 --- a/pkg/restapi/embedded_spec.go +++ b/pkg/restapi/embedded_spec.go @@ -64,7 +64,7 @@ func init() { "application/json" ], "tags": [ - "query" + "common" ], "summary": "Returns list of subscriptions", "operationId": "getAllSubscriptions", @@ -79,48 +79,7 @@ func init() { "description": "Internal error" } } - } - }, - "/subscriptions/policy": { - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "policy" - ], - "summary": "Subscribe and send \"POLICY\" message to RAN to execute a specific POLICY during call processing in RAN after each occurrence of a defined SUBSCRIPTION", - "operationId": "subscribePolicy", - "parameters": [ - { - "description": "Subscription policy parameters", - "name": "PolicyParams", - "in": "body", - "schema": { - "$ref": "#/definitions/PolicyParams" - } - } - ], - "responses": { - "201": { - "description": "Subscription successfully created", - "schema": { - "$ref": "#/definitions/SubscriptionResponse" - } - }, - "400": { - "description": "Invalid input" - }, - "500": { - "description": "Internal error" - } - } - } - }, - "/subscriptions/report": { + }, "post": { "consumes": [ "application/json" @@ -129,17 +88,17 @@ func init() { "application/json" ], "tags": [ - "report" + "common" ], - "summary": "Subscribe a list of X2AP event triggers to receive \"REPORT\" messages sent by RAN or Subscribe to receive the content of gNB NRT table in REPORT message sent by RAN", - "operationId": "subscribeReport", + "summary": "Subscribe a list of X2AP event triggers to receive messages sent by RAN", + "operationId": "Subscribe", "parameters": [ { - "description": "Subscription report parameters", - "name": "ReportParams", + "description": "Subscription parameters", + "name": "SubscriptionParams", "in": "body", "schema": { - "$ref": "#/definitions/ReportParams" + "$ref": "#/definitions/SubscriptionParams" } } ], @@ -196,21 +155,48 @@ func init() { } }, "definitions": { - "ActionParameters": { + "ActionDefinition": { + "description": "E2SM Octet string. ActionDefinition is an OPTIONAL IE", + "type": "object", + "properties": { + "OctetString": { + "type": "string" + } + } + }, + "ActionToBeSetup": { "type": "object", "required": [ - "ActionParameterID", - "ActionParameterValue" + "ActionID", + "ActionType" ], "properties": { - "ActionParameterID": { - "type": "integer" + "ActionDefinition": { + "$ref": "#/definitions/ActionDefinition" + }, + "ActionID": { + "type": "integer", + "maximum": 255 }, - "ActionParameterValue": { - "type": "boolean" + "ActionType": { + "type": "string", + "enum": [ + "insert", + "policy", + "report" + ] + }, + "SubsequentAction": { + "$ref": "#/definitions/SubsequentAction" } } }, + "ActionsToBeSetup": { + "type": "array", + "items": { + "$ref": "#/definitions/ActionToBeSetup" + } + }, "ConfigMetadata": { "type": "object", "required": [ @@ -233,237 +219,128 @@ func init() { } } }, - "EventTrigger": { + "EventTriggerDefinition": { + "description": "E2SM Octet string", "type": "object", "properties": { - "ENBId": { + "OctetString": { "type": "string" - }, - "InterfaceDirection": { - "type": "integer" - }, - "PlmnId": { - "type": "string" - }, - "ProcedureCode": { - "type": "integer" - }, - "TriggerNature": { - "type": "string", - "enum": [ - "now", - "on change" - ] - }, - "TypeOfMessage": { - "type": "integer" - } - } - }, - "EventTriggerList": { - "type": "array", - "items": { - "$ref": "#/definitions/EventTrigger" - } - }, - "Format1ActionDefinition": { - "type": "object", - "required": [ - "StyleID", - "ActionParameters" - ], - "properties": { - "ActionParameters": { - "type": "array", - "items": { - "$ref": "#/definitions/ActionParameters" - } - }, - "StyleID": { - "type": "integer" } } }, - "Format2ActionDefinition": { + "SubscriptionData": { "type": "object", - "required": [ - "RANUeGroupParameters" - ], "properties": { - "RANUeGroupParameters": { + "Endpoint": { "type": "array", "items": { - "$ref": "#/definitions/RANUeGroupList" + "type": "string" } - } - } - }, - "ImperativePolicyDefinition": { - "type": "object", - "required": [ - "PolicyParameterID", - "PolicyParameterValue" - ], - "properties": { - "PolicyParameterID": { - "type": "integer" - }, - "PolicyParameterValue": { - "type": "integer" - } - } - }, - "PolicyActionDefinition": { - "type": "object", - "properties": { - "ActionDefinitionFormat2": { - "$ref": "#/definitions/Format2ActionDefinition" - } - } - }, - "PolicyParams": { - "type": "object", - "required": [ - "Meid", - "RANFunctionID", - "ClientEndpoint", - "EventTriggers", - "PolicyActionDefinitions" - ], - "properties": { - "ClientEndpoint": { - "type": "string" - }, - "EventTriggers": { - "$ref": "#/definitions/EventTriggerList" }, "Meid": { "type": "string" }, - "PolicyActionDefinitions": { - "$ref": "#/definitions/PolicyActionDefinition" - }, - "RANFunctionID": { + "SubscriptionId": { "type": "integer" } } }, - "RANUeGroupList": { + "SubscriptionDetails": { "type": "object", "required": [ - "RANUeGroupID", - "RANUeGroupDefinition", - "RANImperativePolicy" + "EventTriggerList", + "ActionToBeSetupList" ], "properties": { - "RANImperativePolicy": { - "$ref": "#/definitions/ImperativePolicyDefinition" + "ActionToBeSetupList": { + "$ref": "#/definitions/ActionsToBeSetup" }, - "RANUeGroupDefinition": { - "$ref": "#/definitions/RANUeGroupParams" - }, - "RANUeGroupID": { - "type": "integer" + "EventTriggerList": { + "$ref": "#/definitions/EventTriggerDefinition" } } }, - "RANUeGroupParams": { + "SubscriptionDetailsList": { + "type": "array", + "items": { + "$ref": "#/definitions/SubscriptionDetails" + } + }, + "SubscriptionInstance": { "type": "object", "required": [ - "RANParameterID", - "RANParameterValue" + "RequestorId", + "InstanceId", + "ErrorCause" ], "properties": { - "RANParameterID": { - "type": "integer" + "ErrorCause": { + "description": "Empty string when no error.", + "type": "string" }, - "RANParameterTestCondition": { - "type": "string", - "enum": [ - "equal", - "greaterthan", - "lessthan", - "contains", - "present" - ] + "InstanceId": { + "type": "integer", + "maximum": 65535 }, - "RANParameterValue": { - "type": "integer" + "RequestorId": { + "type": "integer", + "maximum": 65535 } } }, - "ReportActionDefinition": { - "type": "object", - "properties": { - "ActionDefinitionFormat1": { - "$ref": "#/definitions/Format1ActionDefinition" - } + "SubscriptionList": { + "description": "A list of subscriptions", + "type": "array", + "items": { + "$ref": "#/definitions/SubscriptionData" } }, - "ReportParams": { + "SubscriptionParams": { "type": "object", "required": [ - "RANFunctionID", "ClientEndpoint", - "EventTriggers" + "Meid", + "RequestorId", + "InstanceId", + "RANFunctionID", + "SubscriptionDetails" ], "properties": { "ClientEndpoint": { - "type": "string" + "description": "xApp service address and port", + "type": "object", + "properties": { + "Port": { + "description": "xApp service address port", + "type": "integer", + "maximum": 65535 + }, + "ServiceName": { + "description": "xApp service address name like 'service-ricxapp-xappname-http.ricxapp'", + "type": "string" + } + } }, - "EventTriggers": { - "$ref": "#/definitions/EventTriggerList" + "InstanceId": { + "type": "integer", + "maximum": 65535 }, "Meid": { "type": "string" }, "RANFunctionID": { - "type": "integer" - }, - "ReportActionDefinitions": { - "$ref": "#/definitions/ReportActionDefinition" - } - } - }, - "SubscriptionData": { - "type": "object", - "properties": { - "Endpoint": { - "type": "array", - "items": { - "type": "string" - } - }, - "Meid": { - "type": "string" - }, - "SubscriptionId": { - "type": "integer" - } - } - }, - "SubscriptionInstance": { - "type": "object", - "required": [ - "RequestorId", - "InstanceId" - ], - "properties": { - "InstanceId": { - "type": "integer" + "type": "integer", + "maximum": 4095 }, "RequestorId": { - "type": "integer" + "type": "integer", + "maximum": 65535 + }, + "SubscriptionDetails": { + "$ref": "#/definitions/SubscriptionDetailsList" } } }, - "SubscriptionList": { - "description": "A list of subscriptions", - "type": "array", - "items": { - "$ref": "#/definitions/SubscriptionData" - } - }, "SubscriptionResponse": { "type": "object", "required": [ @@ -482,13 +359,45 @@ func init() { } } }, - "SubscriptionType": { - "type": "string", - "enum": [ - "insert", - "policy", - "report" - ] + "SubsequentAction": { + "description": "SubsequentAction is an OPTIONAL IE", + "type": "object", + "required": [ + "SubsequentActionType", + "TimeToWait" + ], + "properties": { + "SubsequentActionType": { + "type": "string", + "enum": [ + "continue", + "wait" + ] + }, + "TimeToWait": { + "type": "string", + "enum": [ + "zero", + "w1ms", + "w2ms", + "w5ms", + "w10ms", + "w20ms", + "w30ms", + "w40ms", + "w50ms", + "w100ms", + "w200ms", + "w500ms", + "w1s", + "w2s", + "w5s", + "w10s", + "w20s", + "w60s" + ] + } + } }, "XAppConfig": { "type": "object", @@ -561,7 +470,7 @@ func init() { "application/json" ], "tags": [ - "query" + "common" ], "summary": "Returns list of subscriptions", "operationId": "getAllSubscriptions", @@ -576,48 +485,7 @@ func init() { "description": "Internal error" } } - } - }, - "/subscriptions/policy": { - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "policy" - ], - "summary": "Subscribe and send \"POLICY\" message to RAN to execute a specific POLICY during call processing in RAN after each occurrence of a defined SUBSCRIPTION", - "operationId": "subscribePolicy", - "parameters": [ - { - "description": "Subscription policy parameters", - "name": "PolicyParams", - "in": "body", - "schema": { - "$ref": "#/definitions/PolicyParams" - } - } - ], - "responses": { - "201": { - "description": "Subscription successfully created", - "schema": { - "$ref": "#/definitions/SubscriptionResponse" - } - }, - "400": { - "description": "Invalid input" - }, - "500": { - "description": "Internal error" - } - } - } - }, - "/subscriptions/report": { + }, "post": { "consumes": [ "application/json" @@ -626,17 +494,17 @@ func init() { "application/json" ], "tags": [ - "report" + "common" ], - "summary": "Subscribe a list of X2AP event triggers to receive \"REPORT\" messages sent by RAN or Subscribe to receive the content of gNB NRT table in REPORT message sent by RAN", - "operationId": "subscribeReport", + "summary": "Subscribe a list of X2AP event triggers to receive messages sent by RAN", + "operationId": "Subscribe", "parameters": [ { - "description": "Subscription report parameters", - "name": "ReportParams", + "description": "Subscription parameters", + "name": "SubscriptionParams", "in": "body", "schema": { - "$ref": "#/definitions/ReportParams" + "$ref": "#/definitions/SubscriptionParams" } } ], @@ -693,21 +561,49 @@ func init() { } }, "definitions": { - "ActionParameters": { + "ActionDefinition": { + "description": "E2SM Octet string. ActionDefinition is an OPTIONAL IE", + "type": "object", + "properties": { + "OctetString": { + "type": "string" + } + } + }, + "ActionToBeSetup": { "type": "object", "required": [ - "ActionParameterID", - "ActionParameterValue" + "ActionID", + "ActionType" ], "properties": { - "ActionParameterID": { - "type": "integer" + "ActionDefinition": { + "$ref": "#/definitions/ActionDefinition" + }, + "ActionID": { + "type": "integer", + "maximum": 255, + "minimum": 0 }, - "ActionParameterValue": { - "type": "boolean" + "ActionType": { + "type": "string", + "enum": [ + "insert", + "policy", + "report" + ] + }, + "SubsequentAction": { + "$ref": "#/definitions/SubsequentAction" } } }, + "ActionsToBeSetup": { + "type": "array", + "items": { + "$ref": "#/definitions/ActionToBeSetup" + } + }, "ConfigMetadata": { "type": "object", "required": [ @@ -730,237 +626,134 @@ func init() { } } }, - "EventTrigger": { + "EventTriggerDefinition": { + "description": "E2SM Octet string", "type": "object", "properties": { - "ENBId": { + "OctetString": { "type": "string" - }, - "InterfaceDirection": { - "type": "integer" - }, - "PlmnId": { - "type": "string" - }, - "ProcedureCode": { - "type": "integer" - }, - "TriggerNature": { - "type": "string", - "enum": [ - "now", - "on change" - ] - }, - "TypeOfMessage": { - "type": "integer" - } - } - }, - "EventTriggerList": { - "type": "array", - "items": { - "$ref": "#/definitions/EventTrigger" - } - }, - "Format1ActionDefinition": { - "type": "object", - "required": [ - "StyleID", - "ActionParameters" - ], - "properties": { - "ActionParameters": { - "type": "array", - "items": { - "$ref": "#/definitions/ActionParameters" - } - }, - "StyleID": { - "type": "integer" } } }, - "Format2ActionDefinition": { + "SubscriptionData": { "type": "object", - "required": [ - "RANUeGroupParameters" - ], "properties": { - "RANUeGroupParameters": { + "Endpoint": { "type": "array", "items": { - "$ref": "#/definitions/RANUeGroupList" + "type": "string" } - } - } - }, - "ImperativePolicyDefinition": { - "type": "object", - "required": [ - "PolicyParameterID", - "PolicyParameterValue" - ], - "properties": { - "PolicyParameterID": { - "type": "integer" - }, - "PolicyParameterValue": { - "type": "integer" - } - } - }, - "PolicyActionDefinition": { - "type": "object", - "properties": { - "ActionDefinitionFormat2": { - "$ref": "#/definitions/Format2ActionDefinition" - } - } - }, - "PolicyParams": { - "type": "object", - "required": [ - "Meid", - "RANFunctionID", - "ClientEndpoint", - "EventTriggers", - "PolicyActionDefinitions" - ], - "properties": { - "ClientEndpoint": { - "type": "string" - }, - "EventTriggers": { - "$ref": "#/definitions/EventTriggerList" }, "Meid": { "type": "string" }, - "PolicyActionDefinitions": { - "$ref": "#/definitions/PolicyActionDefinition" - }, - "RANFunctionID": { + "SubscriptionId": { "type": "integer" } } }, - "RANUeGroupList": { + "SubscriptionDetails": { "type": "object", "required": [ - "RANUeGroupID", - "RANUeGroupDefinition", - "RANImperativePolicy" + "EventTriggerList", + "ActionToBeSetupList" ], "properties": { - "RANImperativePolicy": { - "$ref": "#/definitions/ImperativePolicyDefinition" + "ActionToBeSetupList": { + "$ref": "#/definitions/ActionsToBeSetup" }, - "RANUeGroupDefinition": { - "$ref": "#/definitions/RANUeGroupParams" - }, - "RANUeGroupID": { - "type": "integer" + "EventTriggerList": { + "$ref": "#/definitions/EventTriggerDefinition" } } }, - "RANUeGroupParams": { + "SubscriptionDetailsList": { + "type": "array", + "items": { + "$ref": "#/definitions/SubscriptionDetails" + } + }, + "SubscriptionInstance": { "type": "object", "required": [ - "RANParameterID", - "RANParameterValue" + "RequestorId", + "InstanceId", + "ErrorCause" ], "properties": { - "RANParameterID": { - "type": "integer" + "ErrorCause": { + "description": "Empty string when no error.", + "type": "string" }, - "RANParameterTestCondition": { - "type": "string", - "enum": [ - "equal", - "greaterthan", - "lessthan", - "contains", - "present" - ] + "InstanceId": { + "type": "integer", + "maximum": 65535, + "minimum": 0 }, - "RANParameterValue": { - "type": "integer" + "RequestorId": { + "type": "integer", + "maximum": 65535, + "minimum": 0 } } }, - "ReportActionDefinition": { - "type": "object", - "properties": { - "ActionDefinitionFormat1": { - "$ref": "#/definitions/Format1ActionDefinition" - } + "SubscriptionList": { + "description": "A list of subscriptions", + "type": "array", + "items": { + "$ref": "#/definitions/SubscriptionData" } }, - "ReportParams": { + "SubscriptionParams": { "type": "object", "required": [ - "RANFunctionID", "ClientEndpoint", - "EventTriggers" + "Meid", + "RequestorId", + "InstanceId", + "RANFunctionID", + "SubscriptionDetails" ], "properties": { "ClientEndpoint": { - "type": "string" + "description": "xApp service address and port", + "type": "object", + "properties": { + "Port": { + "description": "xApp service address port", + "type": "integer", + "maximum": 65535, + "minimum": 0 + }, + "ServiceName": { + "description": "xApp service address name like 'service-ricxapp-xappname-http.ricxapp'", + "type": "string" + } + } }, - "EventTriggers": { - "$ref": "#/definitions/EventTriggerList" + "InstanceId": { + "type": "integer", + "maximum": 65535, + "minimum": 0 }, "Meid": { "type": "string" }, "RANFunctionID": { - "type": "integer" - }, - "ReportActionDefinitions": { - "$ref": "#/definitions/ReportActionDefinition" - } - } - }, - "SubscriptionData": { - "type": "object", - "properties": { - "Endpoint": { - "type": "array", - "items": { - "type": "string" - } - }, - "Meid": { - "type": "string" - }, - "SubscriptionId": { - "type": "integer" - } - } - }, - "SubscriptionInstance": { - "type": "object", - "required": [ - "RequestorId", - "InstanceId" - ], - "properties": { - "InstanceId": { - "type": "integer" + "type": "integer", + "maximum": 4095, + "minimum": 0 }, "RequestorId": { - "type": "integer" + "type": "integer", + "maximum": 65535, + "minimum": 0 + }, + "SubscriptionDetails": { + "$ref": "#/definitions/SubscriptionDetailsList" } } }, - "SubscriptionList": { - "description": "A list of subscriptions", - "type": "array", - "items": { - "$ref": "#/definitions/SubscriptionData" - } - }, "SubscriptionResponse": { "type": "object", "required": [ @@ -979,13 +772,45 @@ func init() { } } }, - "SubscriptionType": { - "type": "string", - "enum": [ - "insert", - "policy", - "report" - ] + "SubsequentAction": { + "description": "SubsequentAction is an OPTIONAL IE", + "type": "object", + "required": [ + "SubsequentActionType", + "TimeToWait" + ], + "properties": { + "SubsequentActionType": { + "type": "string", + "enum": [ + "continue", + "wait" + ] + }, + "TimeToWait": { + "type": "string", + "enum": [ + "zero", + "w1ms", + "w2ms", + "w5ms", + "w10ms", + "w20ms", + "w30ms", + "w40ms", + "w50ms", + "w100ms", + "w200ms", + "w500ms", + "w1s", + "w2s", + "w5s", + "w10s", + "w20s", + "w60s" + ] + } + } }, "XAppConfig": { "type": "object", diff --git a/pkg/restapi/operations/query/get_all_subscriptions.go b/pkg/restapi/operations/common/get_all_subscriptions.go similarity index 94% rename from pkg/restapi/operations/query/get_all_subscriptions.go rename to pkg/restapi/operations/common/get_all_subscriptions.go index 2a6a6e8..59efa4c 100644 --- a/pkg/restapi/operations/query/get_all_subscriptions.go +++ b/pkg/restapi/operations/common/get_all_subscriptions.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package query +package common // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the generate command @@ -29,7 +29,7 @@ func NewGetAllSubscriptions(ctx *middleware.Context, handler GetAllSubscriptions return &GetAllSubscriptions{Context: ctx, Handler: handler} } -/*GetAllSubscriptions swagger:route GET /subscriptions query getAllSubscriptions +/*GetAllSubscriptions swagger:route GET /subscriptions common getAllSubscriptions Returns list of subscriptions diff --git a/pkg/restapi/operations/query/get_all_subscriptions_parameters.go b/pkg/restapi/operations/common/get_all_subscriptions_parameters.go similarity index 98% rename from pkg/restapi/operations/query/get_all_subscriptions_parameters.go rename to pkg/restapi/operations/common/get_all_subscriptions_parameters.go index a9aca80..ec58649 100644 --- a/pkg/restapi/operations/query/get_all_subscriptions_parameters.go +++ b/pkg/restapi/operations/common/get_all_subscriptions_parameters.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package query +package common // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command diff --git a/pkg/restapi/operations/query/get_all_subscriptions_responses.go b/pkg/restapi/operations/common/get_all_subscriptions_responses.go similarity index 99% rename from pkg/restapi/operations/query/get_all_subscriptions_responses.go rename to pkg/restapi/operations/common/get_all_subscriptions_responses.go index 485f1b8..d1e8f0a 100644 --- a/pkg/restapi/operations/query/get_all_subscriptions_responses.go +++ b/pkg/restapi/operations/common/get_all_subscriptions_responses.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package query +package common // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command diff --git a/pkg/restapi/operations/query/get_all_subscriptions_urlbuilder.go b/pkg/restapi/operations/common/get_all_subscriptions_urlbuilder.go similarity index 99% rename from pkg/restapi/operations/query/get_all_subscriptions_urlbuilder.go rename to pkg/restapi/operations/common/get_all_subscriptions_urlbuilder.go index 7ef157a..4703e12 100644 --- a/pkg/restapi/operations/query/get_all_subscriptions_urlbuilder.go +++ b/pkg/restapi/operations/common/get_all_subscriptions_urlbuilder.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package query +package common // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the generate command diff --git a/pkg/restapi/operations/common/subscribe.go b/pkg/restapi/operations/common/subscribe.go new file mode 100644 index 0000000..49bd617 --- /dev/null +++ b/pkg/restapi/operations/common/subscribe.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package common + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + middleware "github.com/go-openapi/runtime/middleware" +) + +// SubscribeHandlerFunc turns a function with the right signature into a subscribe handler +type SubscribeHandlerFunc func(SubscribeParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn SubscribeHandlerFunc) Handle(params SubscribeParams) middleware.Responder { + return fn(params) +} + +// SubscribeHandler interface for that can handle valid subscribe params +type SubscribeHandler interface { + Handle(SubscribeParams) middleware.Responder +} + +// NewSubscribe creates a new http.Handler for the subscribe operation +func NewSubscribe(ctx *middleware.Context, handler SubscribeHandler) *Subscribe { + return &Subscribe{Context: ctx, Handler: handler} +} + +/*Subscribe swagger:route POST /subscriptions common subscribe + +Subscribe a list of X2AP event triggers to receive messages sent by RAN + +*/ +type Subscribe struct { + Context *middleware.Context + Handler SubscribeHandler +} + +func (o *Subscribe) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewSubscribeParams() + + 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) + +} diff --git a/pkg/restapi/operations/policy/subscribe_policy_parameters.go b/pkg/restapi/operations/common/subscribe_parameters.go similarity index 63% rename from pkg/restapi/operations/policy/subscribe_policy_parameters.go rename to pkg/restapi/operations/common/subscribe_parameters.go index ca6cb28..7749315 100644 --- a/pkg/restapi/operations/policy/subscribe_policy_parameters.go +++ b/pkg/restapi/operations/common/subscribe_parameters.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package policy +package common // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command @@ -15,42 +15,42 @@ import ( models "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" ) -// NewSubscribePolicyParams creates a new SubscribePolicyParams object +// NewSubscribeParams creates a new SubscribeParams object // no default values defined in spec. -func NewSubscribePolicyParams() SubscribePolicyParams { +func NewSubscribeParams() SubscribeParams { - return SubscribePolicyParams{} + return SubscribeParams{} } -// SubscribePolicyParams contains all the bound params for the subscribe policy operation +// SubscribeParams contains all the bound params for the subscribe operation // typically these are obtained from a http.Request // -// swagger:parameters subscribePolicy -type SubscribePolicyParams struct { +// swagger:parameters Subscribe +type SubscribeParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Subscription policy parameters + /*Subscription parameters In: body */ - PolicyParams *models.PolicyParams + SubscriptionParams *models.SubscriptionParams } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface // for simple values it will use straight method calls. // -// To ensure default values, the struct must have been initialized with NewSubscribePolicyParams() beforehand. -func (o *SubscribePolicyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { +// To ensure default values, the struct must have been initialized with NewSubscribeParams() beforehand. +func (o *SubscribeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { var res []error o.HTTPRequest = r if runtime.HasBody(r) { defer r.Body.Close() - var body models.PolicyParams + var body models.SubscriptionParams if err := route.Consumer.Consume(r.Body, &body); err != nil { - res = append(res, errors.NewParseError("policyParams", "body", "", err)) + res = append(res, errors.NewParseError("subscriptionParams", "body", "", err)) } else { // validate body object if err := body.Validate(route.Formats); err != nil { @@ -58,7 +58,7 @@ func (o *SubscribePolicyParams) BindRequest(r *http.Request, route *middleware.M } if len(res) == 0 { - o.PolicyParams = &body + o.SubscriptionParams = &body } } } diff --git a/pkg/restapi/operations/common/subscribe_responses.go b/pkg/restapi/operations/common/subscribe_responses.go new file mode 100644 index 0000000..fc5515c --- /dev/null +++ b/pkg/restapi/operations/common/subscribe_responses.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package common + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + models "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" +) + +// SubscribeCreatedCode is the HTTP code returned for type SubscribeCreated +const SubscribeCreatedCode int = 201 + +/*SubscribeCreated Subscription successfully created + +swagger:response subscribeCreated +*/ +type SubscribeCreated struct { + + /* + In: Body + */ + Payload *models.SubscriptionResponse `json:"body,omitempty"` +} + +// NewSubscribeCreated creates SubscribeCreated with default headers values +func NewSubscribeCreated() *SubscribeCreated { + + return &SubscribeCreated{} +} + +// WithPayload adds the payload to the subscribe created response +func (o *SubscribeCreated) WithPayload(payload *models.SubscriptionResponse) *SubscribeCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the subscribe created response +func (o *SubscribeCreated) SetPayload(payload *models.SubscriptionResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SubscribeCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// SubscribeBadRequestCode is the HTTP code returned for type SubscribeBadRequest +const SubscribeBadRequestCode int = 400 + +/*SubscribeBadRequest Invalid input + +swagger:response subscribeBadRequest +*/ +type SubscribeBadRequest struct { +} + +// NewSubscribeBadRequest creates SubscribeBadRequest with default headers values +func NewSubscribeBadRequest() *SubscribeBadRequest { + + return &SubscribeBadRequest{} +} + +// WriteResponse to the client +func (o *SubscribeBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(400) +} + +// SubscribeInternalServerErrorCode is the HTTP code returned for type SubscribeInternalServerError +const SubscribeInternalServerErrorCode int = 500 + +/*SubscribeInternalServerError Internal error + +swagger:response subscribeInternalServerError +*/ +type SubscribeInternalServerError struct { +} + +// NewSubscribeInternalServerError creates SubscribeInternalServerError with default headers values +func NewSubscribeInternalServerError() *SubscribeInternalServerError { + + return &SubscribeInternalServerError{} +} + +// WriteResponse to the client +func (o *SubscribeInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/pkg/restapi/operations/policy/subscribe_policy_urlbuilder.go b/pkg/restapi/operations/common/subscribe_urlbuilder.go similarity index 72% rename from pkg/restapi/operations/policy/subscribe_policy_urlbuilder.go rename to pkg/restapi/operations/common/subscribe_urlbuilder.go index 2274f40..b3b97e3 100644 --- a/pkg/restapi/operations/policy/subscribe_policy_urlbuilder.go +++ b/pkg/restapi/operations/common/subscribe_urlbuilder.go @@ -1,6 +1,6 @@ // Code generated by go-swagger; DO NOT EDIT. -package policy +package common // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the generate command @@ -11,15 +11,15 @@ import ( golangswaggerpaths "path" ) -// SubscribePolicyURL generates an URL for the subscribe policy operation -type SubscribePolicyURL struct { +// SubscribeURL generates an URL for the subscribe operation +type SubscribeURL struct { _basePath string } // WithBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *SubscribePolicyURL) WithBasePath(bp string) *SubscribePolicyURL { +func (o *SubscribeURL) WithBasePath(bp string) *SubscribeURL { o.SetBasePath(bp) return o } @@ -27,15 +27,15 @@ func (o *SubscribePolicyURL) WithBasePath(bp string) *SubscribePolicyURL { // SetBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *SubscribePolicyURL) SetBasePath(bp string) { +func (o *SubscribeURL) SetBasePath(bp string) { o._basePath = bp } // Build a url path and query string -func (o *SubscribePolicyURL) Build() (*url.URL, error) { +func (o *SubscribeURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/subscriptions/policy" + var _path = "/subscriptions" _basePath := o._basePath if _basePath == "" { @@ -47,7 +47,7 @@ func (o *SubscribePolicyURL) Build() (*url.URL, error) { } // Must is a helper function to panic when the url builder returns an error -func (o *SubscribePolicyURL) Must(u *url.URL, err error) *url.URL { +func (o *SubscribeURL) Must(u *url.URL, err error) *url.URL { if err != nil { panic(err) } @@ -58,17 +58,17 @@ func (o *SubscribePolicyURL) Must(u *url.URL, err error) *url.URL { } // String returns the string representation of the path with query string -func (o *SubscribePolicyURL) String() string { +func (o *SubscribeURL) String() string { return o.Must(o.Build()).String() } // BuildFull builds a full url with scheme, host, path and query string -func (o *SubscribePolicyURL) BuildFull(scheme, host string) (*url.URL, error) { +func (o *SubscribeURL) BuildFull(scheme, host string) (*url.URL, error) { if scheme == "" { - return nil, errors.New("scheme is required for a full url on SubscribePolicyURL") + return nil, errors.New("scheme is required for a full url on SubscribeURL") } if host == "" { - return nil, errors.New("host is required for a full url on SubscribePolicyURL") + return nil, errors.New("host is required for a full url on SubscribeURL") } base, err := o.Build() @@ -82,6 +82,6 @@ func (o *SubscribePolicyURL) BuildFull(scheme, host string) (*url.URL, error) { } // StringFull returns the string representation of a complete url -func (o *SubscribePolicyURL) StringFull(scheme, host string) string { +func (o *SubscribeURL) StringFull(scheme, host string) string { return o.Must(o.BuildFull(scheme, host)).String() } diff --git a/pkg/restapi/operations/policy/subscribe_policy.go b/pkg/restapi/operations/policy/subscribe_policy.go deleted file mode 100644 index f812cec..0000000 --- a/pkg/restapi/operations/policy/subscribe_policy.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package policy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// SubscribePolicyHandlerFunc turns a function with the right signature into a subscribe policy handler -type SubscribePolicyHandlerFunc func(SubscribePolicyParams) middleware.Responder - -// Handle executing the request and returning a response -func (fn SubscribePolicyHandlerFunc) Handle(params SubscribePolicyParams) middleware.Responder { - return fn(params) -} - -// SubscribePolicyHandler interface for that can handle valid subscribe policy params -type SubscribePolicyHandler interface { - Handle(SubscribePolicyParams) middleware.Responder -} - -// NewSubscribePolicy creates a new http.Handler for the subscribe policy operation -func NewSubscribePolicy(ctx *middleware.Context, handler SubscribePolicyHandler) *SubscribePolicy { - return &SubscribePolicy{Context: ctx, Handler: handler} -} - -/*SubscribePolicy swagger:route POST /subscriptions/policy policy subscribePolicy - -Subscribe and send "POLICY" message to RAN to execute a specific POLICY during call processing in RAN after each occurrence of a defined SUBSCRIPTION - -*/ -type SubscribePolicy struct { - Context *middleware.Context - Handler SubscribePolicyHandler -} - -func (o *SubscribePolicy) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewSubscribePolicyParams() - - 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) - -} diff --git a/pkg/restapi/operations/policy/subscribe_policy_responses.go b/pkg/restapi/operations/policy/subscribe_policy_responses.go deleted file mode 100644 index 4a56d34..0000000 --- a/pkg/restapi/operations/policy/subscribe_policy_responses.go +++ /dev/null @@ -1,106 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package policy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - - models "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" -) - -// SubscribePolicyCreatedCode is the HTTP code returned for type SubscribePolicyCreated -const SubscribePolicyCreatedCode int = 201 - -/*SubscribePolicyCreated Subscription successfully created - -swagger:response subscribePolicyCreated -*/ -type SubscribePolicyCreated struct { - - /* - In: Body - */ - Payload *models.SubscriptionResponse `json:"body,omitempty"` -} - -// NewSubscribePolicyCreated creates SubscribePolicyCreated with default headers values -func NewSubscribePolicyCreated() *SubscribePolicyCreated { - - return &SubscribePolicyCreated{} -} - -// WithPayload adds the payload to the subscribe policy created response -func (o *SubscribePolicyCreated) WithPayload(payload *models.SubscriptionResponse) *SubscribePolicyCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subscribe policy created response -func (o *SubscribePolicyCreated) SetPayload(payload *models.SubscriptionResponse) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubscribePolicyCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// SubscribePolicyBadRequestCode is the HTTP code returned for type SubscribePolicyBadRequest -const SubscribePolicyBadRequestCode int = 400 - -/*SubscribePolicyBadRequest Invalid input - -swagger:response subscribePolicyBadRequest -*/ -type SubscribePolicyBadRequest struct { -} - -// NewSubscribePolicyBadRequest creates SubscribePolicyBadRequest with default headers values -func NewSubscribePolicyBadRequest() *SubscribePolicyBadRequest { - - return &SubscribePolicyBadRequest{} -} - -// WriteResponse to the client -func (o *SubscribePolicyBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(400) -} - -// SubscribePolicyInternalServerErrorCode is the HTTP code returned for type SubscribePolicyInternalServerError -const SubscribePolicyInternalServerErrorCode int = 500 - -/*SubscribePolicyInternalServerError Internal error - -swagger:response subscribePolicyInternalServerError -*/ -type SubscribePolicyInternalServerError struct { -} - -// NewSubscribePolicyInternalServerError creates SubscribePolicyInternalServerError with default headers values -func NewSubscribePolicyInternalServerError() *SubscribePolicyInternalServerError { - - return &SubscribePolicyInternalServerError{} -} - -// WriteResponse to the client -func (o *SubscribePolicyInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(500) -} diff --git a/pkg/restapi/operations/report/subscribe_report.go b/pkg/restapi/operations/report/subscribe_report.go deleted file mode 100644 index d0ea85e..0000000 --- a/pkg/restapi/operations/report/subscribe_report.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package report - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// SubscribeReportHandlerFunc turns a function with the right signature into a subscribe report handler -type SubscribeReportHandlerFunc func(SubscribeReportParams) middleware.Responder - -// Handle executing the request and returning a response -func (fn SubscribeReportHandlerFunc) Handle(params SubscribeReportParams) middleware.Responder { - return fn(params) -} - -// SubscribeReportHandler interface for that can handle valid subscribe report params -type SubscribeReportHandler interface { - Handle(SubscribeReportParams) middleware.Responder -} - -// NewSubscribeReport creates a new http.Handler for the subscribe report operation -func NewSubscribeReport(ctx *middleware.Context, handler SubscribeReportHandler) *SubscribeReport { - return &SubscribeReport{Context: ctx, Handler: handler} -} - -/*SubscribeReport swagger:route POST /subscriptions/report report subscribeReport - -Subscribe a list of X2AP event triggers to receive "REPORT" messages sent by RAN or Subscribe to receive the content of gNB NRT table in REPORT message sent by RAN - -*/ -type SubscribeReport struct { - Context *middleware.Context - Handler SubscribeReportHandler -} - -func (o *SubscribeReport) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewSubscribeReportParams() - - 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) - -} diff --git a/pkg/restapi/operations/report/subscribe_report_parameters.go b/pkg/restapi/operations/report/subscribe_report_parameters.go deleted file mode 100644 index 96adaaf..0000000 --- a/pkg/restapi/operations/report/subscribe_report_parameters.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package report - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - - models "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" -) - -// NewSubscribeReportParams creates a new SubscribeReportParams object -// no default values defined in spec. -func NewSubscribeReportParams() SubscribeReportParams { - - return SubscribeReportParams{} -} - -// SubscribeReportParams contains all the bound params for the subscribe report operation -// typically these are obtained from a http.Request -// -// swagger:parameters subscribeReport -type SubscribeReportParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Subscription report parameters - In: body - */ - ReportParams *models.ReportParams -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewSubscribeReportParams() beforehand. -func (o *SubscribeReportParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.ReportParams - if err := route.Consumer.Consume(r.Body, &body); err != nil { - res = append(res, errors.NewParseError("reportParams", "body", "", err)) - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.ReportParams = &body - } - } - } - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/restapi/operations/report/subscribe_report_responses.go b/pkg/restapi/operations/report/subscribe_report_responses.go deleted file mode 100644 index 9e9d18d..0000000 --- a/pkg/restapi/operations/report/subscribe_report_responses.go +++ /dev/null @@ -1,106 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package report - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - - models "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" -) - -// SubscribeReportCreatedCode is the HTTP code returned for type SubscribeReportCreated -const SubscribeReportCreatedCode int = 201 - -/*SubscribeReportCreated Subscription successfully created - -swagger:response subscribeReportCreated -*/ -type SubscribeReportCreated struct { - - /* - In: Body - */ - Payload *models.SubscriptionResponse `json:"body,omitempty"` -} - -// NewSubscribeReportCreated creates SubscribeReportCreated with default headers values -func NewSubscribeReportCreated() *SubscribeReportCreated { - - return &SubscribeReportCreated{} -} - -// WithPayload adds the payload to the subscribe report created response -func (o *SubscribeReportCreated) WithPayload(payload *models.SubscriptionResponse) *SubscribeReportCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subscribe report created response -func (o *SubscribeReportCreated) SetPayload(payload *models.SubscriptionResponse) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubscribeReportCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// SubscribeReportBadRequestCode is the HTTP code returned for type SubscribeReportBadRequest -const SubscribeReportBadRequestCode int = 400 - -/*SubscribeReportBadRequest Invalid input - -swagger:response subscribeReportBadRequest -*/ -type SubscribeReportBadRequest struct { -} - -// NewSubscribeReportBadRequest creates SubscribeReportBadRequest with default headers values -func NewSubscribeReportBadRequest() *SubscribeReportBadRequest { - - return &SubscribeReportBadRequest{} -} - -// WriteResponse to the client -func (o *SubscribeReportBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(400) -} - -// SubscribeReportInternalServerErrorCode is the HTTP code returned for type SubscribeReportInternalServerError -const SubscribeReportInternalServerErrorCode int = 500 - -/*SubscribeReportInternalServerError Internal error - -swagger:response subscribeReportInternalServerError -*/ -type SubscribeReportInternalServerError struct { -} - -// NewSubscribeReportInternalServerError creates SubscribeReportInternalServerError with default headers values -func NewSubscribeReportInternalServerError() *SubscribeReportInternalServerError { - - return &SubscribeReportInternalServerError{} -} - -// WriteResponse to the client -func (o *SubscribeReportInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(500) -} diff --git a/pkg/restapi/operations/report/subscribe_report_urlbuilder.go b/pkg/restapi/operations/report/subscribe_report_urlbuilder.go deleted file mode 100644 index dc713b6..0000000 --- a/pkg/restapi/operations/report/subscribe_report_urlbuilder.go +++ /dev/null @@ -1,87 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package report - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// SubscribeReportURL generates an URL for the subscribe report operation -type SubscribeReportURL struct { - _basePath string -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *SubscribeReportURL) WithBasePath(bp string) *SubscribeReportURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *SubscribeReportURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *SubscribeReportURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/subscriptions/report" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/ric/v1" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *SubscribeReportURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *SubscribeReportURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *SubscribeReportURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on SubscribeReportURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on SubscribeReportURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *SubscribeReportURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/pkg/restapi/operations/xapp_framework_api.go b/pkg/restapi/operations/xapp_framework_api.go index c2ef01b..e16707e 100644 --- a/pkg/restapi/operations/xapp_framework_api.go +++ b/pkg/restapi/operations/xapp_framework_api.go @@ -20,9 +20,6 @@ import ( "github.com/go-openapi/swag" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/common" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/policy" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/query" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/report" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/xapp" ) @@ -44,21 +41,18 @@ func NewXappFrameworkAPI(spec *loads.Document) *XappFrameworkAPI { JSONConsumer: runtime.JSONConsumer(), JSONProducer: runtime.JSONProducer(), XMLProducer: runtime.XMLProducer(), + CommonSubscribeHandler: common.SubscribeHandlerFunc(func(params common.SubscribeParams) middleware.Responder { + return middleware.NotImplemented("operation CommonSubscribe has not yet been implemented") + }), CommonUnsubscribeHandler: common.UnsubscribeHandlerFunc(func(params common.UnsubscribeParams) middleware.Responder { return middleware.NotImplemented("operation CommonUnsubscribe has not yet been implemented") }), - QueryGetAllSubscriptionsHandler: query.GetAllSubscriptionsHandlerFunc(func(params query.GetAllSubscriptionsParams) middleware.Responder { - return middleware.NotImplemented("operation QueryGetAllSubscriptions has not yet been implemented") + CommonGetAllSubscriptionsHandler: common.GetAllSubscriptionsHandlerFunc(func(params common.GetAllSubscriptionsParams) middleware.Responder { + return middleware.NotImplemented("operation CommonGetAllSubscriptions has not yet been implemented") }), XappGetXappConfigListHandler: xapp.GetXappConfigListHandlerFunc(func(params xapp.GetXappConfigListParams) middleware.Responder { return middleware.NotImplemented("operation XappGetXappConfigList has not yet been implemented") }), - PolicySubscribePolicyHandler: policy.SubscribePolicyHandlerFunc(func(params policy.SubscribePolicyParams) middleware.Responder { - return middleware.NotImplemented("operation PolicySubscribePolicy has not yet been implemented") - }), - ReportSubscribeReportHandler: report.SubscribeReportHandlerFunc(func(params report.SubscribeReportParams) middleware.Responder { - return middleware.NotImplemented("operation ReportSubscribeReport has not yet been implemented") - }), } } @@ -92,16 +86,14 @@ type XappFrameworkAPI struct { // XMLProducer registers a producer for a "application/xml" mime type XMLProducer runtime.Producer + // CommonSubscribeHandler sets the operation handler for the subscribe operation + CommonSubscribeHandler common.SubscribeHandler // CommonUnsubscribeHandler sets the operation handler for the unsubscribe operation CommonUnsubscribeHandler common.UnsubscribeHandler - // QueryGetAllSubscriptionsHandler sets the operation handler for the get all subscriptions operation - QueryGetAllSubscriptionsHandler query.GetAllSubscriptionsHandler + // CommonGetAllSubscriptionsHandler sets the operation handler for the get all subscriptions operation + CommonGetAllSubscriptionsHandler common.GetAllSubscriptionsHandler // XappGetXappConfigListHandler sets the operation handler for the get xapp config list operation XappGetXappConfigListHandler xapp.GetXappConfigListHandler - // PolicySubscribePolicyHandler sets the operation handler for the subscribe policy operation - PolicySubscribePolicyHandler policy.SubscribePolicyHandler - // ReportSubscribeReportHandler sets the operation handler for the subscribe report operation - ReportSubscribeReportHandler report.SubscribeReportHandler // ServeError is called when an error is received, there is a default handler // but you can set your own with this @@ -169,26 +161,22 @@ func (o *XappFrameworkAPI) Validate() error { unregistered = append(unregistered, "XMLProducer") } + if o.CommonSubscribeHandler == nil { + unregistered = append(unregistered, "common.SubscribeHandler") + } + if o.CommonUnsubscribeHandler == nil { unregistered = append(unregistered, "common.UnsubscribeHandler") } - if o.QueryGetAllSubscriptionsHandler == nil { - unregistered = append(unregistered, "query.GetAllSubscriptionsHandler") + if o.CommonGetAllSubscriptionsHandler == nil { + unregistered = append(unregistered, "common.GetAllSubscriptionsHandler") } if o.XappGetXappConfigListHandler == nil { unregistered = append(unregistered, "xapp.GetXappConfigListHandler") } - if o.PolicySubscribePolicyHandler == nil { - unregistered = append(unregistered, "policy.SubscribePolicyHandler") - } - - if o.ReportSubscribeReportHandler == nil { - unregistered = append(unregistered, "report.SubscribeReportHandler") - } - if len(unregistered) > 0 { return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) } @@ -290,6 +278,11 @@ func (o *XappFrameworkAPI) initHandlerCache() { o.handlers = make(map[string]map[string]http.Handler) } + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/subscriptions"] = common.NewSubscribe(o.context, o.CommonSubscribeHandler) + if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) } @@ -298,23 +291,13 @@ func (o *XappFrameworkAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } - o.handlers["GET"]["/subscriptions"] = query.NewGetAllSubscriptions(o.context, o.QueryGetAllSubscriptionsHandler) + o.handlers["GET"]["/subscriptions"] = common.NewGetAllSubscriptions(o.context, o.CommonGetAllSubscriptionsHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } o.handlers["GET"]["/config"] = xapp.NewGetXappConfigList(o.context, o.XappGetXappConfigListHandler) - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) - } - o.handlers["POST"]["/subscriptions/policy"] = policy.NewSubscribePolicy(o.context, o.PolicySubscribePolicyHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) - } - o.handlers["POST"]["/subscriptions/report"] = report.NewSubscribeReport(o.context, o.ReportSubscribeReportHandler) - } // Serve creates a http handler to serve the API over HTTP diff --git a/pkg/xapp/restapi.go b/pkg/xapp/restapi.go index 24755fa..7019bac 100755 --- a/pkg/xapp/restapi.go +++ b/pkg/xapp/restapi.go @@ -120,12 +120,50 @@ func (r *Router) GetSymptomDataParams(w http.ResponseWriter, req *http.Request) return params } +func (r *Router) CollectDefaultSymptomData(fileName string, data interface{}) string { + baseDir := Config.GetString("controls.symptomdata.baseDir") + if baseDir == "" { + baseDir = "/tmp/xapp/" + } + + if err := Util.CreateDir(baseDir); err != nil { + Logger.Error("CreateDir failed: %v", err) + return "" + } + + if metrics, err := r.GetLocalMetrics(GetPortData("http").Port); err == nil { + if err := Util.WriteToFile(baseDir+"metrics.json", metrics); err != nil { + Logger.Error("writeToFile failed for metrics.json: %v", err) + } + } + + if data != nil { + if b, err := json.MarshalIndent(data, "", " "); err == nil { + Util.WriteToFile(baseDir+fileName, string(b)) + } + } + + rtPath := os.Getenv("RMR_STASH_RT") + if rtPath == "" { + return baseDir + } + + input, err := ioutil.ReadFile(rtPath) + if err != nil { + Logger.Error("ioutil.ReadFile failed: %v", err) + return baseDir + } + + Util.WriteToFile(baseDir+"rttable.txt", string(input)) + return baseDir +} + func (r *Router) SendSymptomDataJson(w http.ResponseWriter, req *http.Request, data interface{}, n string) { w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Disposition", "attachment; filename="+n) w.WriteHeader(http.StatusOK) if data != nil { - response, _ := json.Marshal(data) + response, _ := json.MarshalIndent(data, "", " ") w.Write(response) } } diff --git a/pkg/xapp/subscription.go b/pkg/xapp/subscription.go index bf140c4..73cb4a2 100755 --- a/pkg/xapp/subscription.go +++ b/pkg/xapp/subscription.go @@ -29,29 +29,21 @@ import ( "github.com/go-openapi/strfmt" "github.com/spf13/viper" "io/ioutil" - "net" "net/http" "os" "time" - //"errors" apiclient "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi" apicommon "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/common" - apipolicy "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/policy" - apireport "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientapi/report" apimodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/common" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/policy" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/query" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/report" - //"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/xapp" ) -type SubscriptionHandler func(models.SubscriptionType, interface{}) (*models.SubscriptionResponse, error) +type SubscriptionHandler func(interface{}) (*models.SubscriptionResponse, error) type SubscriptionQueryHandler func() (models.SubscriptionList, error) type SubscriptionDeleteHandler func(string) error type SubscriptionResponseCallback func(*apimodel.SubscriptionResponse) @@ -116,33 +108,24 @@ func (r *Subscriber) Listen(createSubscription SubscriptionHandler, getSubscript api := operations.NewXappFrameworkAPI(swaggerSpec) // Subscription: Query - api.QueryGetAllSubscriptionsHandler = query.GetAllSubscriptionsHandlerFunc( - func(p query.GetAllSubscriptionsParams) middleware.Responder { + api.CommonGetAllSubscriptionsHandler = common.GetAllSubscriptionsHandlerFunc( + func(p common.GetAllSubscriptionsParams) middleware.Responder { if resp, err := getSubscription(); err == nil { - return query.NewGetAllSubscriptionsOK().WithPayload(resp) + return common.NewGetAllSubscriptionsOK().WithPayload(resp) } - return query.NewGetAllSubscriptionsInternalServerError() + return common.NewGetAllSubscriptionsInternalServerError() }) - // SubscriptionType: Report - api.ReportSubscribeReportHandler = report.SubscribeReportHandlerFunc( - func(p report.SubscribeReportParams) middleware.Responder { - if resp, err := createSubscription(models.SubscriptionTypeReport, p.ReportParams); err == nil { - return report.NewSubscribeReportCreated().WithPayload(resp) + // Subscription: Subscribe + api.CommonSubscribeHandler = common.SubscribeHandlerFunc( + func(params common.SubscribeParams) middleware.Responder { + if resp, err := createSubscription(params.SubscriptionParams); err == nil { + return common.NewSubscribeCreated().WithPayload(resp) } - return report.NewSubscribeReportInternalServerError() + return common.NewSubscribeInternalServerError() }) - // SubscriptionType: Policy - api.PolicySubscribePolicyHandler = policy.SubscribePolicyHandlerFunc( - func(p policy.SubscribePolicyParams) middleware.Responder { - if resp, err := createSubscription(models.SubscriptionTypePolicy, p.PolicyParams); err == nil { - return policy.NewSubscribePolicyCreated().WithPayload(resp) - } - return policy.NewSubscribePolicyInternalServerError() - }) - - // SubscriptionType: Delete + // Subscription: Unsubscribe api.CommonUnsubscribeHandler = common.UnsubscribeHandlerFunc( func(p common.UnsubscribeParams) middleware.Responder { if err := delSubscription(p.SubscriptionID); err == nil { @@ -151,16 +134,6 @@ func (r *Subscriber) Listen(createSubscription SubscriptionHandler, getSubscript return common.NewUnsubscribeInternalServerError() }) - // XApp: Get Config - /*api.XappGetXappConfigListHandler = xapp.GetXappConfigListHandlerFunc( - func(p xapp.GetXappConfigListParams) middleware.Responder { - Logger.Info("Hitting xapp config") - if resp,err := r.getXappConfig(); err == nil { - return xapp.NewGetXappConfigListOK().WithPayload(resp) - } - return xapp.NewGetXappConfigListInternalServerError() - })*/ - server := restapi.NewServer(api) defer server.Shutdown() server.Host = r.localAddr @@ -174,16 +147,14 @@ func (r *Subscriber) Listen(createSubscription SubscriptionHandler, getSubscript } // Server interface: send notification to client -func (r *Subscriber) Notify(resp *models.SubscriptionResponse, clientEndpoint string) (err error) { +func (r *Subscriber) Notify(resp *models.SubscriptionResponse, ep models.SubscriptionParamsClientEndpoint) (err error) { respData, err := json.Marshal(resp) if err != nil { Logger.Error("json.Marshal failed: %v", err) return err } - ep, _, _ := net.SplitHostPort(clientEndpoint) - _, port, _ := net.SplitHostPort(fmt.Sprintf(":%d", GetPortData("http").Port)) - clientUrl := fmt.Sprintf("http://%s:%s%s", ep, port, r.clientUrl) + clientUrl := fmt.Sprintf("http://%s:%d%s", ep.ServiceName, ep.Port, r.clientUrl) retries := viper.GetInt("subscription.retryCount") if retries == 0 { @@ -218,21 +189,10 @@ func (r *Subscriber) SetResponseCB(c SubscriptionResponseCallback) { r.clientCB = c } -// Subscription interface for xApp: REPORT -func (r *Subscriber) SubscribeReport(p *apimodel.ReportParams) (*apimodel.SubscriptionResponse, error) { - params := apireport.NewSubscribeReportParamsWithTimeout(r.timeout).WithReportParams(p) - result, err := r.CreateTransport().Report.SubscribeReport(params) - if err != nil { - return &apimodel.SubscriptionResponse{}, err - } - - return result.Payload, err -} - -// Subscription interface for xApp: POLICY -func (r *Subscriber) SubscribePolicy(p *apimodel.PolicyParams) (*apimodel.SubscriptionResponse, error) { - params := apipolicy.NewSubscribePolicyParamsWithTimeout(r.timeout).WithPolicyParams(p) - result, err := r.CreateTransport().Policy.SubscribePolicy(params) +// Subscription interface for xApp +func (r *Subscriber) Subscribe(p *apimodel.SubscriptionParams) (*apimodel.SubscriptionResponse, error) { + params := apicommon.NewSubscribeParamsWithTimeout(r.timeout).WithSubscriptionParams(p) + result, err := r.CreateTransport().Common.Subscribe(params) if err != nil { return &apimodel.SubscriptionResponse{}, err } @@ -241,7 +201,7 @@ func (r *Subscriber) SubscribePolicy(p *apimodel.PolicyParams) (*apimodel.Subscr } // Subscription interface for xApp: DELETE -func (r *Subscriber) UnSubscribe(subId string) error { +func (r *Subscriber) Unsubscribe(subId string) error { params := apicommon.NewUnsubscribeParamsWithTimeout(r.timeout).WithSubscriptionID(subId) _, err := r.CreateTransport().Common.Unsubscribe(params) diff --git a/pkg/xapp/subscription_test.go b/pkg/xapp/subscription_test.go index 430b0a2..dc0a171 100755 --- a/pkg/xapp/subscription_test.go +++ b/pkg/xapp/subscription_test.go @@ -8,49 +8,96 @@ package xapp import ( "fmt" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" "github.com/stretchr/testify/assert" "testing" "time" ) -var suite *testing.T - -var meid = "gnb123456" -var funId = int64(1) -var clientEndpoint = "localhost:4560" -var direction = int64(0) -var procedureCode = int64(27) -var typeOfMessage = int64(1) - -var reportParams = clientmodel.ReportParams{ - Meid: meid, - RANFunctionID: &funId, - ClientEndpoint: &clientEndpoint, - EventTriggers: clientmodel.EventTriggerList{ - &clientmodel.EventTrigger{ - InterfaceDirection: direction, - ProcedureCode: procedureCode, - TypeOfMessage: typeOfMessage, - }, - }, +var ( + suite *testing.T + + meid = "gnb123456" + reqId = int64(1) + seqId = int64(1) + funId = int64(1) + actionId = int64(1) + actionType = "report" + subsequestActioType = "continue" + timeToWait = "w10ms" + port = int64(4560) + clientEndpoint = clientmodel.SubscriptionParamsClientEndpoint{ServiceName: "localhost", Port: &port} + direction = int64(0) + procedureCode = int64(27) + typeOfMessage = int64(1) + subscriptionId = "" +) + +// Test cases +func TestSetup(t *testing.T) { + suite = t + + // Start the server to simulate SubManager + go Subscription.Listen(subscriptionHandler, queryHandler, deleteHandler) + time.Sleep(time.Duration(2) * time.Second) +} + +func TestSubscriptionQueryHandling(t *testing.T) { + resp, err := Subscription.QuerySubscriptions() + + assert.Equal(t, err, nil) + assert.Equal(t, resp[0].SubscriptionID, int64(11)) + assert.Equal(t, resp[0].Meid, "Test-Gnb") + assert.Equal(t, resp[0].Endpoint, []string{"127.0.0.1:4056"}) } -var policyParams = clientmodel.PolicyParams{ - Meid: &meid, - RANFunctionID: &funId, - ClientEndpoint: &clientEndpoint, - EventTriggers: clientmodel.EventTriggerList{ - &clientmodel.EventTrigger{ - InterfaceDirection: direction, - ProcedureCode: procedureCode, - TypeOfMessage: typeOfMessage, +func TestSubscriptionHandling(t *testing.T) { + subscriptionParams := clientmodel.SubscriptionParams{ + Meid: &meid, + RANFunctionID: &funId, + ClientEndpoint: &clientEndpoint, + RequestorID: &reqId, + InstanceID: &seqId, + SubscriptionDetails: clientmodel.SubscriptionDetailsList{ + &clientmodel.SubscriptionDetails{ + EventTriggerList: &clientmodel.EventTriggerDefinition{ + OctetString: "1234", + }, + ActionToBeSetupList: clientmodel.ActionsToBeSetup{ + &clientmodel.ActionToBeSetup{ + ActionID: &actionId, + ActionType: &actionType, + ActionDefinition: &clientmodel.ActionDefinition{ + OctetString: "5678", + }, + SubsequentAction: &clientmodel.SubsequentAction{ + SubsequentActionType: &subsequestActioType, + TimeToWait: &timeToWait, + }, + }, + }, + }, }, - }, - PolicyActionDefinitions: &clientmodel.PolicyActionDefinition{}, + } + + Subscription.SetResponseCB(func(resp *clientmodel.SubscriptionResponse) { + assert.Equal(t, len(resp.SubscriptionInstances), 1) + assert.Equal(t, *resp.SubscriptionInstances[0].RequestorID, int64(11)) + assert.Equal(t, *resp.SubscriptionInstances[0].InstanceID, int64(22)) + }) + + _, err := Subscription.Subscribe(&subscriptionParams) + assert.Equal(t, err, nil) +} + +func TestSubscriptionDeleteHandling(t *testing.T) { + err := Subscription.Unsubscribe(subscriptionId) + fmt.Println(err) + assert.Equal(t, err, nil) } +// Helper functions func processSubscriptions(subscriptionId string) { // Generate requestorId, instanceId reqId := int64(11) @@ -59,31 +106,37 @@ func processSubscriptions(subscriptionId string) { resp := &models.SubscriptionResponse{ SubscriptionID: &subscriptionId, SubscriptionInstances: []*models.SubscriptionInstance{ - {RequestorID: &reqId, InstanceID: &instanceId}, + { + RequestorID: &reqId, + InstanceID: &instanceId, + }, }, } // Notify the client: don't worry about errors ... Notify() will handle retries, etc. - Subscription.Notify(resp, clientEndpoint) + Subscription.Notify(resp, models.SubscriptionParamsClientEndpoint{ServiceName: "localhost", Port: &port}) } -func subscriptionHandler(stype models.SubscriptionType, params interface{}) (*models.SubscriptionResponse, error) { - switch stype { - case models.SubscriptionTypeReport: - p := params.(*models.ReportParams) - assert.Equal(suite, meid, p.Meid) - assert.Equal(suite, funId, *p.RANFunctionID) - assert.Equal(suite, clientEndpoint, *p.ClientEndpoint) - assert.Equal(suite, direction, p.EventTriggers[0].InterfaceDirection) - assert.Equal(suite, procedureCode, p.EventTriggers[0].ProcedureCode) - assert.Equal(suite, typeOfMessage, p.EventTriggers[0].TypeOfMessage) - case models.SubscriptionTypePolicy: - p := params.(*models.PolicyParams) - assert.Equal(suite, clientEndpoint, *p.ClientEndpoint) - } +func subscriptionHandler(params interface{}) (*models.SubscriptionResponse, error) { + p := params.(*models.SubscriptionParams) + + assert.Equal(suite, meid, *p.Meid) + assert.Equal(suite, funId, *p.RANFunctionID) + assert.Equal(suite, clientEndpoint.ServiceName, p.ClientEndpoint.ServiceName) + assert.Equal(suite, clientEndpoint.Port, p.ClientEndpoint.Port) + assert.Equal(suite, reqId, *p.RequestorID) + assert.Equal(suite, seqId, *p.InstanceID) + + assert.Equal(suite, "1234", p.SubscriptionDetails[0].EventTriggerList.OctetString) + assert.Equal(suite, actionId, *p.SubscriptionDetails[0].ActionToBeSetupList[0].ActionID) + assert.Equal(suite, actionType, *p.SubscriptionDetails[0].ActionToBeSetupList[0].ActionType) + + assert.Equal(suite, subsequestActioType, *p.SubscriptionDetails[0].ActionToBeSetupList[0].SubsequentAction.SubsequentActionType) + assert.Equal(suite, timeToWait, *p.SubscriptionDetails[0].ActionToBeSetupList[0].SubsequentAction.TimeToWait) + assert.Equal(suite, "5678", p.SubscriptionDetails[0].ActionToBeSetupList[0].ActionDefinition.OctetString) // Generate a unique subscriptionId - subscriptionId := fmt.Sprintf("%s-%s", meid, clientEndpoint) + subscriptionId = fmt.Sprintf("%s-%s", meid, clientEndpoint.ServiceName) // Process subscriptions on the background go processSubscriptions(subscriptionId) @@ -102,57 +155,10 @@ func queryHandler() (models.SubscriptionList, error) { Endpoint: []string{"127.0.0.1:4056"}, }, } - return resp, nil } func deleteHandler(ep string) error { - assert.Equal(suite, clientEndpoint, ep) - + assert.Equal(suite, subscriptionId, ep) return nil } - -func TestSetup(t *testing.T) { - suite = t - - // Start the server to simulate SubManager - go Subscription.Listen(subscriptionHandler, queryHandler, deleteHandler) - time.Sleep(time.Duration(2) * time.Second) -} - -func TestSubscriptionQueryHandling(t *testing.T) { - resp, err := Subscription.QuerySubscriptions() - - assert.Equal(t, err, nil) - assert.Equal(t, resp[0].SubscriptionID, int64(11)) - assert.Equal(t, resp[0].Meid, "Test-Gnb") - assert.Equal(t, resp[0].Endpoint, []string{"127.0.0.1:4056"}) -} - -func TestSubscriptionReportHandling(t *testing.T) { - Subscription.SetResponseCB(func(resp *clientmodel.SubscriptionResponse) { - assert.Equal(t, len(resp.SubscriptionInstances), 1) - assert.Equal(t, *resp.SubscriptionInstances[0].RequestorID, int64(11)) - assert.Equal(t, *resp.SubscriptionInstances[0].InstanceID, int64(22)) - }) - - _, err := Subscription.SubscribeReport(&reportParams) - assert.Equal(t, err, nil) -} - -func TestSubscriptionPolicytHandling(t *testing.T) { - Subscription.SetResponseCB(func(resp *clientmodel.SubscriptionResponse) { - assert.Equal(t, len(resp.SubscriptionInstances), 1) - assert.Equal(t, *resp.SubscriptionInstances[0].RequestorID, int64(11)) - assert.Equal(t, *resp.SubscriptionInstances[0].InstanceID, int64(22)) - }) - - _, err := Subscription.SubscribePolicy(&policyParams) - assert.Equal(t, err, nil) -} - -func TestSubscriptionDeleteHandling(t *testing.T) { - err := Subscription.UnSubscribe(clientEndpoint) - - assert.Equal(t, err, nil) -} diff --git a/pkg/xapp/xapp.go b/pkg/xapp/xapp.go index de355fb..ab5aeb6 100755 --- a/pkg/xapp/xapp.go +++ b/pkg/xapp/xapp.go @@ -91,13 +91,13 @@ func registerXapp() { for { time.Sleep(5 * time.Second) if !IsHealthProbeReady() { - Logger.Info("xApp is not ready yet, waiting ...") + Logger.Info("Application='%s' is not ready yet, waiting ...", viper.GetString("name")) continue } - Logger.Info("xApp is now up and ready, continue with registration ...") + Logger.Debug("Application='%s' is now up and ready, continue with registration ...", viper.GetString("name")) if err := doRegister(); err == nil { - Logger.Info("xApp registration done, proceeding with startup ...") + Logger.Info("Registration done, proceeding with startup ...") break } } @@ -243,7 +243,10 @@ func init() { } else { Logger.SetLevel(viper.GetInt("logger.level")) } - Logger.SetFormat(0) + + if !viper.IsSet("controls.logger.noFormat") || !viper.GetBool("controls.logger.noFormat") { + Logger.SetFormat(0) + } Resource = NewRouter() Config = Configurator{}