openapi: 3.0.0
info:
  description: Policy Control Event Exposure Service API
  version: "1.0.0"
  title: Npcf_EventExposure
externalDocs:
  description: 3GPP TS 29.523 V15.0.0; 5G System; Policy Control Event Exposure Service; Stage 3.
  url: http://www.3gpp.org/ftp/Specs/archive/29_series/29.523/

servers:
  - url: '{apiRoot}/npcf-eventexposure/v1'
    variables:
      apiRoot:
        default: https://example.com
        description: apiRoot as defined in subclause 4.4 of 3GPP TS 29.501
        
security:
  - {}
  - oAuth2ClientCredentials:
    - npcf-eventexposure

paths:
  /subscriptions:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PcEventExposureSubsc'
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcEventExposureSubsc'
          headers:
            Location:
              description: 'Contains the URI of the created individual policy control events subscription resource, according to the structure: {apiRoot}/npcf-eventexposure/v1/subscriptions/{subscriptionId}'
              required: true
              schema:
                type: string
        '400':
          $ref: 'TS29571_CommonData.yaml#/components/responses/400'
        '401':
          $ref: 'TS29571_CommonData.yaml#/components/responses/401'
        '403':
          $ref: 'TS29571_CommonData.yaml#/components/responses/403'
        '404':
          $ref: 'TS29571_CommonData.yaml#/components/responses/404'
        '411':
          $ref: 'TS29571_CommonData.yaml#/components/responses/411'
        '413':
          $ref: 'TS29571_CommonData.yaml#/components/responses/413'
        '415':
          $ref: 'TS29571_CommonData.yaml#/components/responses/415'
        '429':
          $ref: 'TS29571_CommonData.yaml#/components/responses/429'
        '500':
          $ref: 'TS29571_CommonData.yaml#/components/responses/500'
        '503':
          $ref: 'TS29571_CommonData.yaml#/components/responses/503'
        default:
          $ref: 'TS29571_CommonData.yaml#/components/responses/default'
      callbacks:
        PcEventNotification:
          '{$request.body#/notifUri}': 
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/PcEventExposureNotif'
              responses:
                '204':
                  description: No Content, Notification was succesfull
                '400':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/400'
                '401':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/401'
                '403':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/403'
                '404':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/404'
                '411':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/411'
                '413':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/413'
                '415':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/415'
                '429':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/429'
                '500':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/500'
                '503':
                  $ref: 'TS29571_CommonData.yaml#/components/responses/503'
                default:
                  $ref: 'TS29571_CommonData.yaml#/components/responses/default'
  /subscriptions/{subscriptionId}:
    get:
      parameters:
        - name: subscriptionId
          in: path
          description: Policy Control Event Subscription ID
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK. Resource representation is returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcEventExposureSubsc'
        '400':
          $ref: 'TS29571_CommonData.yaml#/components/responses/400'
        '401':
          $ref: 'TS29571_CommonData.yaml#/components/responses/401'
        '403':
          $ref: 'TS29571_CommonData.yaml#/components/responses/403'
        '404':
          $ref: 'TS29571_CommonData.yaml#/components/responses/404'
        '406':
          $ref: 'TS29571_CommonData.yaml#/components/responses/406'
        '429':
          $ref: 'TS29571_CommonData.yaml#/components/responses/429'
        '500':
          $ref: 'TS29571_CommonData.yaml#/components/responses/500'
        '503':
          $ref: 'TS29571_CommonData.yaml#/components/responses/503'
        default:
          $ref: 'TS29571_CommonData.yaml#/components/responses/default'
    put:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PcEventExposureSubsc'
      parameters:
        - name: subscriptionId
          in: path
          description: Policy Control Event Subscription ID
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK. Resource was succesfully modified and representation is returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PcEventExposureSubsc'
        '204':
          description: No Content. Resource was succesfully modified
        '400':
          $ref: 'TS29571_CommonData.yaml#/components/responses/400'
        '401':
          $ref: 'TS29571_CommonData.yaml#/components/responses/401'
        '403':
          $ref: 'TS29571_CommonData.yaml#/components/responses/403'
        '404':
          $ref: 'TS29571_CommonData.yaml#/components/responses/404'
        '411':
          $ref: 'TS29571_CommonData.yaml#/components/responses/411'
        '413':
          $ref: 'TS29571_CommonData.yaml#/components/responses/413'
        '415':
          $ref: 'TS29571_CommonData.yaml#/components/responses/415'
        '429':
          $ref: 'TS29571_CommonData.yaml#/components/responses/429'
        '500':
          $ref: 'TS29571_CommonData.yaml#/components/responses/500'
        '503':
          $ref: 'TS29571_CommonData.yaml#/components/responses/503'
        default:
          $ref: 'TS29571_CommonData.yaml#/components/responses/default'
    delete:
      parameters:
        - name: subscriptionId
          in: path
          description: Policy Control Event Subscription ID
          required: true
          schema:
            type: string
      responses:
        '204':
          description: No Content. Resource was succesfully deleted
        '400':
          $ref: 'TS29571_CommonData.yaml#/components/responses/400'
        '401':
          $ref: 'TS29571_CommonData.yaml#/components/responses/401'
        '403':
          $ref: 'TS29571_CommonData.yaml#/components/responses/403'
        '404':
          $ref: 'TS29571_CommonData.yaml#/components/responses/404'
        '429':
          $ref: 'TS29571_CommonData.yaml#/components/responses/429'
        '500':
          $ref: 'TS29571_CommonData.yaml#/components/responses/500'
        '503':
          $ref: 'TS29571_CommonData.yaml#/components/responses/503'
        default:
          $ref: 'TS29571_CommonData.yaml#/components/responses/default'


