openapi: 3.0.1
info:
  title: OpenWiFi RadiusEndpointTypes Provisioning Model for Global Reach
  description: Definitions and APIs to Open Roaming WiFi.
  version: 2.5.0
  license:
    name: BSD3
    url: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE

servers:
  - url: 'https://localhost:16005/api/v1'

security:
  - bearerAuth: []
  - ApiKeyAuth: []

components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

  responses:
    NotFound:
      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/NotFound'
    Unauthorized:
      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Unauthorized'
    Success:
      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Success'
    BadRequest:
      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/BadRequest'

  schemas:
    GLBLRAccountInfo:
      type: object
      properties:
        allOf:
          $ref: 'https://github.com/Telecominfraproject/wlan-cloud-owprov/blob/main/openpapi/owprov.yaml#/components/schemas/ObjectInfo'
        privateKey:
          type: string
        country:
          type: string
        province:
          type: string
        city:
          type: string
        organization:
          type: string
        commonName:
          type: string
        CSR:
          type: string
        CSRPrivateKey:
          type: string
        CSRPublicKey:
          type: string
        GlobalReachAcctId:
          type: string

    GLBLRCertificateInfo:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        accountId:
          type: string
          format: uuid
        csr:
          type: string
        certificate:
          type: string
        certificateChain:
          type: string
        certificateId:
          type: string
        expiresAt:
          type: integer
          format: int64
        created:
          type: integer
          format: int64

paths:
  /openroaming/globalreach/accounts:
    get:
      tags:
        - RadiusEndpointTypes-Global Reach
      operationId: getOpenRoamingGlobalReachAccountList
      summary: Retrieve account list.
      parameters:
        - in: query
          description: Pagination start (starts at 1. If not specified, 1 is assumed)
          name: offset
          schema:
            type: integer
          required: false
        - in: query
          description: Maximum number of entries to return (if absent, no limit is assumed)
          name: limit
          schema:
            type: integer
          required: false
        - in: query
          description: return the number of accounts
          name: countOnly
          schema:
            type: boolean
          required: false

      responses:
        200:
          description: The list of accounts
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GLBLRAccountInfo'
          $ref: '#/components/responses/Success'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

  /openroaming/globalreach/account/{name}:
    get:
      tags:
        - RadiusEndpointTypes-Global Reach
      operationId: getOpenRoamingGlobalReachAccount
      summary: Retrieve account information.
      parameters:
        - in: path
          description: The account name
          name: name
          schema:
            type: string
          required: true
      responses:
        200:
          $ref: '#/components/schemas/GLBLRAccountInfo'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

    delete:
      tags:
        - RadiusEndpointTypes-Global Reach
      operationId: deleteOpenRoamingGlobalReachAccount
      summary: Delete account information.
      parameters:
        - in: path
          description: The account name
          name: name
          schema:
            type: string
          required: true
      responses:
        200:
          $ref: '#/components/responses/Success'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

    post:
      tags:
        - RadiusEndpointTypes-Global Reach
      operationId: createOpenRoamingGlobalReachAccount
      summary: Create account information.
      parameters:
        - in: path
          description: The account name
          name: name
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GLBLRAccountInfo'
      responses:
        200:
          $ref: '#/components/schemas/GLBLRAccountInfo'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

    put:
      tags:
        - RadiusEndpointTypes-Global Reach
      operationId: modifyOpenRoamingGlobalReachAccount
      summary: Modify account information.
      parameters:
        - in: path
          description: The account name
          name: name
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GLBLRAccountInfo'
      responses:
        200:
          $ref: '#/components/schemas/GLBLRAccountInfo'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

  /openroaming/globalreach/certificates/{account}:
    get:
      tags:
        - RadiusEndpointTypes-Global Reach Certificate
      operationId: getOpenRoamingGlobalReachCertificateList
      summary: Retrieve certificate list.
      parameters:
        - in: path
          description: The account name
          name: account
          schema:
            type: string
          required: true
        - in: query
          description: Pagination start (starts at 1. If not specified, 1 is assumed)
          name: offset
          schema:
            type: integer
          required: false
        - in: query
          description: Maximum number of entries to return (if absent, no limit is assumed)
          name: limit
          schema:
            type: integer
          required: false
        - in: query
          description: return the number of certificates
          name: countOnly
          schema:
            type: boolean
          required: false

      responses:
        200:
          description: The list of certificates
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GLBLRCertificateInfo'
          $ref: '#/components/responses/Success'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

  /openroaming/globalreach/certificate/{account}/{id}:
    get:
      tags:
        - RadiusEndpointTypes-Global Reach Certificate
      operationId: getOpenRoamingGlobalReachCertificate
      summary: Retrieve certificate information.
      parameters:
        - in: path
          description: The account name - this is the provisioning ID for the account. Not the GlobalReach ID.
          name: account
          schema:
            type: string
          required: true
        - in: path
          description: The certificate id in provisioning - not the certificate_id from GlobalReach
          name: id
          schema:
            type: string
          required: true
      responses:
        200:
          $ref: '#/components/schemas/GLBLRCertificateInfo'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

    delete:
      tags:
        - RadiusEndpointTypes-Global Reach Certificate
      operationId: deleteOpenRoamingGlobalReachCertificate
      summary: Delete certificate information.
      parameters:
        - in: path
          description: The account name - this is the provisioning ID for the account. Not the GlobalReach ID.
          name: account
          schema:
            type: string
          required: true
        - in: path
          description: The certificate id in provisioning - not the certificate_id from GlobalReach
          name: id
          schema:
            type: string
          required: true
      responses:
        200:
          $ref: '#/components/responses/Success'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

    post:
      tags:
        - RadiusEndpointTypes-Global Reach Certificate
      operationId: createOpenRoamingGlobalReachCertificate
      summary: Create certificate information.
      parameters:
        - in: path
          description: The account name - this is the provisioning ID for the account. Not the GlobalReach ID.
          name: account
          schema:
            type: string
          required: true
        - in: path
          description: Must be set to "0"
          name: id
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GLBLRCertificateInfo'
      responses:
        200:
          $ref: '#/components/schemas/GLBLRCertificateInfo'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

    put:
      tags:
        - RadiusEndpointTypes-Global Reach Certificate
      operationId: updateOpenRoamingGlobalReachCertificate
      summary: Update certificate information.
      parameters:
        - in: path
          description: The account name - this is the provisioning ID for the account. Not the GlobalReach ID.
          name: account
          schema:
            type: string
          required: true
        - in: path
          description: the UUID of the certificate
          name: id
          schema:
            type: string
          required: true
        - in: query
          description: Update an existing certificate
          name: updateCertificate
          schema:
            type: boolean
            default: false
          required: false
      responses:
        200:
          $ref: '#/components/schemas/GLBLRCertificateInfo'
        400:
          $ref: '#/components/responses/BadRequest'
        403:
          $ref: '#/components/responses/Unauthorized'
        404:
          $ref: '#/components/responses/NotFound'

