$schema: 'http://support.riverbed.com/apis/service_def/2.2'
id: 'http://support.riverbed.com/apis/mgmt.til.networking/1.0'
provider: 'riverbed'
name: mgmt.til.networking
version: "1.0"
title: Riverbed Networking Service

types:
    route_type:
        type: object
        properties:
            network_prefix:
                type: string
                description: Destination Network Prefix. A string consisting of an
                             IP address and a mask, separated by a slash (/).
                             For example 192.168.1.0/24
                             For IPv6 specify prefix after slash (/).
            gateway_address:
                type: string
                description: Gateway IP address
            interface:
                type: string
                description: Network Interface. At least one of gateway_address
                             or interface must be specified.


    static_route_type:
        type: object
        properties:
            id:
                type: string
                description: Server generated route identifier
                readOnly: true
            network_prefix:
                type: string
                description: Destination Network Prefix. A string consisting of an
                             IP address and a mask, separated by a slash (/).
                             For example 192.168.1.0/24
                             For IPv6 specify prefix after slash (/).
            gateway_address:
                type: string
                description: Gateway IP address
            interface:
                type: string
                description: Network Interface. At least one of gateway_addresses
                             or interfaces needs to be specified.
        required: [network_prefix, gateway_address, interface]


    state:
        type: object
        readOnly: true
        properties:
            enabled:
                type: boolean
                description: Interface enabled/up state
            link:
                type: boolean
                description: Interface link state
            interface_type:
                type: string
                description: Type of interface
            hw_address:
                type: string
                description: Hardware address of the interface
            if_index:
                type: number
                description: Interface index of the interface
            mtu:
                type: number
                description: MTU of the interface
            speed:
                anyOf:
                    - type: string
                      description: Speed of interface
                    - type: "null"
                      description: Speed is not relevant for interface.

            duplex:
                anyOf:
                    - type: string
                      description: Duplex of interface
                    - type: "null"
                      description: Duplex is not relevant for interface.
            ipv4:
                type: object
                properties:
                    address:
                        type: string
                        description: Interface IPv4 address
                    prefix:
                        type: integer
                        description: Subnet mask

            ipv6:
                type: object
                properties:
                    link_local:
                        type: string
                        description: Link local IPv6 address
                    address:
                        type: string
                        description: Interface IPv6 address

    configuration:
        type: object
        properties:
            enable:
                type: boolean
            description:
                type: string
            speed:
                anyOf:
                    - type: string
                      description: Set speed to the interface
                      enum: [ "auto", "10", "100", "1000", "2500", "10000"]
                    - type: "null"
                      description: Not configured/ Cannot be configured.
            duplex:
                anyOf:
                    - type: string
                      description: Set duplex to the interface
                      enum: [ "full", "half", "auto" ]
                    - type: "null"
                      description: Not Configured/ Cannot be configured.

            mtu:
                type: number
            ipv4:
                type: object
                properties:
                    dhcp:
                        type: boolean
                        description: Obtain IP address from DHCP server.
                    dynamic_dns:
                        type: boolean
                        description: Send hostname with the DHCP request.
                    address:
                        type: string
                        description: Set the IPv4 address of the interface.
                            This field is validated but not applied if DHCP is set.
                            To disable interface IP, set address to 0.0.0.0
                    prefix:
                        type: integer
                        description: Set the prefix of the interface.

                required: [dhcp, dynamic_dns, address, prefix]

            ipv6:
                type: object
                properties:
                    dhcp:
                        type: boolean
                        description: Obtain IP address from DHCP server.
                    dynamic_dns:
                        type: boolean
                        description: Send hostname with the DHCP request.
                    address:
                        type: string
                        description: Set the IPv6 address of the interface.
                            This field is validated but not applied if DHCP is set.
                            To remove IPv6 address set to blank.
                    prefix:
                        type: integer
                        description: IPv6 address prefix. Ignored if address
                            is set to blank.

                required: [dhcp, dynamic_dns, address, prefix]

        required: [enable, description, speed, duplex, mtu, ipv4, ipv6]

resources:
    interfaces:
        type: object
        properties:
            items:
                type: array
                items:
                    type: string
                    relations:
                        full:
                            resource: '#/resources/interface'
                            vars: { name: "0" }

        links:
            self: { path: "$/interfaces" }
            get:
                method: GET
                response: {$ref: '#/resources/interfaces' }


    interface:
        type: object
        properties:
            name:
                type: string
                readOnly: true
            configuration: { $ref: '#/types/configuration' }
            state: { $ref: '#/types/state' }
        links:
            self: { path: "$/interfaces/items/{name}" }
            get:
                method: GET
                response: { $ref: '#/resources/interface' }
            set:
                method: PUT
                request: { $ref: '#/resources/interface' }
                response: { $ref: '#/resources/interface' }

        relations:
            instances: { resource: '#/resources/interfaces' }

    ipv4_routes:
        type: object
        properties:
            all:
                type: array
                items: { $ref: '#/types/route_type' }
            static:
                type: array
                items:
                    $merge:
                        source: { $ref: '#/resources/ipv4_route' }
                        with:
                            relations:
                                full:
                                    resource: '#/resources/ipv4_route'
                                    vars: { id: "0/id" }

        links:
            self: { path: "$/routes/ipv4" }
            get:
                method: GET
                response: {$ref: '#/resources/ipv4_routes'}
            create:
                method: POST
                request: {$ref: '#/resources/ipv4_route' }
                response: {$ref: '#/resources/ipv4_route' }


    ipv4_route:
        $merge:
            source: { $ref: '#/types/static_route_type' }
            with:
                links:
                    self: { path: "$/routes/ipv4/{id}" }
                    get:
                        method: GET
                        response: {$ref: '#/resources/ipv4_route' }
                    delete:
                        description: Delete a static route
                        method: DELETE
                relations:
                    instances: { resource: '#/resources/ipv4_routes' }

    ipv6_routes:
        type: object
        properties:
            all:
                type: array
                items: { $ref: '#/types/route_type' }
            static:
                type: array
                items:
                    $merge:
                        source: { $ref: '#/resources/ipv6_route' }
                        with:
                            relations:
                                full:
                                    resource: '#/resources/ipv6_route'
                                    vars: { id: "0/id" }

        links:
            self: { path: "$/routes/ipv6" }
            get:
                method: GET
                response: {$ref: '#/resources/ipv6_routes'}
            create:
                method: POST
                request: {$ref: '#/resources/ipv6_route' }
                response: {$ref: '#/resources/ipv6_route' }

    ipv6_route:
        $merge:
            source: { $ref: '#/types/static_route_type' }
            with:
                links:
                    self: { path: "$/routes/ipv6/{id}" }
                    get:
                        method: GET
                        response: {$ref: '#/resources/ipv6_route' }
                    delete:
                        description: Delete a static route
                        method: DELETE
                relations:
                    instances: { resource: '#/resources/ipv6_routes' }

    route_settings:
        type: object
        description: This resource configure general route settings.
        properties:
            default_gateway:
                description: Configures the default gateway for the host. The state can be
                             verified by querying the IPv4_routes or IPv6_routes resource.
                type: object
                properties:
                    ipv4:
                        type: string
                        description: IPv4 address for default gateway. Blank string unsets it.
                    ipv6:
                        type: string
                        description: IPv6 address for default gateway. Blank string unsets it.

        links:
            self: { path: "$/settings/route" }
            get:
                method: GET
                response: { $ref: '#/resources/route_settings' }
            set:
                method: PUT
                request: { $ref: '#/resources/route_settings' }
                response: { $ref: '#/resources/route_settings' }
