openapi: 3.0.1
info:
  title: User Mapping Service
  description: The User Mapping Service provides a variety of APIs for creating, deleting, and retrieving user mapping templates.
  version: '2.0'
tags:
  - name: UserMappingTemplateService
security:
  - Authorization: []
paths:
  /users/templates:
    get:
      summary: Lists down all the template names in a tenant
      description: 'Permission Level: Read'
      operationId: UserMappingTemplateService_ListUserTemplates
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v2ListUserTemplatesResponse'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/googleRpcStatus'
      parameters:
        - name: tenantId
          in: query
          required: false
          schema:
            type: string
        - name: pageToken
          description: 'MongoDB Field, describes the encoded page token for page traversal, Required: false'
          in: query
          required: false
          schema:
            type: string
        - name: pageSize
          description: 'Requested size of the next page of data. If not set, the default page size is 10, Required: false.'
          in: query
          required: false
          schema:
            type: integer
            format: int32
        - name: sortField
          description: 'Sort field, valid values: friendlyName, createdDate or lastUpdated. Default: friendlyName, Required: false'
          in: query
          required: false
          schema:
            type: string
        - name: sortType
          description: 'Sort Type for the results, Default: ASC, Required: false'
          in: query
          required: false
          schema:
            type: string
            enum:
              - NONE
              - ASC
              - DESC
            default: NONE
      tags:
        - UserMappingTemplateService
    post:
      summary: |-
        Creates a new template for the bulk import of users in the CSV format.
        Tenant Id, Template Name, List of Template Fields / Data Fields are the fields in the API where Template Fields / Data Fields is a combination of
        1) Column No - Sent as part of response starting from 0
        2) User Field
        3) Optional List of Attribute Map where attribute map is a domain -> attribute name map
      description: 'Permission Level: Read-Write'
      operationId: UserMappingTemplateService_CreateUserTemplate
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v2UserTemplateResponse'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/googleRpcStatus'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/v2CreateUserTemplateRequest'
        description: Main User Mapping Template Object.
        required: true
      tags:
        - UserMappingTemplateService
  /users/templates/download/{templateName}:
    get:
      summary: Downloads a CSV template that can be filled out and uploaded
      description: 'Permission Level: Read'
      operationId: UserMappingTemplateService_DownloadUserTemplate
      responses:
        '200':
          description: A successful response.(streaming responses)
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    $ref: '#/components/schemas/v2DownloadUserTemplateResponse'
                  error:
                    $ref: '#/components/schemas/googleRpcStatus'
                title: Stream result of v2DownloadUserTemplateResponse
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/googleRpcStatus'
      parameters:
        - name: templateName
          description: The template name, Required = true
          in: path
          required: true
          schema:
            type: string
        - name: tenantId
          description: The id of the tenant, Required = true
          in: query
          required: false
          schema:
            type: string
      tags:
        - UserMappingTemplateService
  /users/templates/{templateName}:
    get:
      summary: For fetching template details with a particular tenant name in a tenant
      description: 'Permission Level: Read'
      operationId: UserMappingTemplateService_GetUserTemplate
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v2UserTemplateResponse'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/googleRpcStatus'
      parameters:
        - name: templateName
          in: path
          required: true
          schema:
            type: string
        - name: tenantId
          in: query
          required: false
          schema:
            type: string
      tags:
        - UserMappingTemplateService
    delete:
      summary: Deletes a template by name in a tenant
      description: 'Permission Level: Read-Write'
      operationId: UserMappingTemplateService_DeleteUserTemplate
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                type: object
                properties: {}
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/googleRpcStatus'
      parameters:
        - name: templateName
          description: 'list of names of the user-mapping-template to delete, Required: true'
          in: path
          required: true
          style: simple
          schema:
            type: array
            items:
              type: string
            minItems: 1
        - name: tenantId
          description: 'Tenant id of the user-mapping-template to delete, Required: false'
          in: query
          required: false
          schema:
            type: string
      tags:
        - UserMappingTemplateService
    put:
      summary: |-
        Update an existing template by name in a tenant.
        template_name, tenant_id and template_fields to update are required.
      description: 'Permission Level: Read-Write'
      operationId: UserMappingTemplateService_UpdateUserTemplate
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v2UserTemplateResponse'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/googleRpcStatus'
      parameters:
        - name: templateName
          description: The template name, Required = true
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserMappingTemplateServiceUpdateUserTemplateBody'
        required: true
      tags:
        - UserMappingTemplateService
servers:
  - url: https://prod-ui-zwseuprod01p.pp.zebra.com/api
    description: EU Server
  - url: https://prod-ui-zwsusprod01p.pp.zebra.com/api
    description: NA Server
