openapi: 3.1.0
info:
  title: API Reference
  contact:
    name: Probation Integration Team
    url: https://moj.enterprise.slack.com/archives/C02QSERFGMB
    email: probation-integration@JusticeUK.onmicrosoft.com
  license:
    name: MIT
    url: https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/LICENSE
  version: "1.0"
servers:
- url: /
security:
- hmpps-auth-token: []
paths:
  /user/{username}/access:
    post:
      tags:
      - user-access-controller
      operationId: checkUserAccess
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: string
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserAccess"
  /user/{username}/access/{crn}:
    get:
      tags:
      - user-access-controller
      operationId: checkUserAccessForCrn
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
      - name: crn
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaseAccess"
components:
  schemas:
    CaseAccess:
      type: object
      properties:
        crn:
          type: string
        userExcluded:
          type: boolean
        userRestricted:
          type: boolean
        exclusionMessage:
          type: string
        restrictionMessage:
          type: string
      required:
      - crn
      - userExcluded
      - userRestricted
    UserAccess:
      type: object
      properties:
        access:
          type: array
          items:
            $ref: "#/components/schemas/CaseAccess"
      required:
      - access
  securitySchemes:
    hmpps-auth-token:
      type: http
      name: Authorization
      in: header
      scheme: bearer
      bearerFormat: JWT
