# Copyright (c) ETSI 2017.
# https://forge.etsi.org/etsi-forge-copyright-notice.txt

definitions:
  PmSubscriptionRequest:
    description: >
      This type represents a subscription request.
    type: object
    required:
      - callbackUri
    properties:
      filter:
        description: >
          Filter settings for this subscription, to define the subset of
          all notifications this subscription relates to. A particular
          notification is sent to the subscriber if the filter matches,
          or if there is no filter.
        $ref: "#/definitions/PmNotificationsFilter"
      callbackUri:
        description: >
          The URI of the endpoint to send the notification to.
        $ref: "../../definitions/SOL005_def.yaml#/definitions/Uri"
      authentication:
        description: >
          Authentication parameters to conFigure the use of
          Authorization when sending notifications corresponding
          to this subscription, as defined in clause 4.5.3.4.
          This attribute shall only be present if the subscriber
          requires authorization of notifications..
        $ref: "../../definitions/SOL005_def.yaml#/definitions/SubscriptionAuthentication"

  PmSubscription:
    description: >
      This type represents a subscription.
    type: object
    required:
      - id
      - callbackUri
      - _links
    properties:
      id:
        description: >
          Identifier that identifies the subscription.
        $ref: "../../definitions/SOL005_def.yaml#/definitions/Identifier"
      filter:
        description: >
          Filter settings for this subscription, to define the subset of all
          notifications this subscription relates to. A particular
          notification is sent to the subscriber if the filter matches, or if
          there is no filter.
        $ref: "#/definitions/PmNotificationsFilter"
      callbackUri:
        description: >
          The URI of the endpoint to send the notification to.
        $ref: "../../definitions/SOL005_def.yaml#/definitions/Uri"
      _links:
        description: >
          Links to resources related to this resource.
        type: object
        required:
          - self
        properties:
          self:
            description: >
              URI of this resource.
            $ref: "../../definitions/SOL005_def.yaml#/definitions/Link"

  CreatePmJobRequest:
    description: >
      This type represents a request to create a PM job. 
      It shall comply with the provisions defined in Table 7.5.2.6-1.
    type: object
    required:
      - objectInstanceIds
      - criteria
    properties:
      objectInstanceIds:
        description: >
          Identifiers of the NS instances for which
          performance information is requested to be collected.
        type: "array"
        items:
          $ref: "../../definitions/SOL005_def.yaml#/definitions/Identifier"
      criteria:
        description: >
          Criteria of the collection of performance information.
        $ref: "#/definitions/PmJobCriteria"

  PmJob:
    description: >
      This type represents a PM job.
    type: object
    required:
      - id
      - objectInstanceIds
      - criteria
    properties:
      id:
        description: >
          Identifier of this PM job.
        $ref: "../../definitions/SOL005_def.yaml#/definitions/Identifier"
      objectInstanceIds:
        description: >
          Identifiers of the NS instances for which
          performance information is collected.
        type: array
        items:
          $ref: "../../definitions/SOL005_def.yaml#/definitions/Identifier"
      criteria:
        description: >
          Criteria of the collection of performance information.
        $ref: "#/definitions/PmJobCriteria"
      reports:
        description: >
          Information about available reports collected by this PM job.
        type: object
        required:
          - href
          - readyTime
          - _links
        properties:
          href:
            description: >
              The Uri where the report can be obtained.
            $ref: "../../definitions/SOL005_def.yaml#/definitions/Uri"
          readyTime:
            description: >
              The time when the report was made available.
            $ref: "../../definitions/SOL005_def.yaml#/definitions/DateTime"
          expiryTime:
            description: >
              The time when the report will expire.
            $ref: "../../definitions/SOL005_def.yaml#/definitions/DateTime"
          fileSize:
            description: >
              The size of the report file in bytes, if known.
            type: integer
          _links:
            description: >
              Links for this resource.
            type: object
            required:
              - self
            properties:
              self:
                description: >
                  URI of this resource.
                $ref: "../../definitions/SOL005_def.yaml#/definitions/Link"
              objects:
                description: >
                  Links to resources representing the NS
                  instances for which performance information is
                  collected. Shall be present if the NS instance
                  information is accessible as a resource.
                type: array
                items:
                  $ref: "../../definitions/SOL005_def.yaml#/definitions/Link"

  CreateThresholdRequest:
    description: >
      This type represents a request to create a threshold.
    type: object
    required:
      - objectInstanceId
      - criteria
    properties:
      objectInstanceId:
        description: >
          Identifier of the NS instance associated with this threshold.
        $ref: "../../definitions/SOL005_def.yaml#/definitions/Identifier"
      criteria:
        description: >
          Criteria that define this threshold.
        $ref: "#/definitions/ThresholdCriteria"

  Threshold:
    description: >
      This type represents a threshold.
    type: object
    required:
      - id
      - objectInstanceId
      - criteria
      - _links
    properties:
      id:
        description: >
          Identifier of this threshold resource.
        $ref: "../../definitions/SOL005_def.yaml#/definitions/Identifier"
      objectInstanceId:
        description: >
          Identifier of the NS instance associated with the threshold.
        $ref: "../../definitions/SOL005_def.yaml#/definitions/Identifier"
      criteria:
        description: >
          Criteria that define this threshold.
        $ref: "#/definitions/ThresholdCriteria"
      _links:
        description: >
          Links for this resource.
        type: object
        required:
          - self
        properties:
          self:
            description: >
              URI of this resource.
            $ref: "../../definitions/SOL005_def.yaml#/definitions/Link"
          object:
            description: >
              Link to a resource representing the NS instance for
              which performance information is collected. Shall be
              present if the NS instance information is accessible as
              a resource.

  PerformanceReport:
    description: >
      This type defines the format of a performance report provided by the NFVO
      to the OSS/BSS as a result of collecting
      performance information as part of a PM job.
      The type shall comply with the provisions defined in Table 7.5.2.10-1.
    type: object
    required:
      - entries
    properties:
      entries:
        description: >
          List of performance information entries. Each
          performance report entry is for a given metric of a given
          object (i.e. NS instance), but can include multiple
          collected values.
        type: array
        items:
          type: object
          required:
            - objectType
            - objectInstanceId
            - performanceMetric
            - performanceValue
          properties:
            objectType:
              description: >
                Defines the object type for which performance
                information is reported (i.e. NS type). The string value
                shall be set to the nsdId of the NS instance to which the
                performance information relates.
              type: string
            objectInstanceId:
              description: >
                The object instance for which the performance metric is
                reported.
                The object instances for this information element will be
                NS instances.
              $ref: "../../definitions/SOL005_def.yaml#/definitions/Identifier"
            performanceMetric:
              description: >
                Name of the metric collected.
              type: string
            performanceValues:
              description: >
                List of performance values with associated timestamp.
              type: array
              items:
                type: object
                required:
                  - timeStamp
                  - performanceValue
                properties:
                  timeStamp:
                    description: >
                      Time stamp indicating when the data was collected.
                    $ref: "../../definitions/SOL005_def.yaml#/definitions/DateTime"
                  value:
                    description: >
                      The type of the "performanceValue" attribute (i.e. scalar, structure (Object in JSON), or array (of scalars,
                      arrays or structures / Objects)) is outside the scope of the present document.
                    type: object

  PmNotificationsFilter:
    description: >
      This type represents a filter that can be used to subscribe for
      notifications related to performance management events. It
      shall comply with the provisions defined in Table 7.5.3.2-1.
      At a particular nesting level in the filter structure, the following applies:
      All attributes shall match in order for the filter
      to match (logical "and" between different filter attributes).
      If an attribute is an array, the attribute shall match if at least
      one of the values in the array matches (logical "or" between the values of one filter attribute).
    type: object
    properties:
      nsInstanceSubscriptionFilter:
        description: >
          Filter criteria to select NS instances about which to notify.
        $ref: "../../definitions/SOL005_def.yaml#/definitions/NsInstanceSubscriptionFilter"
      notificationTypes:
        description: >
          Match particular notification types.
          Permitted values:
          - ThresholdCrossedNotification
          - PerformanceInformationAvailableNotification
          The permitted values of the "notificationTypes" attribute are
          spelled exactly as the names of the notification types to facilitate
          automated code generation systems.
        type: array
        items:
          type: string
          enum:
            - ThresholdCrossedNotification
            - PerformanceInformationAvailableNotification

  PmJobCriteria:
    description: >
      This type represents collection criteria for PM jobs. 
      It shall comply with the provisions defined in Table 7.5.3.3-1.
    type: object
    required:
      - collectionPeriod
      - reportingPeriod
    properties:
      performanceMetric:
        description: >
          This defines the types of performance metrics
          for the specified object instances. At least one
          of the two attributes (performance metric or
          group) shall be present.
        type: array
        items:
          $ref: "../../definitions/SOL005_def.yaml#/definitions/String"
      performanceMetricGroup:
        description: >
          Group of performance metrics.
          A metric group is a pre-defined list of metrics,
          known to the producer that it can decompose to
          individual metrics. At least one of the two
          attributes (performance metric or group) shall
          be present.
        type: array
        items:
          $ref: "../../definitions/SOL005_def.yaml#/definitions/String"
      collectionPeriod:
        description: >
          Specifies the periodicity at which the producer
          will collect performance information. The unit
          shall be seconds.
          At the end of each reportingPeriod, the producer will inform the consumer about availability of the performance
          data collected for each completed collection period during this reportingPeriod. The reportingPeriod should be
          equal to or a multiple of the collectionPeriod. In the latter case, the performance data for the collection periods
          within one reporting period are reported together.    
          In particular when choosing short collection and reporting periods, the number of PM jobs that can be
          supported depends on the capability of the producing entity.
        type: integer
        minimum: 0
        default: 0
      reportingPeriod:
        description: >
          Specifies the periodicity at which the producer
          will report to the consumer.
          about performance information. The unit shall be seconds.
          At the end of each reportingPeriod, the producer will inform the consumer about availability of the performance
          data collected for each completed collection period during this reportingPeriod. The reportingPeriod should be
          equal to or a multiple of the collectionPeriod. In the latter case, the performance data for the collection periods
          within one reporting period are reported together.    
          In particular when choosing short collection and reporting periods, the number of PM jobs that can be
          supported depends on the capability of the producing entity.          
        type: integer
        minimum: 0
        default: 0
      reportingBoundary:
        description: >
          Identifies a time boundary after which the
          reporting will stop. The boundary shall allow a
          single reporting as well as periodic reporting up
          to the boundary.
        $ref: "../../definitions/SOL005_def.yaml#/definitions/DateTime"

  ThresholdCriteria:
    description: >
      This type represents criteria that define a threshold.
    type: object
    required:
      - performanceMetric
      - thresholdType
    properties:
      performanceMetric:
        description: >
          Defines the performance metric associated with the
          threshold, as specified in ETSI GS NFV-IFA 027).
        type: string
      thresholdType:
        description: >
          Type of threshold. This attribute determines which other attributes
          are present in the data structure.
          Permitted values:
          * SIMPLE: Single-valued static threshold
          In the present document, simple thresholds are defined. The
          definition of additional threshold types is left for future
          specification.
        type: string
        enum:
          - SIMPLE
      simpleThresholdDetails:
        description: >
          Details of a simple threshold. Shall be present if
          thresholdType="SIMPLE".
        type: object
        required:
          - thresholdValue
          - hysteresis
        properties:
          thresholdValue:
            description: >
              The threshold value. Shall be represented as a floating point
              number.               
            type: integer
          hysteresis:
            description: >
              The hysteresis of the threshold. Shall be represented as a
              non-negative floating point number.
              A notification with crossing direction "UP" will be generated if
              the measured value reaches or exceeds
              "thresholdValue" + "hysteresis". A notification with crossing
              direction "DOWN" will be generated if the measured value reaches
              or undercuts "thresholdValue" - "hysteresis".
              The hysteresis is defined to prevent storms of threshold
              crossing notifications. When processing a request to create a
              threshold, implementations should enforce a suitable minimum
              value for this attribute (e.g. override the value or reject the
              request).
            type: integer