# Schema: StorageReadModel
---
type: object
required:
  - id
  - _type
  - name
  - _links
properties:
  id:
    type: integer
    description: Storage id
  _type:
    type: string
    enum:
      - Storage
  name:
    type: string
    description: Storage name
  tenantId:
    type: string
    description: |-
      The tenant id of a file storage of type OneDrive/SharePoint.

      Ignored if the provider type is not OneDrive/SharePoint.
  driveId:
    type: string
    description: |-
      The drive id of a file storage of type OneDrive/SharePoint.

      Ignored if the provider type is not OneDrive/SharePoint.
  hasApplicationPassword:
    type: boolean
    description: |-
      Whether the storage has the application password to use for the Nextcloud storage.

      Ignored if the provider type is not Nextcloud.
  createdAt:
    type: string
    format: date-time
    description: Time of creation
  updatedAt:
    type: string
    format: date-time
    description: Time of the most recent change to the storage
  configured:
    type: boolean
    description: Indication, if the storage is fully configured
  _embedded:
    type: object
    properties:
      oauthApplication:
        $ref: './oauth_application_read_model.yml'
      oauthClientCredentials:
        $ref: './oauth_client_credentials_read_model.yml'
  _links:
    type: object
    required:
      - self
      - type
      - open
      - authorizationState
    properties:
      self:
        allOf:
          - $ref: './link.yml'
          - description: |-
              This storage resource. Contains the user defined storage name as title.

              **Resource**: Storage
      type:
        allOf:
          - $ref: './link.yml'
          - description: |-
              The urn of the storage type. Currently only nextcloud storages are supported.

              **Resource**: N/A
      origin:
        allOf:
          - $ref: './link.yml'
          - description: |-
              Web URI of the storage instance. This link is ignored, if the storage is hosted in a cloud and has no own
              URL, like file storages of type OneDrive/SharePoint.

              **Resource**: N/A
      open:
        allOf:
          - $ref: './link.yml'
          - description: |-
              URI of the file storage location, from where the user usually starts browsing files.

              **Resource**: N/A
      authorizationState:
        allOf:
          - $ref: './link.yml'
          - description: |-
              The urn of the storage connection state. Can be one of:

              - urn:openproject-org:api:v3:storages:authorization:Connected
              - urn:openproject-org:api:v3:storages:authorization:FailedAuthorization
              - urn:openproject-org:api:v3:storages:authorization:Error

              **Resource**: N/A
      authorize:
        allOf:
          - $ref: './link.yml'
          - description: |-
              The link to the starting point of the authorization cycle for a configured storage provider.

              # Conditions

              `authorizationState` is:

              - urn:openproject-org:api:v3:storages:authorization:FailedAuthorization

              **Resource**: N/A
      oauthApplication:
        allOf:
          - $ref: './link.yml'
          - description: |-
              The OAuth 2 provider application linked to the storage.

              # Conditions

              - User has role `admin`

              **Resource**: OAuthApplication
      oauthClientCredentials:
        allOf:
          - $ref: './link.yml'
          - description: |-
              The OAuth 2 credentials resource linked to the storage.

              # Conditions

              - User has role `admin`

              **Resource**: OAuthClientCredentials