components:
  schemas:
    UserMappingTemplateServiceUpdateUserTemplateBody:
      type: object
      properties:
        tenantId:
          type: string
          title: The id of the tenant, Required = true
        templateFields:
          type: array
          items:
            $ref: '#/components/schemas/v2TemplateFieldProto'
          description: |-
            List of user fields, Required = true
            Users cannot leave the template fields empty, but they can update them. One column must be userId.
            If the input is empty, the existing template_fields data will be retained.
        csvSeparator:
          type: string
          title: separator between each csv field, defaults to comma, Required = false
        isHeaderDefined:
          type: boolean
          title: If the header is defining the mapping rather than column number, Required = false
        friendlyName:
          type: string
          title: Friendly Name of the template, Required = false
        updateFieldMask:
          type: string
          title: |-
            FieldMask to control what fields are to be updated, Required: false
            Valid path names (friendly_name, template_fields)
    commonsSortType:
      type: string
      enum:
        - NONE
        - ASC
        - DESC
      default: NONE
    protobufAny:
      type: object
      properties:
        '@type':
          type: string
      additionalProperties: {}
    rpcStatus:
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/protobufAny'
    v2CreateUserTemplateRequest:
      type: object
      properties:
        tenantId:
          type: string
          title: The id of the tenant, Required = true
        templateName:
          type: string
          title: The template name, Required = true
        templateFields:
          type: array
          items:
            $ref: '#/components/schemas/v2TemplateFieldProto'
          title: List of user fields, Required = true
        csvSeparator:
          type: string
          title: separator between each csv field, defaults to comma, Required = false
        isHeaderDefined:
          type: boolean
          title: If the header is defining the mapping rather than column number, Required = false
        friendlyName:
          type: string
          title: Friendly Name of the template, Required = false
      description: Main User Mapping Template Object.
    v2DownloadUserTemplateResponse:
      type: object
      properties:
        data:
          type: string
          format: byte
          title: |-
            Array of bytes representing csv file data of a header template to be filled in
            (If REST translated, it is a base64 encoded string representation of the bytes. If gRPC, it is a byte array.)
            Default comma separated CSV if no separator is defined in the user mapping template
        fileName:
          type: string
          title: Example file name to be used for the downloaded file
        csvHeader:
          type: string
          title: Header in string format
    v2ListUserTemplatesResponse:
      type: object
      properties:
        templates:
          type: array
          items:
            $ref: '#/components/schemas/v2UserMappingTemplateResponse'
          title: List of user mapping template for the given tenant
        nextPageToken:
          type: string
          title: next page token
    v2TemplateFieldProto:
      type: object
      properties:
        columnNumber:
          type: integer
          format: int32
          title: Column number that maps CSV column to user field, Required = true if header_name is false
        name:
          type: string
          title: Name of the attribute, Required = false
        scope:
          type: string
          title: Scope of the attribute. No Scope means a base level field, Required = false
        domain:
          type: string
          title: Domain of the attribute. Required = false
        separator:
          type: string
          description: The column contains multiple values separated by this sequence. Required = false.
        workspaceType:
          type: string
          title: |-
            The user will be assigned to a workspace with this workspace type
            The CSV value is the workspace name. Required = false
        isSite:
          type: boolean
          title: |-
            The user will be assigned to this site
            The CSV value is the site name. Required = false
        isRole:
          type: boolean
          title: |-
            The user will be assigned to this role
            The CSV value is the role ID. A domain and an optional scope fully define the role. Required = false
        isLicensed:
          type: boolean
          title: |-
            The user will be assigned to this license
            The CSV value is the licensed apps name. Required = false
        isPrimarySite:
          type: boolean
          title: |-
            The user will be assigned to this primarySite, note that primary_site is not dependent on scope and domain
            and as such those fields will not be captured
            The CSV value is the primarySite name. Required = false
        isSelectedDepartments:
          type: boolean
          title: |-
            The user will be assigned to these selectedDepartments, note that selected_departments are not dependent on scope and domain
            and as such those fields will not be captured
            The CSV value is the selectedDepartments names. Required = false
        isContactNumber:
          type: boolean
          title: |-
            The user will build the contact numbers List object on the contact number fields.
            When building the CSV of user data, the following field names are used:
            homeNumber - Home phone number
            mobileNumber - Mobile phone number
            officeNumber - Office phone number
        isFirstSiteMapping:
          type: boolean
          title: |-
            Denotes that this is the first site mapping field.
            All fields after this will be site mappings.
            The first site mapping will have the isPrimary flag as true
            The field that this template field is for is the siteId
            The next 6 columns will be defined as
            Available Roles (List of roleIds using delimiter defined in this template field, the scope and domain are defined in this template field)
            Default Roles (List of roleIds using delimiter defined in this template field, the scope and domain are defined in this template field)
            Persistent Roles (List of roleIds using delimiter defined in this template field, the scope and domain are defined in this template field), Auto added to Default Roles
            Available Departments (List of departmentIds using delimiter defined in this template field)
            Default Departments (List of departmentIds using delimiter defined in this template field)
            Persistent Departments (List of departmentIds using delimiter defined in this template field), Auto added to Default Departments
            Exactly In that order with all of them provided
            This pattern can be repeatedRequired for multiple site mappings = false
        headerName:
          type: string
          title: Header name that maps CSV column to user field, Required = true if column_number is false
    v2UserMappingTemplateResponse:
      type: object
      properties:
        templateName:
          type: string
          title: The template name
        friendlyName:
          type: string
          title: Friendly Name of the template
        creationTime:
          type: string
          format: date-time
          title: Time of creation of the user mapping template
        lastUpdated:
          type: string
          format: date-time
          title: Time of most recent update to the user mapping template
    v2UserTemplateResponse:
      type: object
      properties:
        tenantId:
          type: string
        templateName:
          type: string
        templateFields:
          type: array
          items:
            $ref: '#/components/schemas/v2TemplateFieldProto'
        creationTime:
          type: string
          format: date-time
        csvSeparator:
          type: string
        isHeaderDefined:
          type: boolean
          title: If the header is defining the mapping rather than column number
        friendlyName:
          type: string
          title: Friendly Name of the template
    googleRpcStatus:
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/protobufAny'
  securitySchemes:
    Authorization:
      type: apiKey
      description: Bearer token
      name: Authorization
      in: header
