basePath: "/luxid-partner-api"
consumes:
  - "application/json"
info:
  description: "API used by partners"
  title: "LuxID Partner api"
  version: "1.9"
definitions:
  EmptyJson:
    type: "object"
  Error:
    properties:
      message:
        type: "string"
      type:
        type: "string"
    type: "object"
  ApplicationRefList:
    type: "object"
    properties:
      applications:
        items:
          $ref: "#/definitions/ApplicationRef"
        type: "array"
  ApplicationRef:
    type: "object"
    required:
      - "externalId"
      - "apiIdentifier"
      - "name"
    properties:
      externalId:
        type: "string"
        description: "Unique id, used as path param to identify this object."
      apiIdentifier:
        type: "string"
        description: "Client identifier to use in OIDC workflows."
      name:
        type: "string"
        description: "Displayable name, used to regroup your instances when their are multiple."
  Application:
    allOf:
      - $ref: "#/definitions/ApplicationRef"
      - type: "object"
        required:
          - "defaultInstance"
          - "instances"
        properties:
          defaultInstance:
            description: "The default instance."
            $ref: "#/definitions/ApplicationInstance"
          instances:
            description: "All instances of this application (including the default)."
            type: "array"
            items:
              $ref: "#/definitions/ApplicationInstance"
  ApplicationInstance:
    type: "object"
    description: "An instance of your app. Usually, applications will have only one instance (the \"default\"), but you may have multiple (for beta, or different tenants, etc.)."
    required:
      - "externalId"
      - "name"
      - "isDefault"
    properties:
      externalId:
        type: "string"
        description: "Unique id, used as path param to identify this object."
      name:
        type: "string"
        description: "Displayable name."
      isDefault:
        type: "boolean"
        description: "True if this instance is the default, false otherwise."
      url:
        type: "string"
        description: "URL of this application instance."
      description:
        type: "string"
        description: "Displayable description."
  GroupList:
    type: "object"
    properties:
      groups:
        items:
          $ref: "#/definitions/Group"
        type: "array"
  Group:
    type: "object"
    required:
      - "name"
    properties:
      name:
        type: "string"
      description:
        type: "string"
  GroupMembershipList:
    type: "object"
    properties:
      memberships:
        items:
          $ref: "#/definitions/GroupMembership"
        type: "array"
  GroupMembership:
    type: "object"
    required:
      - "groupName"
    properties:
      groupName:
        type: "string"
      accountEmail:
        description: "Could be null in rare cases of legacy accounts"
        type: "string"
  GroupMembershipsBulkActionEnum:
    type: "string"
    enum:
      - "ADD"
      - "REMOVE"
  Subscription:
    type: "object"
    required:
      - "subscriberExtId"
      - "applicationExtId"
      - "beginDate"
    properties:
      subscriberExtId:
        type: "string"
      applicationExtId:
        type: "string"
      beginDate:
        type: "string"
        format: "date-time"
  ClaimValue:
    type: "object"
    required:
      - "value"
    properties:
      value:
        type: "string"
  EventList:
    type: "object"
    required:
      - "page"
      - "pageSize"
      - "total"
    properties:
      page:
        description: "The number of this page (> 0)."
        type: "number"
        format: "integer"
      pageSize:
        description: "The max number of items per page (> 0)."
        type: "number"
        format: "integer"
      total:
        description: "The total number of items, on all pages (>= 0)."
        type: "number"
        format: "integer"
      items:
        items:
          $ref: "#/definitions/Event"
        type: "array"
  Event:
    type: "object"
    required:
      - "id"
      - "timestamp"
      - "type"
    properties:
      id:
        type: "string"
        description: "Unique id of this event."
      timestamp:
        type: "string"
        format: "date-time"
        description: "Timestamp at which this event was generated."
      type:
        type: "string"
        description: "Type of the event. The type defines the content of the payload."
      version:
        type: "string"
        description: "Version of the event. The content of the payload may vary from a version to another."
      sphere:
        type: "string"
        description: "The sphere in which the event occurred, if applicable."
      subscriber:
        type: "string"
        description: "The subscriber concerned by the event, if applicable."
      application:
        type: "string"
        description: "The application concerned by the event, if applicable."
      subscription:
        type: "string"
        description: "The subscription concerned by the event, if applicable."
      payload:
        type: "object"
        description: "The payload specific to this event type, if applicable."
        schema:
          additionalProperties: true
