swagger: '2.0'
info:
  description: Configuration for Login/Logout resource.
  version: 'v2'
  title: login
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: login
    description: Login/Logout
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  UserSecurity:
    type: basic
security:
  - UserSecurity: []
parameters:
  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/login:
    post:
      tags:
        - login
      summary: POST operation for login
      operationId: post_login
      description: POST operation for login
      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: login
          description: login object
          schema:
              $ref: '#/definitions/addloginRequest'
      responses:
        200:
          description: add for login
          schema: 
              $ref: '#/definitions/addloginResponse'
        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:
  addloginRequest:
    type: object
    required:
      - login
    properties:
      login:
        $ref: '#/definitions/login_readwrite'
    title: addloginRequest
    example:
      login:
        ID: "string_value"
        session_timeout: "86400"
        auth_with_remote_pubkey: "0"
        confirm_new_password: "password"
        password: "password"
        challenge: "string_value"
        challenge_response: "string_value"
        client_port: "0"
        token: "abcd-1111111111-1111111111-1111111111-1111111111"
        permission: "string_value"
        new_password: "password"
        username: "nsroot"
        client_ip: "GUI"
        session_creator: "string_value"
        Secret: "string_value"

  addloginResponse:
    type: object
    required:
      - login
    properties:
      login:
        $ref: '#/definitions/login'
    title: addloginResponse
    example:
      login:
        ID: "string_value"
        session_timeout: "86400"
        auth_with_remote_pubkey: "0"
        confirm_new_password: "password"
        login_type: "string_value"
        password: "password"
        challenge: "string_value"
        challenge_response: "string_value"
        client_port: "0"
        token: "abcd-1111111111-1111111111-1111111111-1111111111"
        tenant_name: "string_value"
        force_change_password: "false"
        permission: "string_value"
        new_password: "password"
        challenge_token: "string_value"
        username: "nsroot"
        client_ip: "GUI"
        session_creator: "string_value"
        sessionid: "##CD73D85621DAF50D8ECA21D26365DB59390EF614D324BB84521D2F5401C0"
        cert_verified: "false"
        Secret: "string_value"

  login_readwrite:
    type: object
    properties:
      ID:
        description: "ID of the User that wants to login in cloud"
        type: string
        format: string
        maxLength: 128
      session_timeout:
        description: "Session Timeout in seconds, if no activity is performed for specified time then session will be expired"
        type: integer
        format: int32
      auth_with_remote_pubkey:
        description: "Login request to specify if SSH authentication took place with remote public keys for this user, 1 for remotely managed pubkey else 0"
        type: integer
        format: int32
      confirm_new_password:
        description: "Password"
        type: string
        format: password
        maxLength: 128
      password:
        description: "Password"
        type: string
        format: password
        maxLength: 128
      challenge:
        description: "Challenge request for authentication"
        type: string
        format: string
      challenge_response:
        description: "Challenge response for authentication"
        type: string
        format: password
      client_port:
        description: "Login Client port"
        type: integer
        format: int32
      token:
        description: "Random token to identify session during logout"
        type: string
        format: password
      permission:
        description: "Actions that this user is authorized to perform"
        type: string
        format: string
        minLength: 1
        maxLength: 128
      new_password:
        description: "Password"
        type: string
        format: password
        maxLength: 128
      username:
        description: "User Name that wants to login"
        type: string
        format: string
        maxLength: 128
      client_ip:
        description: "Login client IP"
        type: string
        format: IP Address
      session_creator:
        description: "session_creator"
        type: string
        format: string
      Secret:
        description: "Secret"
        type: string
        format: password
        maxLength: 128

  login:
    allOf:
      -
        properties:
          sessionid:
            description: Session ID would only be set if login was performed successfully
            type: string
            format: string
      - $ref: '#/definitions/login_readwrite'

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