swagger: '2.0'
info:
  description: Configuration for LDAP Server resource.
  version: 'v2'
  title: ldap_server
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: ldap_server
    description: LDAP Server
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  UserSecurity:
    type: basic
security:
  - UserSecurity: []
parameters:
  idParam:
   name: id
   in: path
   type: string
   description: Id is system generated key for all the ldap servers
   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/ldap_server:
    get:
      tags:
        - ldap_server
      summary: GET all ldap_server
      operationId: getall_ldap_server
      description: Use this operation to get LDAP server details
      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 ldap_server 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 ldap_server 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 ldap_server resources.
          enum:
            - yes
      responses:
        200:
          description:  for ldap_server
          schema: 
              $ref: '#/definitions/getldap_serversResponse'
        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:
        - ldap_server
      summary: POST operation for ldap_server
      operationId: post_ldap_server
      description: POST operation for ldap_server
      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: ldap_server
          description: ldap_server object
          schema:
              $ref: '#/definitions/addldap_serverRequest'
      responses:
        200:
          description: add for ldap_server
          schema: 
              $ref: '#/definitions/addldap_serverResponse'
        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/ldap_server/{id}:
    get:
      tags:
        - ldap_server
      summary: GET by key for ldap_server
      operationId: getbykey_ldap_server
      description: Use this operation to get LDAP server details
      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 ldap_server
          schema: 
              $ref: '#/definitions/getldap_serverResponse'
        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:
        - ldap_server
      summary: PUT for ldap_server
      operationId: putbykey_ldap_server
      description: Use this operation to modify LDAP server
      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: ldap_server
          description: ldap_server object
          schema:
              $ref: '#/definitions/modifyldap_serverRequest'
      responses:
        200:
          description: add for ldap_server
          schema: 
              $ref: '#/definitions/modifyldap_serverResponse'
        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:
        - ldap_server
      summary: Delete for ldap_server
      operationId: deletebykey_ldap_server
      description: Use this operation to delete LDAP server
      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 ldap_server
        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:
  addldap_serverRequest:
    type: object
    required:
      - ldap_server
    properties:
      ldap_server:
        $ref: '#/definitions/ldap_server_readwrite'
    title: addldap_serverRequest
    example:
      ldap_server:
        auth_timeout: "5"
        group_search_subattribute: "memberOf"
        follow_referrals: "false"
        search_filter: "ldap"
        group_attr_name: "memberOf"
        authentication: "true"
        ldap_host_name: "ldap-host-name"
        change_password: "false"
        default_authentication_group: "test-group"
        max_nesting_level: "0"
        login_name: "samAccountName"
        ip_address: "1.1.1.1"
        nested_group_extraction: "false"
        group_search_attribute: "memberOf"
        ssh_public_key: "SSH public key"
        group_name_identifier: "SAM-Group"
        subattribute_name: "CN"
        name: "LDAP Server"
        validate_ldap_server_certs: "false"
        group_search_filter: "ldap"
        bind_dn: "DC=Location,DC=com,CN=admin,CN=Users"
        port: "389"
        base_dn: "CN=admin,CN=Users"
        sec_type: "PLAINTEXT"
        max_ldap_referrals: "0"
        type: "NDS or AD"
        bind_passwd: "password"

  addldap_serverResponse:
    type: object
    required:
      - ldap_server
    properties:
      ldap_server:
        $ref: '#/definitions/ldap_server'
    title: addldap_serverResponse
    example:
      ldap_server:
        auth_timeout: "5"
        group_search_subattribute: "memberOf"
        follow_referrals: "false"
        search_filter: "ldap"
        group_attr_name: "memberOf"
        authentication: "true"
        ldap_host_name: "ldap-host-name"
        change_password: "false"
        default_authentication_group: "test-group"
        max_nesting_level: "0"
        login_name: "samAccountName"
        id: "4be3c482-9d44-4095-add7-c55acc6a8af8"
        ip_address: "1.1.1.1"
        nested_group_extraction: "false"
        group_search_attribute: "memberOf"
        ssh_public_key: "SSH public key"
        group_name_identifier: "SAM-Group"
        subattribute_name: "CN"
        name: "LDAP Server"
        validate_ldap_server_certs: "false"
        group_search_filter: "ldap"
        bind_dn: "DC=Location,DC=com,CN=admin,CN=Users"
        port: "389"
        base_dn: "CN=admin,CN=Users"
        sec_type: "PLAINTEXT"
        max_ldap_referrals: "0"
        type: "NDS or AD"
        bind_passwd: "password"
        address_type: "0"

  getldap_serverResponse:
    type: object
    required:
      - ldap_server
    properties:
      ldap_server:
        $ref: '#/definitions/ldap_server'
    title: getldap_serverResponse
    example:
      ldap_server:
        auth_timeout: "5"
        group_search_subattribute: "memberOf"
        follow_referrals: "false"
        search_filter: "ldap"
        group_attr_name: "memberOf"
        authentication: "true"
        ldap_host_name: "ldap-host-name"
        change_password: "false"
        default_authentication_group: "test-group"
        max_nesting_level: "0"
        login_name: "samAccountName"
        id: "4be3c482-9d44-4095-add7-c55acc6a8af8"
        ip_address: "1.1.1.1"
        nested_group_extraction: "false"
        group_search_attribute: "memberOf"
        ssh_public_key: "SSH public key"
        group_name_identifier: "SAM-Group"
        subattribute_name: "CN"
        name: "LDAP Server"
        validate_ldap_server_certs: "false"
        group_search_filter: "ldap"
        bind_dn: "DC=Location,DC=com,CN=admin,CN=Users"
        port: "389"
        base_dn: "CN=admin,CN=Users"
        sec_type: "PLAINTEXT"
        max_ldap_referrals: "0"
        type: "NDS or AD"
        bind_passwd: "password"
        address_type: "0"

  getldap_serversResponse:
    type: object
    required:
      - ldap_server
    properties:
      ldap_server:
        type: array
        items:
          $ref: '#/definitions/ldap_server'
    title: getldap_serversResponse
    example:
      ldap_server:
        auth_timeout: "5"
        group_search_subattribute: "memberOf"
        follow_referrals: "false"
        search_filter: "ldap"
        group_attr_name: "memberOf"
        authentication: "true"
        ldap_host_name: "ldap-host-name"
        change_password: "false"
        default_authentication_group: "test-group"
        max_nesting_level: "0"
        login_name: "samAccountName"
        id: "4be3c482-9d44-4095-add7-c55acc6a8af8"
        ip_address: "1.1.1.1"
        nested_group_extraction: "false"
        group_search_attribute: "memberOf"
        ssh_public_key: "SSH public key"
        group_name_identifier: "SAM-Group"
        subattribute_name: "CN"
        name: "LDAP Server"
        validate_ldap_server_certs: "false"
        group_search_filter: "ldap"
        bind_dn: "DC=Location,DC=com,CN=admin,CN=Users"
        port: "389"
        base_dn: "CN=admin,CN=Users"
        sec_type: "PLAINTEXT"
        max_ldap_referrals: "0"
        type: "NDS or AD"
        bind_passwd: "password"
        address_type: "0"

  modifyldap_serverRequest:
    type: object
    required:
      - ldap_server
    properties:
      ldap_server:
        $ref: '#/definitions/ldap_server_readwrite'
    title: modifyldap_serverRequest
    example:
      ldap_server:
        auth_timeout: "5"
        group_search_subattribute: "memberOf"
        follow_referrals: "false"
        search_filter: "ldap"
        group_attr_name: "memberOf"
        authentication: "true"
        ldap_host_name: "ldap-host-name"
        change_password: "false"
        default_authentication_group: "test-group"
        max_nesting_level: "0"
        login_name: "samAccountName"
        ip_address: "1.1.1.1"
        nested_group_extraction: "false"
        group_search_attribute: "memberOf"
        ssh_public_key: "SSH public key"
        group_name_identifier: "SAM-Group"
        subattribute_name: "CN"
        name: "LDAP Server"
        validate_ldap_server_certs: "false"
        group_search_filter: "ldap"
        bind_dn: "DC=Location,DC=com,CN=admin,CN=Users"
        port: "389"
        base_dn: "CN=admin,CN=Users"
        sec_type: "PLAINTEXT"
        max_ldap_referrals: "0"
        type: "NDS or AD"
        bind_passwd: "password"

  modifyldap_serverResponse:
    type: object
    required:
      - ldap_server
    properties:
      ldap_server:
        $ref: '#/definitions/ldap_server'
    title: modifyldap_serverResponse
    example:
      ldap_server:
        auth_timeout: "5"
        group_search_subattribute: "memberOf"
        follow_referrals: "false"
        search_filter: "ldap"
        group_attr_name: "memberOf"
        authentication: "true"
        ldap_host_name: "ldap-host-name"
        change_password: "false"
        default_authentication_group: "test-group"
        max_nesting_level: "0"
        login_name: "samAccountName"
        id: "4be3c482-9d44-4095-add7-c55acc6a8af8"
        ip_address: "1.1.1.1"
        nested_group_extraction: "false"
        group_search_attribute: "memberOf"
        ssh_public_key: "SSH public key"
        group_name_identifier: "SAM-Group"
        subattribute_name: "CN"
        name: "LDAP Server"
        validate_ldap_server_certs: "false"
        group_search_filter: "ldap"
        bind_dn: "DC=Location,DC=com,CN=admin,CN=Users"
        port: "389"
        base_dn: "CN=admin,CN=Users"
        sec_type: "PLAINTEXT"
        max_ldap_referrals: "0"
        type: "NDS or AD"
        bind_passwd: "password"
        address_type: "0"

  ldap_server_readwrite:
    type: object
    properties:
      auth_timeout:
        description: "The maximum number of seconds the system will wait for a response from the LDAP server"
        type: integer
        format: int32
      group_search_subattribute:
        description: "LDAP group search subattribute. Used to determine to which groups a group belongs."
        type: string
        format: string
        maxLength: 32
      follow_referrals:
        description: "Enable following LDAP referrals received from LDAP server"
        type: boolean
        format: boolean
      search_filter:
        description: "The String to be combined with the default LDAP user search string to form the value"
        type: string
        format: string
        maxLength: 256
      group_attr_name:
        description: "The Attribute name for group extraction from the LDAP server"
        type: string
        format: string
        maxLength: 32
      authentication:
        description: "Set to false for public key Authentication"
        type: boolean
        format: boolean
      ldap_host_name:
        description: "Host Name on the certificate from LDAP Server"
        type: string
        format: string
        maxLength: 128
      change_password:
        description: "Enable change of the user"
        type: boolean
        format: boolean
      default_authentication_group:
        description: "This is the default group"
        type: string
        format: string
        maxLength: 64
      max_nesting_level:
        description: "Number of levels at which group extraction is allowed"
        type: integer
        format: int32
      login_name:
        description: "The name attribute used by the system to query the external LDAP server"
        type: string
        format: string
        maxLength: 32
      ip_address:
        description: "The IP address of the LDAP server."
        type: string
        format: ipaddress
        minLength: 1
        maxLength: 64
      nested_group_extraction:
        description: "Enable Nested Group Extraction"
        type: boolean
        format: boolean
      group_search_attribute:
        description: "LDAP group search attribute. Used to determine to which groups a group belongs"
        type: string
        format: string
        maxLength: 32
      ssh_public_key:
        description: "SSH public key attribute holds the public keys of the user"
        type: string
        format: string
        maxLength: 64
      group_name_identifier:
        description: "Name that uniquely identifies a group in LDAP server"
        type: string
        format: string
        maxLength: 32
      subattribute_name:
        description: "The Sub-Attribute name for group extraction from LDAP server"
        type: string
        format: string
        maxLength: 32
      name:
        description: "Name of LDAP server"
        type: string
        format: string
        minLength: 1
        maxLength: 128
      validate_ldap_server_certs:
        description: "Validate LDAP Server Certificate"
        type: boolean
        format: boolean
      group_search_filter:
        description: "String to be combined with the default LDAP group search string to form the search value"
        type: string
        format: string
        maxLength: 128
      bind_dn:
        description: "The full distinguished name used to bind to the LDAP server"
        type: string
        format: string
        maxLength: 128
      port:
        description: "The port number on which the LDAP server is running"
        type: integer
        format: int32
      base_dn:
        description: "The base or node where the ldapsearch should start"
        type: string
        format: string
        maxLength: 128
      sec_type:
        description: "The communication type between the system and the LDAP server"
        type: string
        format: string
      max_ldap_referrals:
        description: "Maximum number of ldap referrals to follow"
        type: integer
        format: int32
      type:
        description: "The type of LDAP server"
        type: string
        format: string
        minLength: 2
        maxLength: 64
      bind_passwd:
        description: "The password used to bind to the LDAP server"
        type: string
        format: password
        maxLength: 128

  ldap_server:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the ldap servers
            type: string
            format: uuid
          address_type:
             description: "Configuration Type. Values: 0: IPv4, 1: IPv6, -1: Hostname"
             type: integer
             format: int32
      - $ref: '#/definitions/ldap_server_readwrite'

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