paths:
  /applications:
    get:
      summary: "Get all applications managed by calling partner"
      operationId: "getAllApplications"
      tags:
        - "Applications"
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/ApplicationRefList"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
  /applications/{applicationExtId}:
    get:
      summary: "Get single application"
      operationId: "getApplication"
      tags:
        - "Applications"
      parameters:
        - in: "path"
          name: "applicationExtId"
          type: "string"
          required: true
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/Application"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
  /applications/{applicationExtId}/groups:
    get:
      summary: "Get list of groups of the application"
      operationId: "getApplicationGroups"
      tags:
        - "Applications"
      parameters:
        - in: "path"
          name: "applicationExtId"
          type: "string"
          required: true
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/GroupList"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
  /applications/{applicationExtId}/subscriptions/{subscriberExtId}/current:
    get:
      summary: "Get current subscription details"
      operationId: "getCurrentSubscription"
      tags:
        - "ApplicationSubscriptions"
      parameters:
        - in: "path"
          name: "applicationExtId"
          type: "string"
          required: true
        - in: "path"
          name: "subscriberExtId"
          type: "string"
          required: true
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/Subscription"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        403:
          description: "Forbidden"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
    delete:
      summary: "Remove the current subscription from the application"
      operationId: "deleteCurrentSubscription"
      tags:
        - "ApplicationSubscriptions"
      parameters:
        - in: "path"
          name: "applicationExtId"
          type: "string"
          required: true
        - in: "path"
          name: "subscriberExtId"
          type: "string"
          required: true
      responses:
        200:
          description: "Success"
          schema:
            type: "object"
            title: "DeleteApplicationSubscriptionResponse"
            required:
              - "removalDate"
            properties:
              removalDate:
                type: "string"
                format: "date-time"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        403:
          description: "Forbidden"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
  /groups/{groupName}/memberships:
    get:
      summary: "Get members of a group"
      operationId: "getGroupMemberships"
      tags:
        - "Groups"
      parameters:
        - in: "path"
          name: "groupName"
          required: true
          type: "string"
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/GroupMembershipList"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        403:
          description: "Forbidden"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
  /accounts/{md5HashOfLowercaseEmail}/memberships:
    get:
      summary: "Get group memberships of an account. Only groups managed by the calling partner are returned."
      operationId: "getAccountMemberships"
      tags:
        - "Groups"
      parameters:
        - in: "path"
          name: "md5HashOfLowercaseEmail"
          description: "The MD5 hash of the lowercased, trimmed email address of the account."
          required: true
          type: "string"
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/GroupMembershipList"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        403:
          description: "Forbidden"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
  /accounts/{md5HashOfLowercaseEmail}/applications/{applicationExtId}/subscriptions:
    get:
      summary: "Get current subscription details based on email"
      operationId: "getCurrentEmailSubscription"
      tags:
        - "ApplicationSubscriptions"
      parameters:
        - in: "path"
          name: "applicationExtId"
          type: "string"
          required: true
        - in: "path"
          name: "md5HashOfLowercaseEmail"
          description: "The MD5 hash of the lowercased, trimmed email address of the account."
          required: true
          type: "string"
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/Subscription"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        403:
          description: "Forbidden"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
  /bulk-actions/group-memberships:
    post:
      summary: "Add/Remove accounts into/from groups"
      operationId: "editGroupMemberships"
      tags:
        - "Groups"
      parameters:
        - in: "body"
          name: "body"
          required: true
          schema:
            title: "GroupMembershipsBulkActionPostRequest"
            type: "object"
            properties:
              actions:
                type: "array"
                description: "List of actions to perform on group memberships. The parter must be manager of the target group(s). List must not contain duplicate (account, group) pair. List is limited to 20 actions max."
                items:
                  title: "GroupMembershipsBulkAction"
                  type: "object"
                  required:
                    - "action"
                    - "accountEmail"
                    - "groupName"
                  properties:
                    action:
                      $ref: "#/definitions/GroupMembershipsBulkActionEnum"
                    accountEmail:
                      type: "string"
                    groupName:
                      type: "string"
      responses:
        200:
          description: "Success"
          schema:
            title: "GroupMembershipsBulkActionPostResponse"
            type: "object"
            properties:
              actions:
                type: "array"
                description: "List of actions to perform on group memberships"
                items:
                  title: "GroupMembershipsBulkActionResult"
                  type: "object"
                  required:
                    - "action"
                    - "accountEmail"
                    - "groupName"
                    - "result"
                  properties:
                    action:
                      $ref: "#/definitions/GroupMembershipsBulkActionEnum"
                    accountEmail:
                      type: "string"
                    groupName:
                      type: "string"
                    result:
                      type: "string"
                      description: "Result of the action"
                      enum:
                        - "ACCOUNT_NOT_FOUND"
                        - "GROUP_NOT_FOUND"
                        - "GROUP_FORBIDDEN"
                        - "ACCOUNT_ADDED_TO_GROUP"
                        - "ACCOUNT_REMOVED_FROM_GROUP"
                        - "ACCOUNT_ALREADY_IN_GROUP"
                        - "ACCOUNT_ALREADY_NOT_IN_GROUP"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
  /subscribers/{subscriberExtId}/claims/{claimName}:
    put:
      summary: "Set claim value of a member"
      operationId: "setMemberClaimValue"
      tags:
        - "Claims"
      parameters:
        - in: "path"
          name: "subscriberExtId"
          type: "string"
          required: true
        - in: "path"
          name: "claimName"
          type: "string"
          required: true
        - in: "body"
          name: "body"
          required: true
          schema:
            $ref: "#/definitions/ClaimValue"
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/EmptyJson"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        403:
          description: "Forbidden"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
    delete:
      summary: "Remove claim value of a member"
      operationId: "removeMemberClaimValue"
      tags:
        - "Claims"
      parameters:
        - in: "path"
          name: "subscriberExtId"
          type: "string"
          required: true
        - in: "path"
          name: "claimName"
          type: "string"
          required: true
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/EmptyJson"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        403:
          description: "Forbidden"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
  /events/search:
    get:
      summary: "Search for events"
      description: "Search for user events that occured between the provided 'from' and 'to' timestamps. Format must be ISO-8601: '2018-08-17T07:00:00'. Viewed events depend on the caller of this endpoint."
      operationId: "getEvents"
      tags:
        - "EventHub"
      parameters:
        - in: "query"
          name: "from"
          description: "The 'from' timestamp (included)."
          type: "string"
          format: "date-time"
          required: true
        - in: "query"
          name: "to"
          description: "The 'to' timestamp (excluded)."
          type: "string"
          format: "date-time"
          required: true
        - in: "query"
          name: "page"
          description: "Page number to retrieve, zero-based. Default to 0 if not provided."
          type: "integer"
          format: "int32"
          default: 0
        - in: "query"
          name: "pageSize"
          description: "Max number of events to retrieve at once, must be > 0. Default to 10 if not provided."
          type: "integer"
          format: "int32"
          default: 10
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/EventList"
        400:
          description: "Functional error"
          schema:
            $ref: "#/definitions/Error"
        403:
          description: "Forbidden"
          schema:
            $ref: "#/definitions/Error"
        404:
          description: "Not found"
          schema:
            $ref: "#/definitions/Error"
produces:
  - "application/json"
schemes:
  - "https"
security:
  - clientIdHeader: []
    clientSecretHeader: []
securityDefinitions:
  clientIdHeader:
    in: "header"
    name: "X-Client-Id"
    type: "apiKey"
  clientSecretHeader:
    in: "header"
    name: "X-Client-Secret"
    type: "apiKey"
swagger: "2.0"
host: "api.luxid.lu/services"
