swagger: '2.0'
info:
  description: Configuration for Managed Application resource.
  version: 'v2'
  title: managed_app
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: managed_app
    description: Managed Application
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  UserSecurity:
    type: basic
security:
  - UserSecurity: []
parameters:
  idParam:
   name: app_id
   in: path
   type: string
   description: Id for the managed application
   required: true
  authParam:
      in: header
      name: Authorization
      type: string
      required: true
      description: Session Id for authentication.Should be mentioned in the format CwsAuth bearer=sessionIdValue
  cloudParam:
      in: header
      name: isCloud
      type: string
      required: true
      description: set the value to true in case of Cloud services, false for on-prem deployment
paths:
  /massvc/{customerid}/nitro/v2/config/managed_app:
    get:
      tags:
        - managed_app
      summary: GET all managed_app
      operationId: getall_managed_app
      description: Use this operation to get an managed application
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: path
          name: customerid
          type: string
          required: true
          description: Customer Id of the user
        - in: header
          name: Authorization
          type: string
          required: true
          description: Session Id for authentication.Should be mentioned in the format CwsAuth bearer=sessionIdValue
        - in: header
          name: isCloud
          type: string
          required: true
          description: set the value to true in case of Cloud services, false for on-prem deployment
        - in: query
          name: filter
          type: string
          required: false
          description: "Use this query-parameter to get the filtered set of vm_device resources configured on the system. You can set a filter on any property of the resource.Example:  property-name1:property-value1 "
        - in: query
          name: pagesize
          type: integer
          required: false
          description: Use this query-parameter to get the managed_app resources in chunks.To be used along with pageno query parameter.
        - in: query
          name: pageno
          type: integer
          required: false
          description: Use this query-parameter to get the managed_app resources in chunks.To be used along with pagesize query parameter.
        - in: query
          name: count
          type: string
          required: false
          description: Use this query-parameter to get the count of managed_app resources.
          enum:
            - yes
      responses:
        200:
          description:  for managed_app
          schema: 
              $ref: '#/definitions/getmanaged_appsResponse'
        400:
          description: Bad input parameter
          schema: 
              $ref: '#/definitions/Error'
        401:
          description: Failed Authentication
          schema: 
              $ref: '#/definitions/Error'
        403:
          description: Unauthorized
          schema: 
              $ref: '#/definitions/Error'
        404:
          description: Item not found
          schema: 
              $ref: '#/definitions/Error'
        409:
          description: Resource Conflict
          schema: 
              $ref: '#/definitions/Error'
        500:
          description: Server Error
          schema: 
              $ref: '#/definitions/Error'
        504:
          description: Gateway Timeout
          schema: 
              $ref: '#/definitions/Error'

    post:
      tags:
        - managed_app
      summary: POST operation for managed_app
      operationId: post_managed_app
      description: POST operation for managed_app
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: path
          name: customerid
          type: string
          required: true
          description: Customer Id of the user
        - in: header
          name: Authorization
          type: string
          required: true
          description: Session Id for authentication.Should be mentioned in the format CwsAuth bearer=sessionIdValue
        - in: header
          name: isCloud
          type: string
          required: true
          description: set the value to true in case of Cloud services, false for on-prem deployment
        - in: query
          name: onerror
          description: Use this parameter to set the onerror status for nitro request. Applicable only for bulk requests.
          required: false
          type: string
          default: CONTINUE
          enum:
            - EXIT
            - CONTINUE
        - in: body
          name: managed_app
          description: managed_app object
          schema:
              $ref: '#/definitions/addmanaged_appRequest'
      responses:
        200:
          description: add for managed_app
          schema: 
              $ref: '#/definitions/addmanaged_appResponse'
        400:
          description: Bad input parameter
          schema: 
              $ref: '#/definitions/Error'
        401:
          description: Failed Authentication
          schema: 
              $ref: '#/definitions/Error'
        403:
          description: Unauthorized
          schema: 
              $ref: '#/definitions/Error'
        404:
          description: Item not found
          schema: 
              $ref: '#/definitions/Error'
        409:
          description: Resource Conflict
          schema: 
              $ref: '#/definitions/Error'
        500:
          description: Server Error
          schema: 
              $ref: '#/definitions/Error'
        504:
          description: Gateway Timeout
          schema: 
              $ref: '#/definitions/Error'

  /massvc/{customerid}/nitro/v2/config/managed_app/{app_id}:
    get:
      tags:
        - managed_app
      summary: GET by key for managed_app
      operationId: getbykey_managed_app
      description: Use this operation to get an managed application
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/idParam'
        - in: path
          name: customerid
          type: string
          required: true
          description: Customer Id of the user
        - in: header
          name: Authorization
          type: string
          required: true
          description: Session Id for authentication.Should be mentioned in the format CwsAuth bearer=sessionIdValue
        - in: header
          name: isCloud
          type: string
          required: true
          description: set the value to true in case of Cloud services, false for on-prem deployment
      responses:
        200:
          description: add for managed_app
          schema: 
              $ref: '#/definitions/getmanaged_appResponse'
        400:
          description: Bad input parameter
          schema: 
              $ref: '#/definitions/Error'
        401:
          description: Failed Authentication
          schema: 
              $ref: '#/definitions/Error'
        403:
          description: Unauthorized
          schema: 
              $ref: '#/definitions/Error'
        404:
          description: Item not found
          schema: 
              $ref: '#/definitions/Error'
        409:
          description: Resource Conflict
          schema: 
              $ref: '#/definitions/Error'
        500:
          description: Server Error
          schema: 
              $ref: '#/definitions/Error'
        504:
          description: Gateway Timeout
          schema: 
              $ref: '#/definitions/Error'

    put:
      tags:
        - managed_app
      summary: PUT for managed_app
      operationId: putbykey_managed_app
      description: Use this operation to update managed application
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/idParam'
        - in: path
          name: customerid
          type: string
          required: true
          description: Customer Id of the user
        - in: header
          name: Authorization
          type: string
          required: true
          description: Session Id for authentication.Should be mentioned in the format CwsAuth bearer=sessionIdValue
        - in: header
          name: isCloud
          type: string
          required: true
          description: set the value to true in case of Cloud services, false for on-prem deployment
        - in: body
          name: managed_app
          description: managed_app object
          schema:
              $ref: '#/definitions/modifymanaged_appRequest'
      responses:
        200:
          description: add for managed_app
          schema: 
              $ref: '#/definitions/modifymanaged_appResponse'
        400:
          description: Bad input parameter
          schema: 
              $ref: '#/definitions/Error'
        401:
          description: Failed Authentication
          schema: 
              $ref: '#/definitions/Error'
        403:
          description: Unauthorized
          schema: 
              $ref: '#/definitions/Error'
        404:
          description: Item not found
          schema: 
              $ref: '#/definitions/Error'
        409:
          description: Resource Conflict
          schema: 
              $ref: '#/definitions/Error'
        500:
          description: Server Error
          schema: 
              $ref: '#/definitions/Error'
        504:
          description: Gateway Timeout
          schema: 
              $ref: '#/definitions/Error'

    delete:
      tags:
        - managed_app
      summary: Delete for managed_app
      operationId: deletebykey_managed_app
      description: Use this operation to delete an managed application
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/idParam'
        - in: path
          name: customerid
          type: string
          required: true
          description: Customer Id of the user
        - in: header
          name: Authorization
          type: string
          required: true
          description: Session Id for authentication.Should be mentioned in the format CwsAuth bearer=sessionIdValue
        - in: header
          name: isCloud
          type: string
          required: true
          description: set the value to true in case of Cloud services, false for on-prem deployment
      responses:
        204:
          description: add for managed_app
        400:
          description: Bad input parameter
          schema: 
              $ref: '#/definitions/Error'
        401:
          description: Failed Authentication
          schema: 
              $ref: '#/definitions/Error'
        403:
          description: Unauthorized
          schema: 
              $ref: '#/definitions/Error'
        404:
          description: Item not found
          schema: 
              $ref: '#/definitions/Error'
        409:
          description: Resource Conflict
          schema: 
              $ref: '#/definitions/Error'
        500:
          description: Server Error
          schema: 
              $ref: '#/definitions/Error'
        504:
          description: Gateway Timeout
          schema: 
              $ref: '#/definitions/Error'

