openapi: 3.0.1
info:
  description: ''
  title: WorkCloud Communication Services Admin — SIP Trunk
  contact: {}
  version: 1.29.25101.015
paths:
  /api/v1/sip/trunk:
    post:
      security:
        - PhoenixToken-Authorization: []
      description: Takes a SIP trunk JSON and store in DB. Return saved JSON.
      tags:
        - SipTrunk
      summary: Creates SIP trunk
      parameters:
        - description: tenant id of required records
          name: tenant_id
          in: query
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/main.SipTrunkDTO'
        description: SipTrunk JSON
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.SipTrunkUpdatedDTO'
  /api/v1/sip/trunk/assign/{trunk_id}:
    patch:
      security:
        - PhoenixToken-Authorization: []
      description: Assign SipTrunk to SBC instance
      tags:
        - SipTrunk
      summary: Assign SipTrunk to SBC instance
      parameters:
        - description: tenant id of required records
          name: tenant_id
          in: query
          required: true
          schema:
            type: string
        - description: name of SBC instance
          name: sbc
          in: query
          required: true
          schema:
            type: string
        - description: id of existing SipTrunk record
          name: trunk_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.SipTrunkUpdatedDTO'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
  /api/v1/sip/trunk/status/{trunk_id}:
    get:
      security:
        - PhoenixToken-Authorization: []
      description: Get current status of the SipTrunk
      tags:
        - SipTrunk
      summary: Get SipTrunk Status
      parameters:
        - description: tenant id of required records
          name: tenant_id
          in: query
          required: true
          schema:
            type: string
        - description: id of existing SIP Trunk
          name: trunk_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/main.SipTrunkStatusResponseBody'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
  /api/v1/sip/trunk/{trunk_id}:
    put:
      security:
        - PhoenixToken-Authorization: []
      description: Edit a SipTrunk from sip_trunk table based on SipTrunk id
      tags:
        - SipTrunk
      summary: Edit a SipTrunk
      parameters:
        - description: tenant id of required records
          name: tenant_id
          in: query
          required: true
          schema:
            type: string
        - description: id of existing SipTrunk record
          name: trunk_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/main.SipTrunkDTO'
        description: Updated SipTrunk Info
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.SipTrunkUpdatedDTO'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
    delete:
      security:
        - PhoenixToken-Authorization: []
      description: Delete a SipTrunk from sip_trunk table based on SipTrunk id
      tags:
        - SipTrunk
      summary: Delete SipTrunk
      parameters:
        - description: tenant id of required records
          name: tenant_id
          in: query
          required: true
          schema:
            type: string
        - description: id of existing SIP Trunk
          name: trunk_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/main.deleteSipTrunkResponseBody'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
  /api/v1/sip/trunks:
    get:
      security:
        - PhoenixToken-Authorization: []
      description: Lists all SIP Trunk
      tags:
        - SipTrunk
      summary: View All SIP Trunk
      parameters:
        - description: page number for returned records
          name: page
          in: query
          schema:
            type: integer
            default: 0
        - description: number of records to return per page.
          name: page_size
          in: query
          schema:
            type: integer
            default: 100
        - description: record field to sort by
          name: sort_by
          in: query
          schema:
            type: string
            default: id
        - description: direction to sort records
          name: sort_order
          in: query
          schema:
            type: string
            enum:
              - asc
              - desc
            default: asc
        - description: tenant id of required records
          name: tenant_id
          in: query
          required: true
          schema:
            type: string
        - description: trunk name of required records
          name: trunk_name
          in: query
          schema:
            type: string
        - description: site/region id of required records
          name: site_id
          in: query
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/main.getSIPTrunkResponseBody'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/dto.HTTPStatus'
components:
  securitySchemes:
    PhoenixToken-Authorization:
      description: PhoenixToken-Authorization
      type: apiKey
      name: Authorization
      in: header
  schemas:
    dto.CustomerAdminDTO:
      type: object
      properties:
        auth_data:
          type: array
          items:
            type: integer
        auth_type:
          type: string
        clsid:
          type: string
        country:
          type: string
        created_at:
          type: string
        deleted:
          type: boolean
        description:
          type: string
        extra:
          type: array
          items:
            type: integer
        id:
          type: integer
        jwks_uri:
          type: string
        name:
          type: string
        profile:
          type: string
        tenant_id:
          type: string
        token:
          type: string
        updated_at:
          type: string
    dto.ExternalAppResponseDTO:
      type: object
      properties:
        id:
          description: External App ID, ignored when new app/user added
          type: integer
          format: int64
        name:
          description: |-
            If TRUE, this will be base webhook for site/region. External application must provide list of targets in query parameters.
             'user' an userlogin from TgtName tree
             'group' a group name from TgtName tree
             'site' a site name from TgtName tree
             'region' a region name from TgtName tree
            Base bool `json:"base"`
            External App/User name - unique for a customer
          type: string
        regionName:
          type: string
        siteName:
          description: "UserLogin    *string `db:\"userlogin\" json:\"userName,omitempty\"`\n\tGroupName    *string `db:\"name\" json:\"grpName,omitempty\"`\n\tDepName      *string `db:\"name\" json:\"depName,omitempty\"`\n\tRoleName     *string `db:\"name\" json:\"roleName,omitempty\"`\n\tLocationName *string `db:\"name\" json:\"locName,omitempty\"`"
          type: string
        url:
          description: External URL to post message
          type: string
    dto.ExternalAppUrlDTO:
      type: object
      properties:
        forum_post_url:
          description: External URL to create forum posts
          type: string
        forum_url:
          description: External URL to create forum
          type: string
        message_url:
          description: External URL to post message
          type: string
    dto.ExternalPartnerAppResponseDTO:
      type: object
      properties:
        id:
          description: External App ID, ignored when new app/user added
          type: integer
          format: int64
        name:
          description: |-
            If TRUE, this will be base webhook for site/region. External application must provide list of targets in query parameters.
             'user' an userlogin from TgtName tree
             'group' a group name from TgtName tree
             'site' a site name from TgtName tree
             'region' a region name from TgtName tree
            Base bool `json:"base"`
            External App/User name - unique for a customer
          type: string
        regionName:
          type: string
        siteName:
          description: "UserLogin    *string `db:\"userlogin\" json:\"userName,omitempty\"`\n\tGroupName    *string `db:\"name\" json:\"grpName,omitempty\"`\n\tDepName      *string `db:\"name\" json:\"depName,omitempty\"`\n\tRoleName     *string `db:\"name\" json:\"roleName,omitempty\"`\n\tLocationName *string `db:\"name\" json:\"locName,omitempty\"`"
          type: string
        webhook_urls:
          $ref: '#/components/schemas/dto.ExternalAppUrlDTO'
    dto.HTTPStatus:
      type: object
      properties:
        code:
          type: integer
          example: 0
        message:
          type: string
          example: Success
    dto.HttpHeader:
      type: object
      properties:
        name:
          type: string
        value:
          type: string
    dto.NewExternalAppDTO:
      type: object
      properties:
        name:
          description: External App/User name - unique for a customer
          type: string
        regionName:
          type: string
        siteName:
          description: "UserLogin    *string `db:\"userlogin\" json:\"userName,omitempty\"`\n\tGroupName    *string `db:\"name\" json:\"grpName,omitempty\"`\n\tDepName      *string `db:\"name\" json:\"depName,omitempty\"`\n\tRoleName     *string `db:\"name\" json:\"roleName,omitempty\"`\n\tLocationName *string `db:\"name\" json:\"locName,omitempty\"`"
          type: string
    dto.NewWebhookDTO:
      type: object
      properties:
        body:
          description: Request body
          type: string
        description:
          description: Description
          type: string
        name:
          description: External App/User name - unique for a customer
          type: string
        options:
          description: Extra request options (optional)
          allOf:
            - $ref: '#/components/schemas/dto.WebhookOptions'
        site:
          description: A site/region where this webhook can be used
          type: string
        url:
          description: Webhook Request URL
          type: string
    dto.SipDidDTO:
      type: object
      properties:
        dialplan:
          type: string
        id:
          type: integer
        targets:
          type: array
          items:
            $ref: '#/components/schemas/dto.SipDidTarget'
        trunk_id:
          type: integer
        updated_at:
          type: string
    dto.SipDidTarget:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        type:
          type: integer
    dto.SipTrunkUpdatedDTO:
      type: object
      properties:
        customer_id:
          type: integer
        id:
          type: integer
        params:
          type: array
          items:
            type: integer
        sbc_name:
          type: string
        site_id:
          type: integer
        site_name:
          type: string
        trunk_name:
          type: string
        updated_at:
          type: string
    dto.UserProfileDTOResp:
      type: object
      properties:
        customer_id:
          type: integer
        id:
          type: integer
        name:
          type: string
        value:
          type: array
          items:
            type: integer
    dto.WebhookDTO:
      type: object
      properties:
        body:
          description: Request body
          type: string
        description:
          description: Description
          type: string
        id:
          description: ID
          type: integer
          format: int64
        name:
          description: External App name. It will be recognized if added in text message as @name
          type: string
        options:
          description: Extra request options (optional)
          allOf:
            - $ref: '#/components/schemas/dto.WebhookOptions'
        site:
          description: A site/region where this webhook can be used
          type: string
        url:
          description: Webhook Request URL
          type: string
    dto.WebhookOptions:
      type: object
      properties:
        headers:
          description: Optional list of http headers
          type: array
          items:
            $ref: '#/components/schemas/dto.HttpHeader'
        method:
          description: Request method
          type: string
    main.AssignProfile:
      type: object
      properties:
        profile_name:
          type: string
        tgt_name:
          type: string
        tgt_type:
          $ref: '#/components/schemas/model.TargetType'
    main.ErrorBody:
      type: object
      properties:
        errors:
          type: array
          items:
            type: string
          example:
            - '[]'
        message:
          type: string
          example: query parameters are malformed in the URI
    main.GetUserProfileBYIDResponseBody:
      type: object
      properties:
        is_tenant:
          type: boolean
        regions:
          type: array
          items:
            $ref: '#/components/schemas/model.Site'
        sites:
          type: array
          items:
            $ref: '#/components/schemas/model.Site'
        user_profile:
          $ref: '#/components/schemas/dto.UserProfileDTOResp'
        users:
          type: array
          items:
            $ref: '#/components/schemas/model.Suser'
    main.GetUserProfileResponseBody:
      type: object
      properties:
        total_rows:
          type: integer
        user_profile:
          type: array
          items:
            $ref: '#/components/schemas/dto.UserProfileDTOResp'
    main.SipTrunkDTO:
      type: object
      properties:
        params:
          type: array
          items:
            type: integer
        site_name:
          type: string
        trunk_name:
          type: string
    main.SipTrunkStatusResponseBody:
      type: object
      properties:
        details:
          type: string
        sbc_name:
          type: string
        status:
          type: integer
        trunk_id:
          type: integer
        trunk_name:
          type: string
        updated_at:
          type: string
    main.UserProfileDTO:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        value:
          type: array
          items:
            type: integer
    main.createSipDialplanInput:
      type: object
      properties:
        dialplan:
          type: string
        trunk_id:
          type: integer
    main.deleteSipDialplanResponseBody:
      type: object
      properties:
        num_rows_deleted:
          type: integer
    main.deleteSipTrunkResponseBody:
      type: object
      properties:
        num_rows_deleted:
          type: integer
    main.deleteSiteResponseBody:
      type: object
      properties:
        num_rows_deleted:
          type: integer
    main.deleteUserProfileResponseBody:
      type: object
      properties:
        num_rows_deleted:
          type: integer
    main.getCustomerResponseBody:
      type: object
      properties:
        customers:
          type: array
          items:
            $ref: '#/components/schemas/dto.CustomerAdminDTO'
        total_rows:
          type: integer
    main.getDeviceResponseBody:
      type: object
      properties:
        devices:
          type: array
          items:
            $ref: '#/components/schemas/model.Device'
        total_rows:
          type: integer
    main.getGroupInfoResponseBody:
      type: object
      properties:
        group_info:
          type: array
          items:
            $ref: '#/components/schemas/model.GroupInfo'
        total_rows:
          type: integer
    main.getGroupTargetResponseBody:
      type: object
      properties:
        group_targets:
          type: array
          items:
            $ref: '#/components/schemas/model.GroupTarget'
        total_rows:
          type: integer
    main.getRegionResponseBody:
      type: object
      properties:
        region:
          $ref: '#/components/schemas/model.Site'
    main.getRegionsResponseBody:
      type: object
      properties:
        regions:
          type: array
          items:
            $ref: '#/components/schemas/model.Site'
        total_rows:
          type: integer
    main.getSBCResponseBody:
      type: object
      properties:
        sbc:
          type: array
          items:
            $ref: '#/components/schemas/model.Sbc'
        total_rows:
          type: integer
    main.getSIPTrunkResponseBody:
      type: object
      properties:
        sip_trunks:
          type: array
          items:
            $ref: '#/components/schemas/dto.SipTrunkUpdatedDTO'
        total_rows:
          type: integer
    main.getSipDialplanResponseBody:
      type: object
      properties:
        sip_dialplans:
          type: array
          items:
            $ref: '#/components/schemas/model.SipDialplan'
        total_rows:
          type: integer
    main.getSipDidResponseBody:
      type: object
      properties:
        sip_dids:
          type: array
          items:
            $ref: '#/components/schemas/dto.SipDidDTO'
        total_rows:
          type: integer
    main.getSiteResponseBody:
      type: object
      properties:
        sites:
          type: array
          items:
            $ref: '#/components/schemas/model.Site'
        total_rows:
          type: integer
    main.getSuserResponseBody:
      type: object
      properties:
        susers:
          type: array
          items:
            $ref: '#/components/schemas/model.Suser'
        total_rows:
          type: integer
    main.pbxType:
      type: object
      properties:
        display_name:
          type: string
        profile_type:
          type: string
    main.sipDidInput:
      type: object
      properties:
        dialplan:
          type: string
        targets:
          type: array
          items:
            $ref: '#/components/schemas/dto.SipDidTarget'
        trunk_id:
          type: integer
    main.sipDidUpdate:
      type: object
      properties:
        dialplan:
          type: string
        targets:
          type: array
          items:
            $ref: '#/components/schemas/dto.SipDidTarget'
    main.updateSipDialplanInput:
      type: object
      properties:
        dialplan:
          type: string
    model.ConfigParameter:
      type: object
      properties:
        category:
          type: string
        description:
          type: string
        domain:
          type: string
        groupname:
          type: string
        param_default:
          type: string
        param_key:
          type: string
        param_max:
          type: string
        param_min:
          type: string
        param_type:
          type: string
        param_values:
          type: string
        scope:
          type: string
        shown_on_client:
          type: boolean
        updated_at:
          type: string
    model.Customer:
      type: object
      properties:
        auth_data:
          type: string
        auth_type:
          type: string
        clsid:
          type: string
        country:
          type: string
        created_at:
          type: string
        deleted:
          type: boolean
        description:
          type: string
        extra:
          type: string
        id:
          type: integer
        jwks_uri:
          type: string
        name:
          type: string
        profile:
          type: string
        tenant_id:
          type: string
        token:
          type: string
        updated_at:
          type: string
    model.Device:
      type: object
      properties:
        created_at:
          type: string
        customer_id:
          type: integer
        deleted:
          type: boolean
        did:
          type: string
        id:
          type: integer
        model:
          type: string
        os:
          type: string
        site_id:
          type: integer
        state:
          type: integer
        updated_at:
          type: string
        version:
          type: string
    model.GroupInfo:
      type: object
      properties:
        created_at:
          type: string
        customer_id:
          type: integer
        deleted:
          type: boolean
        description:
          type: string
        group_type:
          type: integer
        id:
          type: integer
        logo:
          type: string
        name:
          type: string
        open:
          type: boolean
        pl_group_id:
          type: string
        site_id:
          type: integer
        updated_at:
          type: string
    model.GroupTarget:
      type: object
      properties:
        dep_id:
          type: integer
        extension:
          type: string
        group_id:
          type: integer
        grp_id:
          type: integer
        id:
          type: integer
        loc_id:
          type: integer
        region_id:
          type: integer
        role_id:
          type: integer
        site_id:
          type: integer
        tgt_perm:
          type: string
        user_id:
          type: integer
    model.Sbc:
      type: object
      properties:
        description:
          type: string
        name:
          type: string
        registered:
          type: integer
        total:
          type: integer
        updated_at:
          type: string
    model.SipDialplan:
      type: object
      properties:
        dialplan:
          type: string
        id:
          type: integer
        trunk_id:
          type: integer
        updated_at:
          type: string
    model.Site:
      type: object
      properties:
        created_at:
          type: string
        customer_id:
          type: integer
        deleted:
          type: boolean
        description:
          type: string
        display_name:
          type: string
        domain:
          type: string
        id:
          type: integer
        name:
          type: string
        parent:
          type: integer
        part:
          type: integer
        profile:
          type: string
        site_type:
          type: integer
        updated_at:
          type: string
    model.Suser:
      type: object
      properties:
        alias:
          type: string
        created_at:
          type: string
        customer_id:
          type: integer
        deleted:
          type: boolean
        email:
          type: string
        firstname:
          type: string
        id:
          type: integer
        language:
          type: string
        lastname:
          type: string
        oauthname:
          type: string
        phone:
          type: string
        photo:
          type: string
        platform_user_id:
          type: string
        profile:
          type: string
        shared_secret:
          type: string
        site_id:
          type: integer
        updated_at:
          type: string
        user_type:
          type: integer
        userlogin:
          type: string
    model.TargetType:
      type: integer
      enum:
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
        - 6
        - 7
        - 10
      x-enum-varnames:
        - TgtTypeUser
        - TgtTypeGroup
        - TgtTypeSite
        - TgtTypeRegion
        - TgtTypeLocation
        - TgtTypeAddHocLocation
        - TgtTypeDepartment
        - TgtTypeRole
        - TgtTypeSip
    model.TwilioAccount:
      type: object
      properties:
        created_at:
          type: string
        customer_id:
          type: integer
        deleted:
          type: boolean
        description:
          type: string
        id:
          type: integer
        name:
          type: string
        response:
          type: string
        sid:
          type: string
        token:
          type: string
        url:
          type: string
    rmq.SetLogLevelMessage:
      type: object
      properties:
        component:
          description: 'pod name or prefix: zac-zsfs-0, zac-zsfs,..., "all" - applies to all component'
          type: string
        level:
          description: 'log level string: trace, debug, ...'
          type: string
