openapi: 3.0.1
info:
  title: Cicso Umbrella Managed Providers API
  version: 2.0.0
  description: View, create, update, and delete the customers for the managed providers.
  contact:
    name: Cloud Security Developer Community

servers:
  - url: https://api.umbrella.com/{basePath}
    variables:
      basePath:
        default: admin/v2

tags:
  - name: Managed Providers
  - name: Umbrella

security:
  - oauthFlow: []

paths:

  '/managed/customers':
    post:
      tags:
        - Managed Providers
        - Umbrella
      description: Create a customer for a managed provider.
      summary: Create Customer for Managed Provider
      operationId: createManagedProviderCustomer
      security:
        - oauthFlow:
            - admin.customers:write
      requestBody:
        content:
          application/json:
            schema:
              properties:
                customerName:
                  $ref: '#/components/schemas/customerName'
                seats:
                  $ref: '#/components/schemas/seats'
              type: object
              required:
                - customerName
                - seats
              description: Create a customer for the managed provider.
            example:
              customerName: Cisco
              seats: 100
      responses:
        '200':
          description: OK        
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customer'
              example:
                customerId: 12929
                customerName: cisco
                seats: 1000
        '400':
          $ref: '#/components/responses/400Error'
        '401':
          $ref: '#/components/responses/401Error'
        '403':
          $ref: '#/components/responses/403Error'
        '404':
          $ref: '#/components/responses/404Error'
        '500':
          $ref: '#/components/responses/500Error'

    get:
      tags:
        - Managed Providers
        - Umbrella
      description: List the customers for the managed provider.
      operationId: listManagedProviderCustomers
      summary: List Customers for Managed Provider
      security:
        - oauthFlow:
            - admin.customers:read
      parameters:
        - $ref: '#/components/parameters/limitParam'
        - $ref: '#/components/parameters/pageParam'
      responses:
        '200':
          description: OK        
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content:
            application/json:
              schema:
                type: array
                description: List the customers for the managed provider.
                items:
                  $ref: '#/components/schemas/Customer'
              example:
                - customerId: 12929
                  customerName: cisco
                  seats: 1000
        '400':
          $ref: '#/components/responses/400Error'
        '401':
          $ref: '#/components/responses/401Error'
        '403':
          $ref: '#/components/responses/403Error'
        '404':
          $ref: '#/components/responses/404Error'
        '500':
          $ref: '#/components/responses/500Error'

  '/managed/customers/{customerId}':
    get:
      tags:
        - Managed Providers
        - Umbrella
      description: Get a customer for the managed provider.
      summary: Get Customer for Managed Provider
      operationId: getManagedProviderCustomer
      parameters:
      - $ref: '#/components/parameters/customerIdParam'
      security:
        - oauthFlow:
            - admin.customers:read
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customer'
              example:
                customerId: 12929
                customerName: cisco
                seats: 1000
        '400':
          $ref: '#/components/responses/400Error'
        '401':
          $ref: '#/components/responses/401Error'
        '403':
          $ref: '#/components/responses/403Error'
        '404':
          $ref: '#/components/responses/404Error'
        '500':
          $ref: '#/components/responses/500Error'

    delete:
      tags:
        - Managed Providers
        - Umbrella
      description: Delete an customer for the managed provider.
      summary: Delete Customer for Managed Provider
      operationId: deleteMangedProviderCustomer
      parameters:
      - $ref: '#/components/parameters/customerIdParam'
      security:
        - oauthFlow:
            - admin.customers:write
      responses:
        '204':
          description: No Content
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content:
            application/json:
              schema:
                type: string
                description: Delete a customer for the Managed Provider. Returns no content.
                nullable: true
              example: ''
        '400':
          $ref: '#/components/responses/400Error'
        '401':
          $ref: '#/components/responses/401Error'
        '403':
          $ref: '#/components/responses/403Error'
        '404':
          $ref: '#/components/responses/404Error'
        '500':
          $ref: '#/components/responses/500Error'

    put:
      tags:
        - Managed Providers
        - Umbrella
      description: Update a customer for a managed provider.
      summary: Update Customer for Managed Provider
      operationId: updateManagedProviderCustomer
      parameters:
      - $ref: '#/components/parameters/customerIdParam'
      security:
        - oauthFlow:
            - admin.customers:write
      requestBody:
        content:
          application/json:
            schema:
              properties:
                customerName:
                  $ref: '#/components/schemas/customerName'
                seats:
                  $ref: '#/components/schemas/seats'
              type: object
              required:
                - customerName
                - seats
            example:
                customerName: cisco
                seats: 1000
        description: Provide the customer information.
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customer'
              example:
                customerId: 12929
                customerName: cisco
                seats: 1000
        '400':
          $ref: '#/components/responses/400Error'
        '401':
          $ref: '#/components/responses/401Error'
        '403':
          $ref: '#/components/responses/403Error'
        '404':
          $ref: '#/components/responses/404Error'
        '500':
          $ref: '#/components/responses/500Error'