definitions:
  addmanaged_appRequest:
    type: object
    required:
      - managed_app
    properties:
      managed_app:
        $ref: '#/definitions/managed_app_readwrite'
    title: addmanaged_appRequest
    example:
      managed_app:
        app_networking_data: "string_value"
        is_app_placed: "false"
        lb_role: "client"
        container_manager: "testsystem"
        app_netfuncs_config: [{        parent_name: "string_value"
,        netfunc_params: "object_value"
,        type: "string_value"
,        id: "string_value"
,        parent_id: "string_value"
}]
        networking_manager: "test_manager"
        app_dns: "1.1.1.1"
        appname: "test_app"
        dns_manager: "dns_manager"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  addmanaged_appResponse:
    type: object
    required:
      - managed_app
    properties:
      managed_app:
        $ref: '#/definitions/managed_app'
    title: addmanaged_appResponse
    example:
      managed_app:
        app_networking_data: "string_value"
        is_app_placed: "false"
        lb_role: "client"
        container_manager: "testsystem"
        app_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        app_netfuncs_config: [{        parent_name: "string_value"
,        netfunc_params: "object_value"
,        type: "string_value"
,        id: "string_value"
,        parent_id: "string_value"
}]
        networking_manager: "test_manager"
        app_dns: "1.1.1.1"
        appname: "test_app"
        dns_manager: "dns_manager"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  getmanaged_appResponse:
    type: object
    required:
      - managed_app
    properties:
      managed_app:
        $ref: '#/definitions/managed_app'
    title: getmanaged_appResponse
    example:
      managed_app:
        app_networking_data: "string_value"
        is_app_placed: "false"
        lb_role: "client"
        container_manager: "testsystem"
        app_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        app_netfuncs_config: [{        parent_name: "string_value"
,        netfunc_params: "object_value"
,        type: "string_value"
,        id: "string_value"
,        parent_id: "string_value"
}]
        networking_manager: "test_manager"
        app_dns: "1.1.1.1"
        appname: "test_app"
        dns_manager: "dns_manager"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  getmanaged_appsResponse:
    type: object
    required:
      - managed_app
    properties:
      managed_app:
        type: array
        items:
          $ref: '#/definitions/managed_app'
    title: getmanaged_appsResponse
    example:
      managed_app:
        app_networking_data: "string_value"
        is_app_placed: "false"
        lb_role: "client"
        container_manager: "testsystem"
        app_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        app_netfuncs_config: [{        parent_name: "string_value"
,        netfunc_params: "object_value"
,        type: "string_value"
,        id: "string_value"
,        parent_id: "string_value"
}]
        networking_manager: "test_manager"
        app_dns: "1.1.1.1"
        appname: "test_app"
        dns_manager: "dns_manager"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  modifymanaged_appRequest:
    type: object
    required:
      - managed_app
    properties:
      managed_app:
        $ref: '#/definitions/managed_app_readwrite'
    title: modifymanaged_appRequest
    example:
      managed_app:
        app_networking_data: "string_value"
        is_app_placed: "false"
        lb_role: "client"
        container_manager: "testsystem"
        app_netfuncs_config: [{        parent_name: "string_value"
,        netfunc_params: "object_value"
,        type: "string_value"
,        id: "string_value"
,        parent_id: "string_value"
}]
        networking_manager: "test_manager"
        app_dns: "1.1.1.1"
        appname: "test_app"
        dns_manager: "dns_manager"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  modifymanaged_appResponse:
    type: object
    required:
      - managed_app
    properties:
      managed_app:
        $ref: '#/definitions/managed_app'
    title: modifymanaged_appResponse
    example:
      managed_app:
        app_networking_data: "string_value"
        is_app_placed: "false"
        lb_role: "client"
        container_manager: "testsystem"
        app_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        app_netfuncs_config: [{        parent_name: "string_value"
,        netfunc_params: "object_value"
,        type: "string_value"
,        id: "string_value"
,        parent_id: "string_value"
}]
        networking_manager: "test_manager"
        app_dns: "1.1.1.1"
        appname: "test_app"
        dns_manager: "dns_manager"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  managed_app_readwrite:
    type: object
    properties:
      app_networking_data:
        description: "app networking blob that can be used by placement logic"
        type: string
        format: string
      is_app_placed:
        description: "1 if app is placed on some NS, else 0."
        type: boolean
        format: boolean
      lb_role:
        description: "Application is applied only on the devices with the same Lb role"
        type: string
        format: string
      container_manager:
        description: "Container orchestration system"
        type: string
        format: string
      app_netfuncs_config:
        type: array
        items:
          $ref: '#/definitions/network_function_config_readwrite'
      networking_manager:
        description: "System used to setup the network"
        type: string
        format: string
      app_dns:
        description: "Doman name service for Application"
        type: string
        format: string
      appname:
        description: "Name of the Application"
        type: string
        format: string
      dns_manager:
        description: "Domain Name Service manager"
        type: string
        format: string
      id:
        description: "Dummy Id needed for input get requests"
        type: string
        format: uuid

  managed_app:
    allOf:
      -
        properties:
          app_id:
            description: Id for the managed application
            type: string
            format: uuid
      - $ref: '#/definitions/managed_app_readwrite'

  network_function_config_readwrite:
    type: object
    properties:
      parent_name:
        type: string
        format: string
      netfunc_params:
        $ref: '#/definitions/network_function_param_readwrite'
      type:
        description: "Type of network function"
        type: string
        format: string
        minLength: 1
        maxLength: 1024
      parent_id:
        type: string
        format: string

  network_function_config:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the servers
            type: string
            format: uuid
      - $ref: '#/definitions/network_function_config_readwrite'

  network_function_param_readwrite:
    type: object
    properties:
      parameters:
        description: "Payload parameters for the network function"
        type: string
        format: string
      netfunc_id:
        description: "ID of network function"
        type: string
        format: string
        minLength: 1
        maxLength: 1024

  network_function_param:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the servers
            type: string
            format: uuid
          config_id:
             description: "Stylebook config Id for the managed application"
             type: string
             format: string
          app_devices:
            type: array
            items:
              $ref: '#/definitions/app_device'
      - $ref: '#/definitions/network_function_param_readwrite'

  app_device_readwrite:
    type: object
    properties:
      device_id:
        description: "Instance ID for the device"
        type: string
        format: string
      parent_name:
        description: "Nmae of the parent device"
        type: string
        format: string
      device_mgmt_ip:
        description: "IPv4 or IPv6 Address assigned to the device"
        type: string
        format: ipaddress
        minLength: 1
        maxLength: 64
      parent_id:
        description: "Instance ID for the parent"
        type: string
        format: string

  app_device:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the app-device mapping
            type: string
            format: uuid
      - $ref: '#/definitions/app_device_readwrite'

  Error:
    properties:
      errorcode:
        type: number
        format: int32
        example: 1001
      errormessage:
        type: string
        format: string
        example: "id cannot be found"
