groups:
  - name: WebDAV Configuration
    description: Configure WebDAV
  - name: User and Group Configuration
    description: Configure User and Group for WebDAV
  - name: Network Configuration
    description: Configure Network for WebDAV
  - name: Storage Configuration
    description: Configure Storage for WebDAV
  - name: Resources Configuration
    description: Configure Resources for WebDAV

questions:
  - variable: webdavConfig
    label: ""
    group: WebDAV Configuration
    schema:
      type: dict
      attrs:
        - variable: authType
          label: Authentication Type
          description: Select the authentication type for WebDAV.
          schema:
            type: string
            default: "none"
            enum:
              - value: "none"
                description: No Authentication
              - value: "basic"
                description: Basic Authentication
        - variable: username
          label: Username
          description: The username for basic authentication.
          schema:
            type: string
            show_if: [["authType", "=", "basic"]]
            required: true
        - variable: password
          label: Password
          description: The password for basic authentication.
          schema:
            type: string
            show_if: [["authType", "=", "basic"]]
            private: true
            required: true
        - variable: additionalBrowserMatches
          label: Additional Browser Matches
          description: |
            Additional browser matches for WebDAV.</br>
            This is useful if you want to use WebDAV with a browser
            that is not supported by the default configuration.</br>
            Example: "^some-regex" </br>
            This will create the following line in the configuration file:</br>
            BrowserMatch "^some-regex" redirect-carefully
          schema:
            type: list
            default: []
            items:
              - variable: match
                label: Match
                schema:
                  type: string
                  required: true
        - variable: additionalEnvs
          label: Additional Environment Variables
          description: Configure additional environment variables for WebDAV.
          schema:
            type: list
            default: []
            items:
              - variable: env
                label: Environment Variable
                schema:
                  type: dict
                  attrs:
                    - variable: name
                      label: Name
                      schema:
                        type: string
                        required: true
                    - variable: value
                      label: Value
                      schema:
                        type: string
                        required: true

  - variable: webdavRunAs
    label: ""
    group: User and Group Configuration
    schema:
      type: dict
      attrs:
        - variable: user
          label: User ID
          description: The user id that WebDAV will run as.
          schema:
            type: int
            min: 2
            default: 666
            required: true
        - variable: group
          label: Group ID
          description: The group id that WebDAV will run as.
          schema:
            type: int
            min: 2
            default: 666
            required: true

  - variable: webdavNetwork
    label: ""
    group: Network Configuration
    schema:
      type: dict
      attrs:
        - variable: http
          label: Enable HTTP
          description: Enable HTTP for WebDAV.
          schema:
            type: boolean
            default: true
            show_subquestions_if: true
            subquestions:
              - variable: httpPort
                label: HTTP Port
                description: The port for HTTP WebDAV.
                schema:
                  type: int
                  default: 30034
                  min: 9000
                  max: 65535
                  required: true
        - variable: https
          label: Enable HTTPS
          description: Enable HTTPS for WebDAV.
          schema:
            type: boolean
            default: false
            show_subquestions_if: true
            subquestions:
              - variable: httpsPort
                label: HTTPS Port
                description: The port for HTTPS WebDAV.
                schema:
                  type: int
                  default: 30035
                  min: 9000
                  max: 65535
                  required: true
              - variable: certificateID
                label: Certificate
                description: The certificate to use for HTTPS WebDAV.
                schema:
                  type: int
                  required: true
                  "null": true
                  $ref:
                    - "definitions/certificate"
        - variable: hostNetwork
          label: Host Network
          description: |
            Bind to the host network. It's recommended to keep this disabled.</br>
          schema:
            type: boolean
            default: false

  - variable: webdavStorage
    label: ""
    group: Storage Configuration
    schema:
      type: dict
      attrs:
        - variable: shares
          label: Shares
          description: Shares for WebDAV.
          schema:
            type: list
            required: true
            default: []
            items:
              - variable: shareEntry
                label: Share Entry
                schema:
                  type: dict
                  attrs:
                    - variable: enabled
                      label: Enable the share
                      description: Enable the share.
                      schema:
                        type: boolean
                        default: true
                    - variable: name
                      label: Share Name
                      description: |
                        The name of the share.</br>
                        Also serves as the endpoint for the share.</br>
                        Example: [share1] will be available at [http://<webdav-ip>:<webdav-port>/share1]
                      schema:
                        type: string
                        valid_chars: "^[a-zA-Z0-9_-]+$"
                        valid_chars_error: "Share name can only consist of [Letters(a-z, A-Z), Numbers(0-9), Underscores(_), Dashes(-)]"
                        required: true
                    - variable: description
                      label: Description
                      description: Share description. Only used for documentation.
                      schema:
                        type: string
                    - variable: hostPath
                      label: Host Path
                      description: The host path to use for the share.
                      schema:
                        type: hostpath
                        required: true
                    - variable: readOnly
                      label: Read Only
                      description: |
                        Enable read only access to the share.</br>
                        This will disable write access to the share.</br>
                        Data will be mounted as read only.
                      schema:
                        type: boolean
                        default: false
                    - variable: maxRequestBodySizeInGB
                      label: Max Request Body Size (in GB)
                      description: |
                        The maximum size of the request body in GB.
                        If the request body size exceeds this value, the request will fail.
                        Value of 0 means no limit.
                      schema:
                        type: int
                        default: 1
                    - variable: fixPermissions
                      label: Fix Permissions
                      description: |
                        Enable permission fix for the share.</br>
                        This will fix the permissions of the share on startup.</br>
                        This will change the owner of the share to the user and group specified in [User and Group Configuration].</br>
                        Note: This will still change permissions even if [Read Only] for the share is enabled.
                      schema:
                        type: boolean
                        default: false

  - variable: resources
    group: Resources Configuration
    label: ""
    schema:
      type: dict
      attrs:
        - variable: limits
          label: Limits
          schema:
            type: dict
            attrs:
              - variable: cpu
                label: CPU
                description: CPU limit for WebDAV.
                schema:
                  type: string
                  max_length: 6
                  valid_chars: '^(0\.[1-9]|[1-9][0-9]*)(\.[0-9]|m?)$'
                  valid_chars_error: |
                    Valid CPU limit formats are</br>
                    - Plain Integer - eg. 1</br>
                    - Float - eg. 0.5</br>
                    - Milicpu - eg. 500m
                  default: "4000m"
                  required: true
              - variable: memory
                label: Memory
                description: Memory limit for WebDAV.
                schema:
                  type: string
                  max_length: 12
                  valid_chars: '^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$'
                  valid_chars_error: |
                    Valid Memory limit formats are</br>
                    - Suffixed with E/P/T/G/M/K - eg. 1G</br>
                    - Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi</br>
                    - Plain Integer in bytes - eg. 1024</br>
                    - Exponent - eg. 134e6
                  default: "8Gi"
                  required: true