components:

  schemas:
    Customer:
      type: object
      description: The properties of the customer.
      required:
        - customerId
        - customerName
        - seats
      properties:
        customerId:
          $ref: '#/components/schemas/customerId'
        customerName:
          $ref: '#/components/schemas/customerName'
        seats:
          $ref: '#/components/schemas/seats'
      example:
        customerId: 124
        customerName: Cisco
        seats: 45

    customerId:
      type: integer
      description: The ID of the customer.
      example: 14

    customerName:
      type: string
      description: The customer's organization name.
      minLength: 1
      maxLength: 255
      example: Cisco

    seats:
      type: integer
      minimum: 1
      description: The number of users.
      example: 100

  securitySchemes:
    oauthFlow:
      type: oauth2
      description: The client credential flow.
      flows:
        clientCredentials:
          tokenUrl: https://api.umbrella.com/auth/v2/token
          scopes:
            admin.customers:read: 'Read admin customers'
            admin.customers:write: 'Write admin customers'

  headers:
    Content-Type:
      schema:
        type: string
      description: The MIME content type of the response body.
      example: application/json
    Date:
      schema:
        type: string
        pattern: '^[0-90-90-90-9-0-90-9-0-90-9T0-90-9:0-90-9:0-90-9Z]+$'
      description: The timestamp of the response.
      example: '2023-03-14T18:34:25Z'
      #'2023-03-14T18:34:25.412525046Z'

  parameters:
    pageParam:
      name: page
      in: query
      description: The number of a page in the collection.
      required: false
      schema:
        default: 1
        type: integer
        format: int32
        minimum: 1
      example: 5
    limitParam:
      name: limit
      in: query
      description: The maximum number of records to return on the page.
      required: false
      schema:
        default: 100
        type: integer
        format: int32
        minimum: 1
        maximum: 100
      example: 50
    customerIdParam:
      name: customerId
      in: path
      description: The ID of the customer.
      schema:
        type: integer
        format: int64  
      required: true
      example: 1235

  responses:
    400Error:
      description: Bad Request
      headers:
        Content-Type:
          $ref: '#/components/headers/Content-Type'
        Date:
          $ref: '#/components/headers/Date'
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
    401Error:
      description: Unauthorized
      headers:
        Content-Type:
          $ref: '#/components/headers/Content-Type'
        Date:
          $ref: '#/components/headers/Date'
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
    403Error:
      description: Forbidden
      headers:
        Content-Type:
          $ref: '#/components/headers/Content-Type'
        Date:
          $ref: '#/components/headers/Date'
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
    404Error:
      description: Not Found
      headers:
        Content-Type:
          $ref: '#/components/headers/Content-Type'
        Date:
          $ref: '#/components/headers/Date'
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
    500Error:
      description: Internal Server Error
      headers:
        Content-Type:
          $ref: '#/components/headers/Content-Type'
        Date:
          $ref: '#/components/headers/Date'
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
