openapi: 3.0.1
info:
  title: Cisco Umbrella Network Devices API
  version: 2.0.0
  description: Manage the network devices in your organization.
  contact:
    name: Cloud Security Developer Community

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

security:
  - oauthFlow: []

tags:
  - name: Network Devices
    description: Umbrella Network Device Management
  - name: Umbrella

paths:

  '/networkdevices':
    post:
      tags:
        - Network Devices
        - Umbrella
      summary: Create Network Device
      description: Create a network device.
      operationId: createNetworkDevice
      security:
        - oauthFlow:
          - deployments.networkdevices:write
      requestBody:
        content:
            application/json:
              schema:
                $ref: '#/components/schemas/NetworkDeviceCreate'
              example:
                model: The model name of the device.
                macAddress: 0123456789ab
                name: A name for the device.
                serialNumber: 12345a
      responses:
        '201':
          description: Created
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NetworkDeviceEntity'
              example:
                originId: 35872943
                deviceId: 0123456789abcdef
                deviceKey: ModelName-0123456789ab
                name: APIDemoDevice
                serialNumber: 12345a
                createdAt: '2021-09-22T04:18:51.000Z'
                organizationId: 1234
        '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:
        - Network Devices
        - Umbrella
      summary: List Network Devices
      description: List the network devices.
      operationId: getAllNetworkDevices
      security:
        - oauthFlow:
          - deployments.networkdevices: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/NetworkDeviceEntityList'
              example:
              - originId: 35872943
                deviceId: 0123456789abcdef
                deviceKey: ModelName-0123456789ab
                name: APIDemoDevice
                serialNumber: 12345a
                createdAt: '2021-09-22T04:18:51.000Z'
                organizationId: 1234
        '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'

  '/networkdevices/{originId}':
    patch:
      tags:
        - Network Devices
        - Umbrella
      summary: Update Network Device
      description: Update a network device.
      operationId: updateNetworkDevice
      security:
        - oauthFlow:
          - deployments.networkdevices:write
      parameters:
        - $ref: '#/components/parameters/networkDeviceOriginIdParam'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NetworkDevicePatch'
            example:
              name: NetworkDevice01
        description: Update the properties of the network device.
        required: true
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NetworkDeviceEntity'
              example:
                originId: 35872943
                deviceId: 0123456789abcdef
                deviceKey: ModelName-0123456789ab
                name: APIDemoDevice
                serialNumber: 12345a
                createdAt: '2021-09-22T04:18:51.000Z'
                organizationId: 1234
        '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:
        - Network Devices
        - Umbrella
      summary: Get Network Device
      description: Get a network device.
      operationId: getNetworkDevice
      security:
        - oauthFlow:
          - deployments.networkdevices:read
      parameters:
        - $ref: '#/components/parameters/networkDeviceOriginIdParam'
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NetworkDeviceEntity'
              example:
                originId: 35872943
                deviceId: 0123456789abcdef
                deviceKey: ModelName-0123456789ab
                name: APIDemoDevice
                serialNumber: 12345a
                createdAt: '2021-09-22T04:18:51.000Z'
                organizationId: 1234
        '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:
        - Network Devices
        - Umbrella
      summary: Delete Network Device
      description: Remove a network device.
      operationId: deleteNetworkDevice
      security:
        - oauthFlow:
          - deployments.networkdevices:write
      parameters:
        - $ref: '#/components/parameters/networkDeviceOriginIdParam'
      responses:
        '204':
          description: No Content
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content: {}
        '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'

  '/networkdevices/{originId}/policies':
    get:
      tags:
        - Network Devices
        - Umbrella
      summary: List Policies for Network Device
      description: |-
        List the Umbrella policies associated with a network device.
        If no filters are supplied, Umbrella returns the DNS policies.
      operationId: listNetworkDevicePolicies
      security:
        - oauthFlow:
          - deployments.networkdevices:read
      parameters:
        - $ref: '#/components/parameters/networkDeviceOriginIdParam'
        - $ref: '#/components/parameters/policyTypeParam'
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/Content-Type'
            Date:
              $ref: '#/components/headers/Date'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OriginPolicyAssociationList'
              example:
              - policyId: 123
                name: APIDemo policy
                priority: 1
                isAppliedDirectly: true
                isDefault: true
                createdAt: '2017-09-22T04:18:51.000Z'
        '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:
  securitySchemes:
    oauthFlow:
      type: oauth2
      description: client credential flow
      flows:
        clientCredentials:
          tokenUrl: https://api.umbrella.com/auth/v2/token
          scopes:
            deployments.networkdevices:write: 'Write deployments network devices'
            deployments.networkdevices:read: 'Read deployments network devices'

  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:
    networkDeviceOriginIdParam:
      name: originId
      in: path
      description: The origin ID of the network device.
      required: true
      schema:
        type: integer
        minimum: 1
        format: int32
    policyTypeParam:
      name: type
      in: query
      description: The type of the policy (`dns` or `web`).
      required: false
      schema:
        default: dns
        enum:
          - dns
          - web
        type: string
      example: dns

  schemas:
    NetworkDeviceCreate:
      type: object
      minProperties: 4
      required: [model, macAddress, name, serialNumber]
      properties:
        model:
          type: string
          example: ModelName
          maxLength: 128
          pattern: "[0-9A-Za-z_.-]{1,128}"
          description: The model name of the device. Must be unique to your organization.
        macAddress:
          type: string
          example: 0123456789ab
          maxLength: 12
          minLength: 12
          pattern: "[0-9A-Fa-f]{12}"
          description: |-
            The MAC address of the device. The unique MAC address may include
            up to 12 characters and must not contain hyphens or colons.
        name:
          $ref: '#/components/schemas/Name'
        serialNumber:
          type: string
          example: 12345a
          maxLength: 255
          description: The serial number of the device.
        tag:
          type: string
          description: >-
            A text tag that describes the device or this origin, which is assigned to the device. Provide a tag that is unique to your organization.
          maxLength: 50
    NetworkDevicePatch:
      type: object
      required: [name]
      description: Update the network device information.
      properties:
        name:
          $ref: '#/components/schemas/Name'
      example:
        name: MyDeviceName
    NetworkDeviceEntityList:
      type: array
      description: The list of networks devices.
      items:
        $ref: '#/components/schemas/NetworkDeviceEntity'
    NetworkDeviceEntity:
      type: object
      description: The network device object.
      minProperties: 7
      required: [originId, deviceId, deviceKey, name, serialNumber, createdAt, organizationId]
      properties:
        originId:
          type: integer
          example: 35872943
          minimum: 1
          description: |-
            The unique global identifier for this traffic source (origin). Use
            the origin ID to manage the device. The origin ID is not used by the device.
        deviceId:
          type: string
          example: "0123456789abcdef"
          maxLength: 16
          minLength: 15
          #pattern: "[0-9a-f]{16}"
          description: |-
            The unique identifier for the specific network device. Insert the identifier into the EDNS packets.
        deviceKey:
          type: string
          example: ModelName-0123456789ab
          description: |-
            A descriptive unique identifier for the device. Not used by the
            device.
        name:
          type: string
          example: APIDemoDevice
          description: The name of the device.
          minLength: 1
        serialNumber:
          type: string
          example: 12345a
          description: The serial number of the device.
        createdAt:
          type: string
          format: date-time
          example: '2017-09-22T04:18:51.000Z'
          description: The time when the device was created. Specify an ISO 8601-formatted timestamp.
          #pattern: "^((?:[12][0-9]{3}))-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\.[0-9]{3})(Z)$"
        organizationId:
          type: integer
          description: The ID of the organization.
          example: 1234
          minimum: 1
    OriginPolicyAssociationList:
      type: array
      description: The list of policies, which are associated with the network device.
      items:
        $ref: '#/components/schemas/OriginPolicyAssociation'
    OriginPolicyAssociation:
      type: object
      description: The policy that is associated with a network device.
      minProperties: 6
      required: [policyId, name, priority, isAppliedDirectly, isDefault, createdAt]
      properties:
        policyId:
          type: integer
          maxLength: 64
          description: The unique ID for the policy.
          minimum: 0
        name:
          type: string
          description: The name of the policy.
          example: ApiDemoPolicy
        priority:
          type: integer
          maxLength: 64
          description: The priority of the policy.
          minimum: 0
        isAppliedDirectly:
          type: boolean
          example: true
          description: |-
            Specify whether the policy is directly applied to this network device.
        isDefault:
          type: boolean
          example: true
          description: Specify whether the policy is the default policy.
        createdAt:
          type: string
          format: date-time
          example: '2021-10-02T20:00:00Z'
          description: The time when the policy was created. Specify an ISO 8601-formatted timestamp.
          #pattern: "^((?:[12][0-9]{3}))-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\.[0-9]{3})(Z)$"

    Name:
      type: string
      example: label1
      maxLength: 50
      minLength: 1
      description: |-
        The name of the device. The name is a sequence of characters with a length from 1 through 50.
        The name must be unique in your organization.

  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:
              statusCode:
                type: integer
                example: 400
                description: HTTP status code
              error:
                type: string
                example: Validation Error
                description: A brief description of the error
              message:
                type: string
                description: Detailed error message
    401Error:
      description: Unauthorized
      headers:
        Content-Type:
          $ref: '#/components/headers/Content-Type'
        Date:
          $ref: '#/components/headers/Date'
      content:
        application/json:
          schema:
            type: object
            properties:
              statusCode:
                type: integer
                example: 401
                description: HTTP status code
              error:
                type: string
                example: Validation error
                description: A brief description of the error
              message:
                type: string
                description: Detailed error message
    403Error:
      description: Forbidden
      headers:
        Content-Type:
          $ref: '#/components/headers/Content-Type'
        Date:
          $ref: '#/components/headers/Date'
      content:
        application/json:
          schema:
            type: object
            properties:
              statusCode:
                type: integer
                example: 403
                description: HTTP status code
              error:
                type: string
                example: Forbidden
                description: A brief description of the error
              message:
                type: string
                description: Detailed error message
    404Error:
      description: Not Found
      headers:
        Content-Type:
          $ref: '#/components/headers/Content-Type'
        Date:
          $ref: '#/components/headers/Date'
      content:
        application/json:
          schema:
            type: object
            properties:
              statusCode:
                type: integer
                example: 404
                description: HTTP status code
              error:
                type: string
                example: Not Found
                description: A brief description of the error
              message:
                type: string
                description: Detailed error message
    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:
              statusCode:
                type: integer
                example: 500
                description: HTTP status code
              error:
                type: string
                example: Internal error
                description: A brief description of the error
              message:
                type: string
                description: Detailed error message
