Skip to content

feat: extend Nsmf_EventExposure models and add Nupf_EventExposure client#77

Open
haha39 wants to merge 3 commits into
free5gc:mainfrom
Intelligent-Systems-Lab:feat/smf-event-exposure-openapi
Open

feat: extend Nsmf_EventExposure models and add Nupf_EventExposure client#77
haha39 wants to merge 3 commits into
free5gc:mainfrom
Intelligent-Systems-Lab:feat/smf-event-exposure-openapi

Conversation

@haha39

@haha39 haha39 commented Jun 20, 2026

Copy link
Copy Markdown

Summary

This PR extends the existing Nsmf_EventExposure models with fields needed to
represent the targeted UPF event subscription flow and adds Nupf_EventExposure
models and client operations for creating and deleting subscriptions.

It also adds an optional per-configuration redirect policy to the shared
runtime and enables Nupf_EventExposure configurations to select reject-all
behavior without changing the default behavior of other APIs.

Motivation

The current module provides Nsmf_EventExposure support but does not include the
Nsmf UPF-event forwarding fields or a Nupf_EventExposure client. These additions
are needed for an SMF to create the corresponding subscription on the selected
UPF.

Changes

  • Add UPF_EVENT to SmfEvent.
  • Extend SmfEventExposureEventSubscription with:
    • upfEvents
    • bundlingAllowed
    • bundleId
    • bundledEventNotifyUri
  • Add the targeted Nupf_EventExposure models used by the Create and Delete
    subscription paths.
  • Add ServiceName_NUPF_EE.
  • Add client operations for:
    • POST /ee-subscriptions
    • DELETE /ee-subscriptions/{subscriptionId}
  • Handle the specified success, ProblemDetails, redirect, and default error
    responses.
  • Preserve the Create request subscription wrapper.
  • Reuse compatible shared models, including IpAddr, Snssai,
    ProblemDetails, and RedirectResponse.
  • Add the general-purpose RedirectPolicy, RedirectPolicyProvider, and
    RejectRedirects runtime API.
  • Allow Nupf_EventExposure configurations to opt into redirect rejection while
    keeping their default policy nil.
  • Apply configured policies through a request-local HTTP client value while
    preserving the selected client's Transport, Timeout, and Jar, as well as
    existing metrics hook behavior.

Specification Scope

This is a targeted addition based on:

  • 3GPP TS 29.508 V19.4.0
  • 3GPP TS 29.564 V19.5.0
  • 3GPP TS 29.571 V19.5.0 common data types

It does not perform a broad Rel-19 regeneration or modify unrelated APIs.
Existing Nsmf_EventExposure behavior remains backward-compatible.

OpenAPI Generator v7.12.0 output was used as a wire-shape reference. Raw
generator output is not included in this PR. The final package layout and shared
model reuse follow the existing free5gc/openapi structure.

The Upf* prefix follows nearby service-specific naming patterns and avoids
collisions in the shared models package. The exact naming remains open to
maintainer feedback.

BundleId uses *uint32 to preserve the distinction between omission and
"bundleId": 0, represent the complete TS 29.571 Uint32 range, and reject
negative or above-range JSON values.

Redirect Behavior

Configurations that do not provide a redirect policy, or provide a nil policy,
retain the existing redirect behavior. This includes the default
Nupf_EventExposure configuration.

With Go's default HTTP redirect policy, replayable Create POST requests
receiving 307 or 308 are followed and the final response is returned.

Callers can explicitly configure Nupf_EventExposure with:

configuration.SetRedirectPolicy(openapi.RejectRedirects)

The shared runtime then uses a request-local http.Client value that preserves
the selected client's Transport, Timeout, and Jar, as well as existing metrics
hook behavior, while replacing only CheckRedirect. It does not mutate the
original client, shared clients, or their transports.

With redirect rejection enabled, Create and Delete receive the original
307/308 response and return a GenericOpenAPIError whose model exposes
RedirectResponse, Location, and 3gpp-Sbi-Target-Nf-Id. No request is sent
to the redirect target, and the Create body is not replayed.

The runtime hook is general-purpose. In this PR, the generated-style opt-in
setter is exposed only by the Nupf_EventExposure configuration.

Intentional Omissions

The following areas are outside this focused change:

  • subscription modification
  • event notification callback or receiver support
  • CreatedEventSubscription.reportList
  • NotificationItem and its dependent report schema graph
  • Nsmf flowDescs
  • optional event and reporting fields not required by the targeted SMF
    Create/Delete subscription flow

Tests

Added focused model and client tests covering:

  • exact Nsmf and Nupf JSON wire shapes and enum values
  • the outer Create request subscription wrapper
  • TS 29.571 IpAddr serialization
  • BundleId serialization at 0 and 4294967295
  • rejection of BundleId JSON values below 0 or above 4294967295
  • omission of prohibited bundlingAllowed: false
  • Create and Delete status matrices
  • ProblemDetails, redirect, and default response handling
  • unchanged default following when the provider is absent or its policy is nil
  • preservation of explicit-client precedence, Transport, Timeout, Jar, and
    existing metrics hook behavior
  • no mutation of original or shared HTTP clients
  • concurrent follow and no-follow behavior under the race detector
  • configuration-driven Create and Delete 307/308 rejection
  • typed redirect metadata and Location and 3gpp-Sbi-Target-Nf-Id headers
  • zero requests to redirect targets and no Create-body replay
  • default redirect following and replay of the Create POST body

Validation

Validation environment:

Go 1.26.2

Formatting and diff checks:

  • gofmt -l against all changed Go files returned no output.
  • git diff --check passed.

Build and test commands:

GOPROXY=off go build -v ./...
GOPROXY=off go test -count=1 -v ./...
GOPROXY=off go test -race -count=1 ./...

Focused race validation:

GOPROXY=off go test -race -count=1 . ./upf/EventExposure

Related Issue

Related to #75.

Thank you for reviewing this contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant