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

definitions:

  Link:
    description: >
      This type represents a link to a resource.
    type: object
    required:
      - href
    properties:
      href:
        description: >
          URI of the referenced resource.
        type: string
        format: url

  Version:
    description: >
      A version.
    type: string

  MacAddress:
    description: >
      A MAC address. Representation: string that consists of groups of two hexadecimal digits, separated by hyphens or colons.
    type: string
    format: MAC

  IpAddress:
    description: >
      An IPV4 or IPV6 address. Representation: In case of an IPV4 address, string that consists of four decimal
      integers separated by dots, each integer ranging from 0 to 255. In case of an IPV6 address, string that 
      consists of groups of zero to four hexadecimal digits, separated by colons.
    type: string
    format: IP

  DateTime:
    description: >
      Date-time stamp. 
      Representation: String formatted according to IETF RFC 3339.
    type: string
    format: "date-time"

  Identifier:
    description: >
      An identifier with the intention of being globally unique.
    type: string

  IdentifierInVim:
    description: >
      An identifier maintained by the VIM or other resource provider. It is
      expected to be unique within the VIM instance.
    type: string

  IdentifierInVnf:
    description: >
      An identifier that is unique for the respective type within a VNF
      instance, but may not be globally unique.
    type: string

  IdentifierInVnfd:
    description: >
      An identifier that is unique within a VNF descriptor.
    type: string

  KeyValuePairs:
    description: >
      This type represents a list of key-value pairs. The order of the pairs in the list is not significant.
      In JSON, a set of key- value pairs is represented as an object. It shall comply with the provisions 
      defined in clause 4 of IETF RFC 7159. 
    type: object

  Link:
    description: >
      This type represents a link to a resource.
    type: object
    required:
      - href
    properties:
      href:
        description: >
          URI of the referenced resource.
        type: string
        format: url

  ProblemDetails:
    #SOL003 location: 4.3.5.3
    description: >
      The definition of the general "ProblemDetails" data structure from
      IETF RFC 7807 [19] is reproduced inthis structure. Compared to the
      general framework defined in IETF RFC 7807 [19], the "status" and
      "detail" attributes are mandated to be included by the present document,
      to ensure that the response contains additional textual information about
      an error. IETF RFC 7807 [19] foresees extensibility of the
      "ProblemDetails" type. It is possible that particular APIs in the present
      document, or particular implementations, define extensions to define
      additional attributes that provide more information about the error.
      The description column only provides some explanation of the meaning to
      Facilitate understanding of the design. For a full description, see
      IETF RFC 7807 [19].
    type: object
    required:
      - status
      - detail
    properties:
      type:
        description: >
          A URI reference according to IETF RFC 3986 [5] that identifies the
          problem type. It is encouraged that the URI provides human-readable
          documentation for the problem (e.g. using HTML) when dereferenced.
          When this member is not present, its value is assumed to be
          "about:blank".
        type: string
        format: URI
      title:
        description: >
          A short, human-readable summary of the problem type. It should not
          change from occurrence to occurrence of the problem, except for
          purposes of localization. If type is given and other than
          "about:blank", this attribute shall also be provided.
          A short, human-readable summary of the problem
          type.  It SHOULD NOT change from occurrence to occurrence of the
          problem, except for purposes of localization (e.g., using
          proactive content negotiation; see [RFC7231], Section 3.4).
        type: string
      status:
        description: >
          The HTTP status code for this occurrence of the problem.
          The HTTP status code ([RFC7231], Section 6) generated by the origin
          server for this occurrence of the problem.
        type: integer
      detail:
        description: >
          A human-readable explanation specific to this occurrence of the
          problem.
        type: string
      instance:
        description: >
          A URI reference that identifies the specific occurrence of the
          problem. It may yield further information if dereferenced.
        type: string
        format: URI
      #TODO: How to express "any additional attributes"?

  ResourceHandle:
    required:
      - vimConnectionId
      - resourceId
    type: object
    description: >
      This type represents the information that allows addressing a virtualised
      resource that is used by a VNF instance. Information about the resource
      is available from the VIM.
    properties:
      vimConnectionId:
        description: >
          Identifier of the VIM connection to manage the resource. This
          attribute shall only be supported and present if VNF-related resource
          management in direct mode is applicable. The applicable
          "VimConnectionInfo" structure, which is referenced by
          vimConnectionId, can be obtained from the "vimConnectionInfo"
          attribute of the "VnfInstance" structure.
        $ref: "#/definitions/Identifier"
      resourceProviderId:
        description: >
          Identifier of the entity responsible for the management of the
          resource. This attribute shall only be supported and present when
          VNF-related resource management in indirect mode is applicable. The
          identification scheme is outside the scope of the present document.
        $ref: "#/definitions/Identifier"
      resourceId:
        description: >
          Identifier of the resource in the scope of the VIM or the resource
          provider.
        $ref: "#/definitions/IdentifierInVim"
      vimLevelResourceType:
        description: >
          Type of the resource in the scope of the VIM or the resource
          provider.
        type: string
        #TODO: Note of Table 4.4.1.7-1

  SubscriptionAuthentication:
    type: object
    required: 
      - authType
    properties: 
      authType:
        description: >
          Defines the type of Authentication / Authorization to use when
          sending a notification. 
          Permitted values:
          * BASIC: In every POST request that sends a notification, use
            HTTP Basic authentication with the client credentials.
          * OAUTH2_CLIENT_CREDENTIALS: In every POST request that sends a
            notification, use an OAuth 2.0 Bearer token, obtained using the
            client credentials grant type.
        type: string
        enum:
          - BASIC
          - OAUTH2_CLIENT_CREDENTIALS
      paramsBasic:
        description: >
          Parameters for authentication/authorization using BASIC.
          Shall be present if authType is "BASIC" and the contained
          information has not been provisioned out of band.
          Shall be absent otherwise.
        type: object
        properties:
          userName:
            description: >
              Username to be used in HTTP Basic authentication. Shall be
              present if it has not been provisioned out of band.
            type: string
          password:
            description: >
              Password to be used in HTTP Basic authentication. Shall be
              present if it has not been provisioned out of band.
            type: string
      paramsOauth2ClientCredentials:
        description: >
          Parameters for authentication/authorization using
          OAUTH2_CLIENT_CREDENTIALS.
          Shall be present if authType is "OAUTH2_CLIENT_CREDENTIALS" and the
          contained information has not been provisioned out of band.
          Shall be absent otherwise.
        type: object
        properties:
          clientId:
            description: >
              Client identifier to be used in the access token request of the
              OAuth 2.0 client credentials grant type. 
              Shall be present if it has not been provisioned out of band.
              The clientId and clientPassword passed in a subscription shall
              not be the same as the clientId and clientPassword that are used
              to obtain authorization for API requests. Client credentials may
              differ between subscriptions. The value of clientPassword should
              be generated by a random process.
            type: string
          clientPassword:
            description: >
              Client password to be used in the access token request of the
              OAuth 2.0 client credentials grant type. 
              Shall be present if it has not been provisioned out of band.
              The clientId and clientPassword passed in a subscription shall
              not be the same as the clientId and clientPassword that are used
              to obtain authorization for API requests. Client credentials may
              differ between subscriptions. The value of clientPassword should
              be generated by a random process.
            type: string
          tokenEndpoint:
            description: >
              The token endpoint from which the access token can be obtained.
              Shall be present if it has not been provisioned out of band.
            $ref: "#/definitions/Uri"

  Uri:
    description: >
      String formatted according to IETF RFC 3986.
    type: string

  VnfInstanceSubscriptionFilter:
    description: >
      This type represents subscription filter criteria to match VNF
      instances.
    type: object
    properties:
      vnfdIds:
        description: >
          If present, match VNF instances that were created based on a VNFD
          identified by one of the vnfdId values listed in this attribute.
          The attributes "vnfdIds" and "vnfProductsFromProviders" are
          alternatives to reference to VNF instances that are based on certain
          VNFDs in a filter. They should not be used both in the same filter
          instance, but one alternative should be chosen.
        type: array
        items:
          $ref: "#/definitions/Identifier"
      vnfProductsFromProviders:
        description: >
          If present, match VNF instances that belong to VNF products from
          certain providers.
          The attributes "vnfdIds" and "vnfProductsFromProviders" are
          alternatives to reference to VNF instances that are based on certain
          VNFDs in a filter. They should not be used both in the same filter
          instance, but one alternative should be chosen.
        type: array
        items:
          type: object
          required:
            - vnfProvider
          properties:
            vnfProvider:
              description: >
                Name of the VNF provider to match.
              type: string
            vnfProducts:
              description: >
                If present, match VNF instances that belong to VNF products
                with certain product names, from one particular provider.
              type: array
              items: 
                type: object
                required:
                  - vnfProductName
                properties:
                  vnfProductName:
                    description: >
                      Name of the VNF product to match.
                    type: string
                  versions:
                    description: >
                      If present, match VNF instances that belong to VNF
                      products with certain versions and a certain product
                      name, from one particular provider.
                    type: array
                    items:
                      type: object
                      required:
                        - vnfSoftwareVersions
                      properties:
                        vnfSoftwareVersions:
                          description: >
                            Software version to match.
                          $ref: "#/definitions/Version"
                        vnfdVersions:
                          description: >
                            If present, match VNF instances that belong to VNF
                            products with certain VNFD versions, a certain
                            software version and a certain product name, from
                            one particular provider.
                          type: array
                          items: 
                            $ref: "#/definitions/Version"
  Version:
    description: >
      A Version.
    type: string