components:
  securitySchemes:
    oAuth2ClientCredentials:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: '{nrfApiRoot}/oauth2/token'
          scopes:
            npcf-eventexposure: Access to the Npcf_EventExposure API.

  schemas:
  
    PcEventExposureNotif:
      type: object
      properties:
        notifId:
          type: string
        eventNotifs:
          type: array
          items:
            $ref: '#/components/schemas/PcEventNotification'
          minItems: 1
      required:
        - notifId
        - eventNotifs

          
    PcEventExposureSubsc:
      type: object
      properties:
        eventSubscs:
          type: array
          items:
            $ref: '#/components/schemas/PcEvent'
          minItems: 1
        eventsRepInfo:
          $ref: '#/components/schemas/ReportingInformation'
        groupId:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/GroupId'
        filterDnns:
          type: array
          items:
            $ref: 'TS29571_CommonData.yaml#/components/schemas/Dnn'
          minItems: 1
        filterSnssais:
          type: array
          items:
            $ref: 'TS29571_CommonData.yaml#/components/schemas/Snssai'
          minItems: 1
        filterServices:
          type: array
          items:
            $ref: '#/components/schemas/ServiceIdentification'
          minItems: 1
        notifUri:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/Link'
        notifId:
          type: string
        suppFeat:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/SupportedFeatures'
      required:
        - eventSubs
        - notifId
        - notifUri
        
    ReportingInformation:
      type: object
      properties:
        immRep: 
          type: boolean
        notifMethod:
          $ref: 'TS29508_Nsmf_EventExposure.yaml#/components/schemas/NotificationMethod'
        maxReportNbr:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/Uinteger'
        monDur:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/DateTime'
        repPeriod:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/DurationSec'
          
    ServiceIdentification:
      type: object
      properties:
        servEthFlows:
          type: array
          items:
            $ref: '#/components/schemas/EthernetFlowInfo'
          minItems: 1
        servIpFlows:
          type: array
          items:
            $ref: '#/components/schemas/IpFlowInfo'
          minItems: 1
        afAppId:
          $ref: 'TS29514_Npcf_PolicyAuthorization.yaml#/components/schemas/AfAppId'
            
    EthernetFlowInfo:
      type: object
      properties:
        ethFlows: 
          type: array
          items:
            $ref: 'TS29514_Npcf_PolicyAuthorization.yaml#/components/schemas/EthFlowDescription'
          minItems: 1
          maxItems: 2
        flowNumber:
          type: integer
      required:
        - flowNumber
    
    IpFlowInfo:
      type: object
      properties:
        ipFlows:
          type: array
          items:
            $ref: 'TS29514_Npcf_PolicyAuthorization.yaml#/components/schemas/FlowDescription'
          minItems: 1
          maxItems: 2
        flowNumber:
          type: integer
      required:
        - flowNumber
        
    PcEventNotification:
      type: object
      properties:
        event:
          $ref: '#/components/schemas/PcEvent'
        accType:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/AccessType'
        ratType: 
          $ref: 'TS29571_CommonData.yaml#/components/schemas/RatType'
        plmnId:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/PlmnId'
        timeStamp:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/DateTime'
        pduSessionInfo:
          $ref: '#/components/schemas/PduSessionInformation'
        repServices:
          $ref: '#/components/schemas/ServiceIdentification'
      required:
        - event
        - timeStamp
        
    PduSessionInformation:
      type: object
      properties:
        snssai:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/Snssai'
        dnn:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/Dnn'
        ueIpv4:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/Ipv4Addr'
        ueIpv6:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/Ipv6Prefix'
        ipDomain:
          type: string
        ueMac:
          $ref: 'TS29571_CommonData.yaml#/components/schemas/MacAddr48'
      required:
        - snssai
        - dnn

# Simple data types and Enumerations

    PcEvent:
      anyOf:
      - type: string
        enum:
          - AC_TY_CH
          - PLMN_CH
      - type: string