# Naming conventions:
# - Post*: Schemas for POST requests
# - Get*: Schemas for GET requests
# Good resources:
# - Spring Petclinic: https://github.com/spring-petclinic/spring-petclinic-rest/blob/master/src/main/resources/openapi.yml
openapi: 3.0.1
info:
  title: Confluent Manager for Apache Flink / CMF
  description: Apache Flink job lifecycle management component for Confluent Platform.
  version: '1.0'
servers:
  - url: http://localhost:8080
tags:
  - name: Environments
  - name: FlinkApplications
  - name: Secrets
  - name: SQL
  - name: Savepoints

paths:
  ## ---------------------------- Environments API ---------------------------- ##
  /cmf/api/v1/environments:
    post:
      tags:
        - Environments
      operationId: createOrUpdateEnvironment
      summary: Create or update an Environment
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostEnvironment'
            examples:
              basic-environment:
                summary: Basic Environment
                value:
                  name: "production"
                  kubernetesNamespace: "flink-production"
                  flinkApplicationDefaults:
                    spec:
                      flinkConfiguration:
                        taskmanager.numberOfTaskSlots: "4"
                        rest.profiling.enabled: "true"
                      jobManager:
                        resource:
                          memory: "1024m"
                          cpu: 1
                      taskManager:
                        resource:
                          memory: "1024m"
                          cpu: 1
                  computePoolDefaults:
                    clusterSpec:
                      flinkVersion: "v1_19"
                      image: "confluentinc/cp-flink-sql:1.19-cp5"
                      flinkConfiguration:
                        taskmanager.numberOfTaskSlots: "4"
                  statementDefaults:
                    detached:
                      flinkConfiguration:
                        "state.backend.type": "hashmap"
                    interactive:
                      flinkConfiguration:
                        "state.backend.type": "hashmap"
          application/yaml:
            schema:
              $ref: '#/components/schemas/PostEnvironment'
            examples:
              basic-environment-yaml:
                summary: Basic Environment (YAML)
                value:
                  name: "staging"
                  kubernetesNamespace: "flink-staging"
                  flinkApplicationDefaults:
                    spec:
                      flinkConfiguration:
                        taskmanager.numberOfTaskSlots: "2"
                        rest.profiling.enabled: "true"
                      jobManager:
                        resource:
                          memory: "1024m"
                          cpu: 1
                      taskManager:
                        resource:
                          memory: "1024m"
                          cpu: 1
        required: true
      responses:
        201:
          description: The Environment was successfully created or updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Environment'
              examples:
                created-environment:
                  summary: Created Environment
                  value:
                    name: "production"
                    kubernetesNamespace: "flink-production"
                    created_time: "2024-01-15T10:30:00Z"
                    updated_time: "2024-01-15T10:30:00Z"
                    flinkApplicationDefaults:
                      spec:
                        flinkConfiguration:
                          taskmanager.numberOfTaskSlots: "4"
                          rest.profiling.enabled: "true"
                        jobManager:
                          resource:
                            memory: "1024m"
                            cpu: 1
                        taskManager:
                          resource:
                            memory: "1024m"
                            cpu: 1
                    computePoolDefaults:
                      clusterSpec:
                        flinkVersion: "v1_19"
                        image: "confluentinc/cp-flink-sql:1.19-cp5"
                        flinkConfiguration:
                          taskmanager.numberOfTaskSlots: "4"
                    statementDefaults:
                      detached:
                        flinkConfiguration:
                          "state.backend.type": "hashmap"
                      interactive:
                        flinkConfiguration:
                          "state.backend.type": "hashmap"
                    secrets: {}
            application/yaml:
              schema:
                $ref: '#/components/schemas/Environment'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
              examples:
                validation-error:
                  summary: Validation Error
                  value:
                    errors:
                      - message: "name: size must be between 4 and 2147483647"
                      - message: "Environment's kubernetesNamespace 'fl' does not exist."
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - Environments
      operationId: getEnvironments
      summary: Retrieve a paginated list of all environments.
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - $ref: '#/components/parameters/includeResourceInformationParam'
      responses:
        200:
          description: List of environments found. If no environments are found, an empty list is returned. Note the information about secret is not included in the list call yet. In order to get the information about secret, make a getSecret call.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvironmentsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/EnvironmentsPage'
        304:
          description: Not modified.
          headers:
            ETag:
              description: An ID for this version of the response.
              schema:
                type: string
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}:
    get:
      operationId: getEnvironment
      tags:
        - Environments
      summary: Get/Describe an environment with the given name.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment to be retrieved.
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/includeResourceInformationParam'
      responses:
        200:
          description: Environment found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Environment'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Environment'
        404:
          description: Environment not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      operationId: deleteEnvironment
      tags:
        - Environments
      parameters:
        - name: envName
          in: path
          description: Name of the Environment to be deleted.
          required: true
          schema:
            type: string
      responses:
        200:
          description: Environment found and deleted.
        304:
          description: Not modified.
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: Environment not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  ## ---------------------------- Applications API ---------------------------- ##
  /cmf/api/v1/environments/{envName}/applications:
    post:
      tags:
        - FlinkApplications
      operationId: createOrUpdateApplication
      summary: Creates a new Flink Application or updates an existing one in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
          example: "production"
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FlinkApplication'
            examples:
              basic-application:
                summary: Basic Flink Application
                value:
                  apiVersion: "cmf.confluent.io/v1"
                  kind: "FlinkApplication"
                  metadata:
                    name: "state-machine"
                    labels:
                      app: "state-machine"
                      environment: "production"
                    annotations:
                      description: "Real-time fraud detection application"
                  spec:
                    image: "confluentinc/cp-flink:1.19.3-cp2"
                    flinkVersion: "v1_19"
                    flinkConfiguration:
                      taskmanager.numberOfTaskSlots: "2"
                      metrics.reporter.prom.factory.class: "org.apache.flink.metrics.prometheus.PrometheusReporterFactory"
                      metrics.reporter.prom.port: "9249-9250"
                    serviceAccount: "flink"
                    jobManager:
                      resource:
                        memory: "1024m"
                        cpu: 1
                    taskManager:
                      resource:
                        memory: "1024m"
                        cpu: 1
                    job:
                      jarURI: "local:///opt/flink/examples/streaming/StateMachineExample.jar"
                      state: "running"
                      parallelism: 2
                      upgradeMode: "stateless"
          application/yaml:
            schema:
              $ref: '#/components/schemas/FlinkApplication'
            examples:
              yaml-application:
                summary: Flink Application (YAML)
                value:
                  apiVersion: cmf.confluent.io/v1
                  kind: FlinkApplication
                  metadata:
                    name: news-aggregator
                    labels:
                      app: news-aggregator
                      environment: staging
                  spec:
                    image: confluentinc/cp-flink:1.19.3-cp2
                    flinkVersion: v1_19
                    flinkConfiguration:
                      taskmanager.numberOfTaskSlots: "4"
                      metrics.reporter.prom.factory.class: org.apache.flink.metrics.prometheus.PrometheusReporterFactory
                      metrics.reporter.prom.port: "9249-9250"
                    serviceAccount: flink
                    jobManager:
                      resource:
                        memory: "1024m"
                        cpu: 1
                    taskManager:
                      resource:
                        memory: "1024m"
                        cpu: 1
                    job:
                      jarURI: "local:///opt/flink/examples/streaming/WordCount.jar"
                      state: running
                      parallelism: 4
                      upgradeMode: stateless
        required: true
      responses:
        201:
          description: The Application was successfully created or updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlinkApplication'
            application/yaml:
              schema:
                $ref: '#/components/schemas/FlinkApplication'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - FlinkApplications
      operationId: getApplications
      summary: Retrieve a paginated list of all applications in the given Environment.
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - $ref: '#/components/parameters/includeResourceInformationParam'
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
      responses:
        200:
          description: Application found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApplicationsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/ApplicationsPage'
        304:
          description: Not modified.
          headers:
            ETag:
              description: An ID for this version of the response.
              schema:
                type: string
        404:
          description: Environment not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/applications/{appName}:
    get:
      tags:
        - FlinkApplications
      operationId: getApplication
      summary: Retrieve an Application of the given name in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/includeResourceInformationParam'
      responses:
        200:
          description: Application found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlinkApplication'
            application/yaml:
              schema:
                $ref: '#/components/schemas/FlinkApplication'
        304:
          description: Not modified.
          headers:
            ETag:
              description: An ID for this version of the response.
              schema:
                type: string
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: Application not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      tags:
        - FlinkApplications
      operationId: deleteApplication
      summary: Deletes an Application of the given name in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
      responses:
        200:
          description: Application found and deleted.
        304:
          description: Not modified.
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1alpha1/environments/{envName}/applications/{appName}/events:
    get:
      tags:
        - FlinkApplications
      operationId: getApplicationEvents
      summary: Get a paginated list of events of the given Application
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
      responses:
        200:
          description: Events found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/EventsPage'
        404:
          description: Environment or Application not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/applications/{appName}/start:
    post:
      tags:
        - FlinkApplications
      operationId: startApplication
      summary: Starts an earlier submitted Flink Application
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
        - name: startFromSavepointUid
          in: query
          description: UID of the Savepoint from which the application should be started. This savepoint could belong to the application or can be a deatched savepoint.
          required: false
          schema:
            type: string
      responses:
        200:
          description: Application started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlinkApplication'
            application/yaml:
              schema:
                $ref: '#/components/schemas/FlinkApplication'
        304:
          description: Not modified.
        404:
          description: Environment, Application or Savepoint not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/applications/{appName}/suspend:
    post:
      tags:
        - FlinkApplications
      operationId: suspendApplication
      summary: Suspends an earlier started Flink Application
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
      responses:
        200:
          description: Application suspended
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlinkApplication'
            application/yaml:
              schema:
                $ref: '#/components/schemas/FlinkApplication'
        304:
          description: Not modified.
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/applications/{appName}/instances:
    get:
      tags:
        - FlinkApplications
      operationId: getApplicationInstances
      summary: Get a paginated list of instances of the given Application
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
      responses:
        200:
          description: Instances found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApplicationInstancesPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/ApplicationInstancesPage'
        404:
          description: Environment or Application not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/applications/{appName}/instances/{instName}:
    get:
      tags:
        - FlinkApplications
      operationId: getApplicationInstance
      summary: Retrieve an Instance of an Application
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
        - name: instName
          in: path
          description: Name of the ApplicationInstance
          required: true
          schema:
            type: string
      responses:
        200:
          description: ApplicationInstance found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlinkApplicationInstance'
            application/yaml:
              schema:
                $ref: '#/components/schemas/FlinkApplicationInstance'
        404:
          description: FlinkApplicationInstance or environment or application not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  ## ---------------------------- Environment Secret Mapping API ---------------------------- ##

  /cmf/api/v1/environments/{envName}/secret-mappings/{name}:
    delete:
      tags:
        - Environments
      operationId: deleteEnvironmentSecretMapping
      summary: Deletes the Environment Secret Mapping for the given Environment and Secret.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment in which the mapping has to be deleted.
          required: true
          schema:
            type: string
        - name: name
          in: path
          description: Name of the environment secret mapping to be deleted in the given environment.
          required: true
          schema:
            type: string
      responses:
        204:
          description: The Environment Secret Mapping was successfully deleted.
        404:
          description: Environment or Secret not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - Environments
      operationId: getEnvironmentSecretMapping
      summary: Retrieve the Environment Secret Mapping for the given name in the given environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: name
          in: path
          description: Name of the environment secret mapping to be retrieved.
          required: true
          schema:
            type: string
      responses:
        200:
          description: Environment Secret Mapping found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvironmentSecretMapping'
            application/yaml:
              schema:
                $ref: '#/components/schemas/EnvironmentSecretMapping'
        404:
          description: Environment or Secret not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    put:
      tags:
        - Environments
      operationId: updateEnvironmentSecretMapping
      summary:
        Updates the Environment Secret Mapping for the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: name
          in: path
          description: Name of the environment secret mapping to be updated
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnvironmentSecretMapping'
          application/yaml:
            schema:
              $ref: '#/components/schemas/EnvironmentSecretMapping'
        required: true
      responses:
        200:
          description: The Environment Secret Mapping was successfully updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvironmentSecretMapping'
            application/yaml:
              schema:
                $ref: '#/components/schemas/EnvironmentSecretMapping'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: Environment or Secret not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/secret-mappings:
    post:
      tags:
        - Environments
      operationId: createEnvironmentSecretMapping
      summary: Creates the Environment Secret Mapping for the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnvironmentSecretMapping'
          application/yaml:
            schema:
              $ref: '#/components/schemas/EnvironmentSecretMapping'
        required: true
      responses:
        200:
          description: The Environment Secret Mapping was successfully created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvironmentSecretMapping'
            application/yaml:
              schema:
                $ref: '#/components/schemas/EnvironmentSecretMapping'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: Environment not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        409:
          description: Environment Secret Mapping already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - Environments
      operationId: getEnvironmentSecretMappings
      summary: Retrieve a paginated list of all Environment Secret Mappings.
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
      responses:
        200:
          description: Environment Secret Mappings found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvironmentSecretMappingsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/EnvironmentSecretMappingsPage'
        404:
          description: Environment not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  ## ---------------------------- Statement API ---------------------------- ##

  /cmf/api/v1/environments/{envName}/statements:
    post:
      tags:
        - SQL
      operationId: createStatement
      summary: Creates a new Flink SQL Statement in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Statement'
            examples:
              basic-statement:
                summary: Basic SQL Statement
                value:
                  apiVersion: "cmf.confluent.io/v1"
                  kind: "Statement"
                  metadata:
                    name: "test-stmt"
                    labels:
                      app: "data-processing"
                      environment: "production"
                    annotations:
                      description: "Test SQL statement for data processing"
                  spec:
                    statement: "INSERT INTO blackhole SELECT click_id FROM clicks;"
                    computePoolName: "test-pool"
                    parallelism: 2
                    stopped: false
                    flinkConfiguration:
                      "state.backend.type": "hashmap"
                      "execution.checkpointing.interval": "2000"
          application/yaml:
            schema:
              $ref: '#/components/schemas/Statement'
            examples:
              yaml-statement:
                summary: Statement (YAML)
                value:
                  apiVersion: cmf.confluent.io/v1
                  kind: Statement
                  metadata:
                    name: data-streaming
                    labels:
                      app: streaming
                      environment: staging
                  spec:
                    statement: "INSERT INTO blackhole SELECT click_id FROM clicks;"
                    computePoolName: streaming-pool
                    parallelism: 2
                    stopped: false
                    flinkConfiguration:
                      "state.backend.type": "hashmap"
                      "execution.checkpointing.interval": "2000"
        required: true
      responses:
        200:
          description: The Statement was successfully created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Statement'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Statement'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: Environment not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        409:
          description: Statement already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - SQL
      operationId: getStatements
      summary: Retrieve a paginated list of Statements in the given Environment.
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - $ref: '#/components/parameters/computePoolParam'
        - $ref: '#/components/parameters/phaseParam'
        - $ref: '#/components/parameters/includeResourceInformationParam'
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: name
          in: query
          description: Wildcard filter by statement name (e.g. ?name=abc)
          required: false
          schema:
            type: string
      responses:
        200:
          description: Statements found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatementsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/StatementsPage'
        404:
          description: Environment not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/statements/{stmtName}:
    get:
      tags:
        - SQL
      operationId: getStatement
      summary: Retrieve the Statement of the given name in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: stmtName
          in: path
          description: Name of the Statement
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/includeResourceInformationParam'
      responses:
        200:
          description: Statement found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Statement'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Statement'
        404:
          description: Statement not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      tags:
        - SQL
      operationId: deleteStatement
      summary: Deletes the Statement of the given name in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: stmtName
          in: path
          description: Name of the Statement
          required: true
          schema:
            type: string
      responses:
        204:
          description: Statement was found and deleted.
        202:
          description: Statement was found and deletion request received.
        404:
          description: Statement not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    put:
      tags:
        - SQL
      operationId: updateStatement
      summary: Updates a Statement of the given name in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
          example: "production"
        - name: stmtName
          in: path
          description: Name of the Statement
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Statement'
          application/yaml:
            schema:
              $ref: '#/components/schemas/Statement'
        required: true
      responses:
        200:
          description: Statement was found and updated.
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: Statement not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/statements/{stmtName}/results:
    get:
      tags:
        - SQL
      operationId: getStatementResult
      summary: Retrieve the result of the interactive Statement with the given name in the given Environment.
      parameters:
        - $ref: '#/components/parameters/pageTokenParam'
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: stmtName
          in: path
          description: Name of the Statement
          required: true
          schema:
            type: string
      responses:
        200:
          description: StatementResults found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatementResult'
            application/yaml:
              schema:
                $ref: '#/components/schemas/StatementResult'
        400:
          description: Statement does not return results.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: Statement not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        410:
          description: Results are gone.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/statements/{stmtName}/exceptions:
    get:
      tags:
        - SQL
      operationId: getStatementExceptions
      summary: Retrieves the last 10 exceptions of the Statement with the given name in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: stmtName
          in: path
          description: Name of the Statement
          required: true
          schema:
            type: string
      responses:
        200:
          description: StatementExceptions found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatementExceptionList'
            application/yaml:
              schema:
                $ref: '#/components/schemas/StatementExceptionList'
        404:
          description: Statement not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  ## ---------------------------- Compute Pool API ---------------------------- ##
  /cmf/api/v1/environments/{envName}/compute-pools:
    post:
      tags:
        - SQL
      operationId: createComputePool
      summary: Creates a new Flink Compute Pool in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
          example: "production"
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ComputePool'
            examples:
              basic-compute-pool:
                summary: Basic Compute Pool
                value:
                  apiVersion: "cmf.confluent.io/v1"
                  kind: "ComputePool"
                  metadata:
                    name: "test-pool"
                    labels:
                      environment: "production"
                    annotations:
                      description: "Standard compute pool for production workloads"
                  spec:
                    type: "DEDICATED"
                    clusterSpec:
                      flinkVersion: "v1_19"
                      image: "confluentinc/cp-flink-sql:1.19-cp5"
                      flinkConfiguration:
                        taskmanager.numberOfTaskSlots: "1"
                      taskManager:
                        resource:
                          cpu: 0.5
                          memory: "1024m"
                      jobManager:
                        resource:
                          cpu: 0.5
                          memory: "1024m"
          application/yaml:
            schema:
              $ref: '#/components/schemas/ComputePool'
            examples:
              yaml-compute-pool:
                summary: Compute Pool (YAML)
                value:
                  apiVersion: cmf.confluent.io/v1
                  kind: ComputePool
                  metadata:
                    name: staging-pool
                    labels:
                      environment: staging
                  spec:
                    type: DEDICATED
                    clusterSpec:
                      flinkVersion: v1_19
                      image: confluentinc/cp-flink-sql:1.19-cp5
                      flinkConfiguration:
                        taskmanager.numberOfTaskSlots: "2"
                      taskManager:
                        resource:
                          cpu: 1
                          memory: "1024m"
                      jobManager:
                        resource:
                          cpu: 1
                          memory: "1024m"
        required: true
      responses:
        200:
          description: The Compute Pool was successfully created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComputePool'
            application/yaml:
              schema:
                $ref: '#/components/schemas/ComputePool'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        409:
          description: Compute Pool already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - SQL
      operationId: getComputePools
      summary: Retrieve a paginated list of Compute Pools in the given Environment.
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - $ref: '#/components/parameters/includeResourceInformationParam'
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
      responses:
        200:
          description: Compute Pools found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComputePoolsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/ComputePoolsPage'
        404:
          description: Environment not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/environments/{envName}/compute-pools/{computePoolName}:
    get:
      tags:
        - SQL
      operationId: getComputePool
      summary: Retrieve the Compute Pool of the given name in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: computePoolName
          in: path
          description: Name of the Compute Pool
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/includeResourceInformationParam'
      responses:
        200:
          description: Compute Pool found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComputePool'
            application/yaml:
              schema:
                $ref: '#/components/schemas/ComputePool'
        404:
          description: Compute Pool not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      tags:
        - SQL
      operationId: deleteComputePool
      summary: Deletes the ComputePool of the given name in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: computePoolName
          in: path
          description: Name of the ComputePool
          required: true
          schema:
            type: string
      responses:
        204:
          description: Compute Pool was found and deleted.
        404:
          description: Compute Pool not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        409:
          description: Compute Pool is in use and cannot be deleted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'



  ## ---------------------------- Secrets API ---------------------------- ##

  /cmf/api/v1/secrets:
    post:
      tags:
        - Secrets
      operationId: createSecret
      summary: Create a Secret.
      description: Create a Secret. This secrets can be then used to specify sensitive information in the Flink SQL statements. Right now these secrets are only used for Kafka and Schema Registry credentials.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Secret'
          application/yaml:
            schema:
              $ref: '#/components/schemas/Secret'
        required: true
      responses:
        200:
          description: The Secret was successfully created. Note that for security reasons, you can never view the contents of the secret itself once created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Secret'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Secret'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        409:
          description: The Secret already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - Secrets
      operationId: getSecrets
      summary: Retrieve a paginated list of all secrets. Note that the actual secret data is masked for security reasons.
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
      responses:
        200:
          description: List of secrets found. If no secrets are found, an empty list is returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SecretsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/SecretsPage'
        304:
          description: The list of secrets has not changed.
          headers:
            ETag:
              description: An ID for this version of the response.
              schema:
                type: string
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/secrets/{secretName}:
    get:
      tags:
        - Secrets
      operationId: getSecret
      summary: Retrieve the Secret of the given name. Note that the secret data is not returned for security reasons.
      parameters:
        - name: secretName
          in: path
          description: Name of the Secret
          required: true
          schema:
            type: string
      responses:
        200:
          description: Secret found and returned, with security data masked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Secret'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Secret'
        404:
          description: Secret not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    put:
      tags:
        - Secrets
      operationId: updateSecret
      summary: Update the secret.
      parameters:
        - name: secretName
          in: path
          description: Name of the Secret
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Secret'
          application/yaml:
            schema:
              $ref: '#/components/schemas/Secret'
      responses:
        200:
          description: Returns the updated Secret
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Secret'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Secret'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: Secret with the given name not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      tags:
        - Secrets
      operationId: deleteSecret
      summary: Delete the secret with the given name.
      parameters:
        - name: secretName
          in: path
          description: Name of the Secret
          required: true
          schema:
            type: string
      responses:
        204:
          description: Secret was successfully deleted.
        404:
          description: Secret not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  ## ---------------------------- Catalog API ---------------------------- ##

  /cmf/api/v1/catalogs/kafka:
    post:
      tags:
        - SQL
      operationId: createKafkaCatalog
      summary: Creates a new Kafka Catalog that can be referenced by Flink Statements
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KafkaCatalog'
            examples:
              basic-kafka-catalog:
                summary: Basic Kafka Catalog
                value:
                  apiVersion: "cmf.confluent.io/v1"
                  kind: "KafkaCatalog"
                  metadata:
                    name: "test-cat"
                    labels:
                      environment: "production"
                      managedBy: "CMF"
                    annotations:
                      description: "Production Kafka catalog for Flink statements"
                  spec:
                    srInstance:
                      connectionConfig:
                        schema.registry.url: "https://schema-registry.example.com"
                      connectionSecretId: "sr-secret-id"
          application/yaml:
            schema:
              $ref: '#/components/schemas/KafkaCatalog'
            examples:
              yaml-kafka-catalog:
                summary: Kafka Catalog (YAML)
                value:
                  apiVersion: cmf.confluent.io/v1
                  kind: KafkaCatalog
                  metadata:
                    name: staging-catalog
                    labels:
                      environment: staging
                  spec:
                    srInstance:
                      connectionConfig:
                        schema.registry.url: "https://sr-staging.example.com"
                      connectionSecretId: sr-staging-secret
        required: true
      responses:
        200:
          description: The Kafka Catalog was successfully created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KafkaCatalog'
            application/yaml:
              schema:
                $ref: '#/components/schemas/KafkaCatalog'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        409:
          description: Kafka Catalog already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - SQL
      operationId: getKafkaCatalogs
      summary: Retrieve a paginated list of Kafka Catalogs
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
      responses:
        200:
          description: Kafka Catalogs found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KafkaCatalogsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/KafkaCatalogsPage'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/catalogs/kafka/{catName}:
    get:
      tags:
        - SQL
      operationId: getKafkaCatalog
      summary: Retrieve the Kafka Catalog of the given name.
      parameters:
        - name: catName
          in: path
          description: Name of the Kafka Catalog
          required: true
          schema:
            type: string
      responses:
        200:
          description: Kafka Catalog found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KafkaCatalog'
            application/yaml:
              schema:
                $ref: '#/components/schemas/KafkaCatalog'
        404:
          description: Kafka Catalog not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      tags:
        - SQL
      operationId: deleteKafkaCatalog
      summary: Deletes the Kafka Catalog of the given name.
      parameters:
        - name: catName
          in: path
          description: Name of the Kafka Catalog
          required: true
          schema:
            type: string
      responses:
        204:
          description: Kafka Catalog was found and deleted.
        404:
          description: Kafka Catalog not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        409:
          description: Catalog contains databases and cannot be deleted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    put:
      tags:
        - SQL
      operationId: updateKafkaCatalog
      summary: Updates a KafkaCatalog of the given name.
      parameters:
        - name: catName
          in: path
          description: Name of the KafkaCatalog
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KafkaCatalog'
          application/yaml:
            schema:
              $ref: '#/components/schemas/KafkaCatalog'
        required: true
      responses:
        200:
          description: KafkaCatalog was found and updated.
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: KafkaCatalog not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  ## ---------------------------- Database API ---------------------------- ##

  /cmf/api/v1/catalogs/kafka/{catName}/databases:
    post:
      tags:
        - SQL
      operationId: createKafkaDatabase
      summary: Creates a new Kafka Database
      parameters:
        - name: catName
          in: path
          description: Name of the Catalog
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KafkaDatabase'
            examples:
              basic-kafka-database:
                summary: Basic Kafka Database
                value:
                  apiVersion: "cmf.confluent.io/v1"
                  kind: "KafkaDatabase"
                  metadata:
                    name: "dev"
                    labels:
                      environment: "production"
                      managedBy: "CMF"
                    annotations:
                      description: "Development Kafka database"
                  spec:
                    kafkaCluster:
                      connectionConfig:
                        bootstrap.servers: "kafka-dev.example.com:9092"
                        security.protocol: "SASL_PLAINTEXT"
                        sasl.mechanism: "PLAIN"
                      connectionSecretId: "dev-secret-id"
                    alterEnvironments:
                      - "production"
          application/yaml:
            schema:
              $ref: '#/components/schemas/KafkaDatabase'
            examples:
              yaml-kafka-database:
                summary: Kafka Database (YAML)
                value:
                  apiVersion: cmf.confluent.io/v1
                  kind: KafkaDatabase
                  metadata:
                    name: staging
                    labels:
                      environment: staging
                  spec:
                    kafkaCluster:
                      connectionConfig:
                        bootstrap.servers: "kafka-staging.example.com:9092"
                        security.protocol: SASL_PLAINTEXT
                      connectionSecretId: staging-kafka-secret
                    alterEnvironments:
                      - staging
        required: true
      responses:
        200:
          description: The Kafka Database was successfully created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KafkaDatabase'
            application/yaml:
              schema:
                $ref: '#/components/schemas/KafkaDatabase'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        409:
          description: Kafka Database already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - SQL
      operationId: getKafkaDatabases
      summary: Retrieve a paginated list of Kafka Databases
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - name: catName
          in: path
          description: Name of the Catalog
          required: true
          schema:
            type: string
      x-spring-paginated: true
      responses:
        200:
          description: Kafka Databases found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KafkaDatabasesPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/KafkaDatabasesPage'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/catalogs/kafka/{catName}/databases/{dbName}:
    get:
      tags:
        - SQL
      operationId: getKafkaDatabase
      summary: Retrieve the Kafka Database of the given name in the given KafkaCatalog.
      parameters:
        - name: catName
          in: path
          description: Name of the Kafka Catalog
          required: true
          schema:
            type: string
        - name: dbName
          in: path
          description: Name of the Kafka Database
          required: true
          schema:
            type: string
      responses:
        200:
          description: Kafka Database found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KafkaDatabase'
            application/yaml:
              schema:
                $ref: '#/components/schemas/KafkaDatabase'
        404:
          description: Kafka Database not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      tags:
        - SQL
      operationId: deleteKafkaDatabase
      summary: Deletes the Kafka Database of the given name in the given KafkaCatalog.
      parameters:
        - name: catName
          in: path
          description: Name of the Kafka Catalog
          required: true
          schema:
            type: string
        - name: dbName
          in: path
          description: Name of the Kafka Database
          required: true
          schema:
            type: string
      responses:
        204:
          description: Kafka Database was found and deleted.
        404:
          description: Kafka Database not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    put:
      tags:
        - SQL
      operationId: updateKafkaDatabase
      summary: Updates a KafkaDatabase of the given name in the given KafkaCatalog.
      parameters:
        - name: catName
          in: path
          description: Name of the KafkaCatalog
          required: true
          schema:
            type: string
        - name: dbName
          in: path
          description: Name of the KafkaDatabase
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KafkaDatabase'
          application/yaml:
            schema:
              $ref: '#/components/schemas/KafkaDatabase'
        required: true
      responses:
        200:
          description: KafkaDatabase was found and updated.
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: KafkaDatabase not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

    ## ---------------------------- Savepoint API ---------------------------- ##

  ### --------------------------- Savepoint for Applications API --------------------------- ###
  /cmf/api/v1/environments/{envName}/applications/{appName}/savepoints:
    post:
      tags:
        - Savepoints
      operationId: createSavepointForFlinkApplication
      summary: Creates a new Savepoint for the given Application in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Savepoint'
          application/yaml:
            schema:
              $ref: '#/components/schemas/Savepoint'
      responses:
        201:
          description: Savepoint was successfully created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Savepoint'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Savepoint'
        404:
          description: Environment or Application not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - Savepoints
      operationId: getSavepointsForFlinkApplication
      summary: Retrieve a paginated list of all Savepoints for the given Application in the given Environment.
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
      responses:
        200:
          description: Savepoints found and returned. In case, there are no savepoints, an empty list is returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SavepointsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/SavepointsPage'
        404:
          description: Environment or Application not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  /cmf/api/v1/environments/{envName}/applications/{appName}/savepoints/{savepointName}:
    get:
      tags:
        - Savepoints
      operationId: getSavepointForFlinkApplication
      summary: Retrieve the Savepoint of the given name for the given Application in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
        - name: savepointName
          in: path
          description: Name of the Savepoint
          required: true
          schema:
            type: string
      responses:
        200:
          description: Savepoint found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Savepoint'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Savepoint'
        404:
          description: Environment, Application or Savepoint not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      tags:
        - Savepoints
      operationId: deleteSavepointForFlinkApplication
      summary: Deletes the Savepoint of the given name for the given Application in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
        - name: savepointName
          in: path
          description: Name of the Savepoint to be deleted.
          required: true
          schema:
            type: string
        - name: force
          in: query
          description: If a Savepoint is marked for deletion, it can be force deleted.
          required: false
          schema:
            type: boolean
            default: false
      responses:
        204:
          description: Savepoint was found and deleted.
        404:
          description: Environment, Application or Savepoint not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  /cmf/api/v1/environments/{envName}/applications/{appName}/savepoints/{savepointName}/detach:
    post:
      tags:
        - Savepoints
      operationId: detachSavepointFromFlinkApplication
      summary: Detaches the Savepoint of the given name for the given Application in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: appName
          in: path
          description: Name of the Application
          required: true
          schema:
            type: string
        - name: savepointName
          in: path
          description: Name of the Savepoint to be detached.
          required: true
          schema:
            type: string
      responses:
        200:
          description: Savepoint was successfully detached and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Savepoint'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Savepoint'
        404:
          description: Environment, Application or Savepoint not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  ### --------------------------- Savepoint for Statements API --------------------------- ###
  /cmf/api/v1/environments/{envName}/statements/{stmtName}/savepoints:
    post:
      tags:
        - Savepoints
      operationId: createSavepointForFlinkStatement
      summary: Creates a new Savepoint for the given Statement in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: stmtName
          in: path
          description: Name of the Statement
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Savepoint'
          application/yaml:
            schema:
              $ref: '#/components/schemas/Savepoint'
      responses:
        201:
          description: Savepoint was successfully created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Savepoint'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Savepoint'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        404:
          description: Environment or Statement not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - Savepoints
      operationId: getSavepointsForFlinkStatement
      summary: Retrieve a paginated list of all Savepoints for the given Statement in the given Environment.
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: stmtName
          in: path
          description: Name of the Statement
          required: true
          schema:
            type: string
      responses:
        200:
          description: Savepoints found and returned. In case, there are no savepoints, an empty list is returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SavepointsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/SavepointsPage'
        404:
          description: Environment or Statement not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  /cmf/api/v1/environments/{envName}/statements/{stmtName}/savepoints/{savepointName}:
    get:
      tags:
        - Savepoints
      operationId: getSavepointForFlinkStatement
      summary: Retrieve the Savepoint of the given name for the given Statement in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: stmtName
          in: path
          description: Name of the Statement
          required: true
          schema:
            type: string
        - name: savepointName
          in: path
          description: Name of the Savepoint
          required: true
          schema:
            type: string
      responses:
        200:
          description: Savepoint found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Savepoint'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Savepoint'
        404:
          description: Environment, Statement or Savepoint not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      tags:
        - Savepoints
      operationId: deleteSavepointForFlinkStatement
      summary: Deletes the Savepoint of the given name for the given Statement in the given Environment.
      parameters:
        - name: envName
          in: path
          description: Name of the Environment
          required: true
          schema:
            type: string
        - name: stmtName
          in: path
          description: Name of the Statement
          required: true
          schema:
            type: string
        - name: savepointName
          in: path
          description: Name of the Savepoint to be deleted.
          required: true
          schema:
            type: string
        - name: force
          in: query
          description: If a Savepoint is marked for deletion, it can be force deleted.
          required: false
          schema:
            type: boolean
            default: false
      responses:
        204:
          description: Savepoint was found and deleted.
        404:
          description: Environment, Statement or Savepoint not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  ### --------------------------- Detached Savepoint API --------------------------- ###

  /cmf/api/v1/detached-savepoints:
    post:
      tags:
        - DetachedSavepoints
      operationId: createDetachedSavepoint
      summary: Creates a new detached savepoint.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Savepoint'
          application/yaml:
            schema:
              $ref: '#/components/schemas/Savepoint'
      responses:
        201:
          description: Detached Savepoint was successfully created and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Savepoint'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Savepoint'
        400:
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        422:
          description: Request valid but invalid content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    get:
      tags:
        - DetachedSavepoints
      operationId: listDetachedSavepoints
      summary: Retrieve a paginated list of all Detached Savepoints.
      x-spring-paginated: true
      parameters:
        - $ref: '#/components/parameters/pageParam'
        - $ref: '#/components/parameters/sizeParam'
        - $ref: '#/components/parameters/sortParam'
        - name: name
          in: query
          description: Filter by detached savepoint name prefix (e.g. ?name=abc)
          required: false
          schema:
            type: string
      responses:
        200:
          description: Detached Savepoints found and returned. In case, there are none, an empty list is returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SavepointsPage'
            application/yaml:
              schema:
                $ref: '#/components/schemas/SavepointsPage'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
  /cmf/api/v1/detached-savepoints/{detachedSavepointName}:
    get:
      tags:
        - DetachedSavepoints
      operationId: getDetachedSavepoint
      summary: Retrieve the Detached Savepoint of the given name.
      parameters:
        - name: detachedSavepointName
          in: path
          description: Name of the Detached Savepoint
          required: true
          schema:
            type: string
      responses:
        200:
          description: Detached Savepoint found and returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Savepoint'
            application/yaml:
              schema:
                $ref: '#/components/schemas/Savepoint'
        404:
          description: Detached Savepoint not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
    delete:
      tags:
        - DetachedSavepoints
      operationId: deleteDetachedSavepoint
      summary: Deletes the Detached Savepoint of the given name.
      parameters:
        - name: detachedSavepointName
          in: path
          description: Name of the Detached Savepoint
          required: true
          schema:
            type: string
      responses:
        204:
          description: Detached Savepoint was found and deleted.
        404:
          description: Detached Savepoint not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  ### ---------------------------- CMF Information API -------------------------- ###
  /cmf/api/v1/system-information:
    get:
      tags:
        - CMFInformation
      operationId: getSystemInformation
      summary: Retrieve system information about the CMF deployment.
      responses:
        200:
          description: System information retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SystemInformation'
            application/yaml:
              schema:
                $ref: '#/components/schemas/SystemInformation'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

  /cmf/api/v1/resource-information:
    get:
      tags:
        - CMFInformation
      operationId: getResourceInformation
      summary: Retrieve resource information about the CMF deployment.
      responses:
        200:
          description: Resource information retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceInformation'
            application/yaml:
              schema:
                $ref: '#/components/schemas/ResourceInformation'
        500:
          description: Server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
            application/yaml:
              schema:
                $ref: '#/components/schemas/RestError'

components:
  # https://github.com/daniel-shuy/swaggerhub-spring-pagination / Copyright (c) 2023 Daniel Shuy
  parameters:
    pageParam:
      in: query
      name: page
      schema:
        type: integer
      description: Zero-based page index (0..N)
    sizeParam:
      in: query
      name: size
      schema:
        type: integer
      description: The size of the page to be returned
    sortParam:
      in: query
      name: sort
      schema:
        type: array
        items:
          type: string
      style: form
      explode: true
      description: >-
        Sorting criteria in the format: property,(asc|desc). Default sort order is ascending.
        Multiple sort criteria are supported.
    pageTokenParam:
      in: query
      name: page-token
      schema:
        type: string
      description: Token for the next page of results
    includeResourceInformationParam:
      name: include-resource-information
      in: query
      description: Whether to include resource summary in the response.
      required: false
      schema:
        type: boolean
        default: false
    computePoolParam:
      in: query
      name: compute-pool
      schema:
        type: string
      description: Name of the ComputePool to filter on
    phaseParam:
      in: query
      name: phase
      schema:
        type: string
        enum: [pending, running, completed, deleting, failing, failed, stopped]
      description: Phase to filter on
  schemas:
    ## ---------------------------- Shared Utilities ---------------------------- ##
    RestError:
      title: REST Error
      description: The schema for all error responses.
      type: object
      properties:
        errors:
          title: errors
          description: List of all errors
          type: array
          items:
            title: error
            type: object
            description: An error
            properties:
              message:
                type: string
                description: An error message
    PaginationResponse:
      type: object
      properties:
        pageable:
          $ref: '#/components/schemas/Pageable'
    Sort:
      type: object
      format: sort
      properties:
        sorted:
          type: boolean
          description: Whether the results are sorted.
          example: true
        unsorted:
          type: boolean
          description: Whether the results are unsorted.
          example: false
        empty:
          type: boolean
    Pageable:
      type: object
      format: pageable
      properties:
        page:
          type: integer
          minimum: 0
        size:
          type: integer
          description: The number of items in a page.
          minimum: 1
        sort:
          $ref: '#/components/schemas/Sort'

    ## ---------------------------- Shared Bases ---------------------------- ##
    ResourceBaseV2:
      type: object
      properties:
        apiVersion:
          description: API version for spec
          type: string
        kind:
          description: Kind of resource - set to resource type
          type: string
      required:
        - apiVersion
        - kind

    PostResourceBase:
      type: object
      properties:
        name:
          title: Name
          description: A unique name for the resource.
          type: string
          # Validate for DNS subdomain name
          minLength: 4
          pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$'
    GetResourceBase:
      type: object
      properties:
        created_time:
          title: Time when the resource has been created
          type: string
          format: date-time
        updated_time:
          title: Time when the resource has been last updated
          type: string
          format: date-time
    # defines kubernetesNamespace
    KubernetesNamespace:
      type: object
      properties:
        kubernetesNamespace:
          type: string
          title: Kubernetes namespace name where resources referencing this environment are created in.
          minLength: 1
          maxLength: 253
          pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$'
    # defines properties of fields with flinkApplicationDefaults
    ResourceWithFlinkApplicationDefaults:
      type: object
      properties:
        flinkApplicationDefaults:
          title: the defaults as YAML or JSON for FlinkApplications
          type: object
          format: yamlorjson
    # defines computePool defaults
    ComputePoolDefaults:
      type: object
      properties:
        computePoolDefaults:
          title: ComputePoolDefaults
          description: the defaults as YAML or JSON for ComputePools
          type: object
          format: yamlorjson
    # defines statement defaults
    StatementDefaults:
      type: object
      properties:
        flinkConfiguration:
          description: default Flink configuration for Statements
          type: object
          additionalProperties:
            type: string
    # defines defaults for detached and interactive statements
    AllStatementDefaults:
      type: object
      properties:
        statementDefaults:
          title: AllStatementDefaults
          description: the defaults for detached and interactive Statements
          type: object
          properties:
            detached:
              description: defaults for detached statements
              $ref: '#/components/schemas/StatementDefaults'
            interactive:
              description: defaults for interactive statements
              $ref: '#/components/schemas/StatementDefaults'

    ## ---------------------------- Request Schemas ---------------------------- ##
    PostEnvironment:
      title: Environment
      description: Environment
      type: object
      required:
        - name
      allOf:
        - $ref: '#/components/schemas/PostResourceBase'
        - $ref: '#/components/schemas/ResourceWithFlinkApplicationDefaults'
        - $ref: '#/components/schemas/KubernetesNamespace'
        - $ref: '#/components/schemas/ComputePoolDefaults'
        - $ref: '#/components/schemas/AllStatementDefaults'

    ## ---------------------------- Response Schemas ---------------------------- ##
    Environment:
      title: Environment
      description: Environment
      type: object
      allOf:
        - $ref: '#/components/schemas/PostResourceBase'
        - $ref: '#/components/schemas/GetResourceBase'
        - $ref: '#/components/schemas/ResourceWithFlinkApplicationDefaults'
        - $ref: '#/components/schemas/KubernetesNamespace'
        - $ref: '#/components/schemas/ComputePoolDefaults'
        - $ref: '#/components/schemas/AllStatementDefaults'
      properties:
        secrets:
          title: Secrets
          description: The secrets mapping for the environment. This is a mapping between connection_secret_id and the secret name.
          type: object
          additionalProperties:
            type: string
          default: { }
        status:
          title: Status
          description: Status for the environment
          type: object
          properties:
            resourceSummary:
              $ref: '#/components/schemas/ResourceUsageSummary'
      required:
        - name
        - kubernetesNamespace

    EnvironmentSecretMapping:
      title: EnvironmentSecretMapping
      description: The secrets mapping for the environment. The name shows the name of the Connection Secret ID to be mapped.
      type: object
      properties:
        apiVersion:
          title: API version for EnvironmentSecretMapping spec
          type: string
        kind:
          title: Kind of resource - set to EnvironmentSecretMapping
          type: string
        metadata:
          title: EnvironmentSecretMappingMetadata
          description: Metadata about the environment secret mapping
          type: object
          properties:
            name:
              description: Name of the Connection Secret ID
              type: string
            uid:
              description: Unique identifier of the EnvironmentSecretMapping
              type: string
            creationTimestamp:
              description: Timestamp when the EnvironmentSecretMapping was created
              type: string
            updateTimestamp:
              description: Timestamp when the EnvironmentSecretMapping was last updated
              type: string
            labels:
              description: Labels of the EnvironmentSecretMapping
              type: object
              additionalProperties:
                type: string
            annotations:
              description: Annotations of the EnvironmentSecretMapping
              type: object
              additionalProperties:
                type: string
        spec:
          title: EnvironmentSecretMappingSpec
          description: Spec for environment secret mapping
          type: object
          writeOnly: true
          properties:
            secretName:
              description: Name of the secret to be mapped to the connection secret id of this mapping.
              type: string
          required:
            - secretName
      required:
        - apiVersion
        - kind

    EnvironmentSecretMappingsPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: EnvironmentSecretMappingsPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/EnvironmentSecretMapping'
              default: [ ]

    Secret:
      title: Secret
      description: Represents a Secret that can be used to specify sensitive information in the Flink SQL statements.
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            metadata:
              title: SecretMetadata
              description: Metadata about the secret
              type: object
              properties:
                name:
                  type: string
                  description: Name of the Secret
                creationTimestamp:
                  description: Timestamp when the Secret was created
                  type: string
                  readOnly: true
                updateTimestamp:
                  description: Timestamp when the Secret was last updated
                  type: string
                  readOnly: true
                uid:
                  description: Unique identifier of the Secret
                  type: string
                  readOnly: true
                labels:
                  description: Labels of the Secret
                  type: object
                  additionalProperties:
                    type: string
                annotations:
                  description: Annotations of the Secret
                  type: object
                  additionalProperties:
                    type: string
              required:
                - name
            spec:
              title: SecretSpec
              description: Spec for secret
              type: object
              writeOnly: true
              properties:
                data:
                  title: SecretData
                  description: Data of the secret
                  type: object
                  additionalProperties:
                    type: string
            status:
              title: SecretStatus
              description: Status for the secret
              type: object
              readOnly: true
              properties:
                version:
                  title: SecretVersion
                  description: The version of the secret
                  type: string
                environments:
                  title: Environments
                  description: The environments to which the secret is attached to.
                  type: array
                  items:
                    type: string
          required:
            - metadata
            - spec

    SecretsPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: SecretsPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/Secret'
              default: [ ]

    EnvironmentsPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: EnvironmentsPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              title: "Env"
              items:
                $ref: '#/components/schemas/Environment'
              default: [ ]

    FlinkApplication:
      title: FlinkApplication
      description: Represents a Flink Application submitted by the user
      type: object
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            metadata:
              title: Metadata about the application
              type: object
              format: yamlorjson
            spec:
              title: Spec for Flink Application
              type: object
              format: yamlorjson
            status:
              title: Status for Flink Application
              type: object
              format: yamlorjson
          required: # status is optional for application spec
            - metadata
            - spec

    ApplicationsPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: ApplicationPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/FlinkApplication'
              default: [ ]

    FlinkApplicationEvent:
      title: FlinkApplicationEvent
      description: Events from the deployment of Flink clusters
      # TODO(CF-1159): Using the ResourceBaseV2 here leads to incorrectly generated EventType where the generated interface doesn't match the file name causing compilation errors.
      type: object
      properties:
        apiVersion:
          title: API version for Event spec - set to v1alpha1
          type: string
        kind:
          title: Kind of resource - set to FlinkApplicationEvent
          type: string
        metadata:
          title: EventMetadata
          description: Metadata about the event
          type: object
          properties:
            name:
              description: Name of the Event
              type: string
            uid:
              description: Unique identifier of the Event. Identical to name.
              type: string
            creationTimestamp:
              description: Timestamp when the Event was created
              type: string
            flinkApplicationInstance:
              description: Name of the FlinkApplicationInstance which this event is related to
              type: string
            labels:
              description: Labels of the Event
              type: object
              additionalProperties:
                type: string
            annotations:
              description: Annotations of the Event
              type: object
              additionalProperties:
                type: string
        status:
          type: object
          title: EventStatus
          properties:
            message:
              description: Human readable status message.
              type: string
            type:
              title: EventType
              description: Type of the event
              type: string
            data:
              $ref: '#/components/schemas/EventData'
      required:
        - kind
        - apiVersion
        - metadata
        - status

    EventDataNewStatus:
      type: object
      properties:
        newStatus:
          description: "The new status"
          type: string

    EventDataJobException:
      type: object
      properties:
        exceptionString:
          description: "The full exception string from the Flink job"
          type: string
    EventData:
      oneOf:
        - $ref: '#/components/schemas/EventDataNewStatus'
        - $ref: '#/components/schemas/EventDataJobException'

    EventsPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: EventsPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/FlinkApplicationEvent'
              default: [ ]

    FlinkApplicationInstance:
      title: ApplicationInstance
      description: An instance of a Flink Application
      type: object
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            metadata:
              title: ApplicationInstanceMetadata
              description: Metadata about the instance
              type: object
              properties:
                name:
                  description: Name of the Instance - a uuid.
                  type: string
                uid:
                  description: Unique identifier of the instance. Identical to name.
                  type: string
                creationTimestamp:
                  description: Timestamp when the Instance was created
                  type: string
                updateTimestamp:
                  description: Timestamp when the Instance status was last updated
                  type: string
                labels:
                  description: Labels of the instance
                  type: object
                  additionalProperties:
                    type: string
                annotations:
                  description: Annotations of the instance
                  type: object
                  additionalProperties:
                    type: string
            status:
              type: object
              title: ApplicationInstanceStatus
              properties:
                spec:
                  description: The environment defaults merged with the FlinkApplication spec at instance creation time
                  type: object
                  format: yamlorjson
                jobStatus:
                  type: object
                  properties:
                    jobId:
                      description: Flink job id inside the Flink cluster
                      type: string
                    state:
                      description: Tracks the final Flink JobStatus of the instance
                      type: string
    ApplicationInstancesPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: ApplicationInstancesPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/FlinkApplicationInstance'
              default: [ ]

    Statement:
      title: Statement
      description: Represents a SQL Statement submitted by the user
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            metadata:
              title: StatementMetadata
              description: Metadata about the statement
              type: object
              properties:
                name:
                  description: Name of the Statement
                  type: string
                creationTimestamp:
                  description: Timestamp when the Statement was created
                  type: string
                updateTimestamp:
                  description: Timestamp when the Statement was updated last
                  type: string
                uid:
                  description: Unique identifier of the Statement
                  type: string
                labels:
                  description: Labels of the Statement
                  type: object
                  additionalProperties:
                    type: string
                annotations:
                  description: Annotations of the Statement
                  type: object
                  additionalProperties:
                    type: string
              required:
                - name
            spec:
              title: StatementSpec
              description: Spec for statement
              type: object
              properties:
                statement:
                  description: SQL statement
                  type: string
                properties:
                  title: SessionProperties
                  description: Properties of the client session
                  type: object
                  additionalProperties:
                    type: string
                flinkConfiguration:
                  title: StatementFlinkConfiguration
                  description: Flink configuration for the statement
                  type: object
                  additionalProperties:
                    type: string
                computePoolName:
                  description: Name of the ComputePool
                  type: string
                parallelism:
                  description: Parallelism of the statement
                  type: integer
                  format: int32
                stopped:
                  description: Whether the statement is stopped
                  type: boolean
                startFromSavepoint:
                  description: Configuration for starting/resuming the statement from a savepoint
                  $ref: '#/components/schemas/StatementStartFromSavepoint'
              required:
                - statement
                - computePoolName
            status:
              title: StatementStatus
              description: Status for statement
              type: object
              properties:
                phase:
                  description: The lifecycle phase of the statement
                  type: string
                detail:
                  description: Details about the execution status of the statement
                  type: string
                traits:
                  title: StatementTraits
                  description: Detailed information about the properties of the statement
                  type: object
                  properties:
                    sqlKind:
                      description: The kind of SQL statement
                      type: string
                    isBounded:
                      description: Whether the result of the statement is bounded
                      type: boolean
                    isAppendOnly:
                      description: Whether the result of the statement is append only
                      type: boolean
                    upsertColumns:
                      description: The column indexes that are updated by the statement
                      type: array
                      items:
                        type: integer
                        format: int32
                    schema:
                      title: StatementResultSchema
                      description: The schema of the statement result
                      $ref: '#/components/schemas/ResultSchema'
                resourceSummary:
                  $ref: '#/components/schemas/ResourceUsageSummary'
              required:
                - phase
            result:
              title: StatementResult
              description: Result of the statement
              $ref: '#/components/schemas/StatementResult'
          required: # status and result are optional for Statement spec
            - metadata
            - spec

    StatementsPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: StatementPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/Statement'
              default: [ ]

    StatementResult:
      title: StatementResult
      description: Represents the result of a SQL Statement
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            metadata:
              title: StatementResultMetadata
              description: Metadata about the StatementResult
              type: object
              properties:
                creationTimestamp:
                  description: Timestamp when the StatementResult was created
                  type: string
                annotations:
                  description: Annotations of the StatementResult
                  type: object
                  additionalProperties:
                    type: string
            results:
              title: StatementResults
              description: Results of the Statement
              type: object
              properties:
                data:
                  title: Data
                  type: array
                  items:
                    description: A result row
                    type: object
                    format: yamlorjson
          required:
            - metadata
            - results

    StatementException:
      title: StatementException
      description: Represents an exception that occurred while executing a SQL Statement
      type: object
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            name:
              description: Name of the StatementException
              type: string
            message:
              description: Message of the StatementException
              type: string
            timestamp:
              description: Timestamp when the StatementException was created
              type: string
          required:
            - name
            - message
            - timestamp

    StatementExceptionList:
      title: StatementExceptionList
      description: Represents a list of exceptions that occurred while executing a SQL Statement
      type: object
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            data:
              title: Exceptions
              description: List of exceptions
              type: array
              maxItems: 10
              items:
                $ref: '#/components/schemas/StatementException'
                default: [ ]
          required:
            - data

    DataType:
      title: DataType
      description: Represents a SQL data type
      type: object
      properties:
        type:
          description: Name of the data type of the column
          type: string
        nullable:
          description: Whether the data type is nullable
          type: boolean
        length:
          description: Length of the data type
          type: integer
          format: int32
        precision:
          description: Precision of the data type
          type: integer
          format: int32
        scale:
          description: Scale of the data type
          type: integer
          format: int32
        keyType:
          description: Type of the key in the data type (if applicable)
          $ref: '#/components/schemas/DataType'
          x-go-pointer: true
        valueType:
          description: Type of the value in the data type (if applicable)
          $ref: '#/components/schemas/DataType'
          x-go-pointer: true
        elementType:
          description: Type of the elements in the data type (if applicable)
          $ref: '#/components/schemas/DataType'
          x-go-pointer: true
        fields:
          description: Fields of the data type (if applicable)
          type: array
          items:
            type: object
            title: DataTypeField
            description: Field of the data type
            properties:
              name:
                description: Name of the field
                type: string
              fieldType:
                description: Type of the field
                $ref: '#/components/schemas/DataType'
                x-go-pointer: true
              description:
                description: Description of the field
                type: string
            required:
              - name
              - fieldType
        resolution:
          description: Resolution of the data type (if applicable)
          type: string
        fractionalPrecision:
          description: Fractional precision of the data type (if applicable)
          type: integer
          format: int32
      required:
        - type
        - nullable

    ResultSchema:
      title: ResultSchema
      description: Represents the schema of the result of a SQL Statement
      type: object
      properties:
        columns:
          description: Properites of all columns in the schema
          type: array
          items:
            title: ResultSchemaColumn
            type: object
            properties:
              name:
                description: Name of the column
                type: string
              type:
                description: Type of the column
                $ref: '#/components/schemas/DataType'
            required:
              - name
              - type
      required:
        - columns

    ComputePool:
      title: ComputePool
      description: Represents the configuration of a Flink cluster
      type: object
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            metadata:
              title: ComputePoolMetadata
              description: Metadata about the ComputePool
              type: object
              properties:
                name:
                  description: Name of the ComputePool
                  type: string
                creationTimestamp:
                  description: Timestamp when the ComputePool was created
                  type: string
                uid:
                  description: Unique identifier of the ComputePool
                  type: string
                labels:
                  description: Labels of the ComputePool
                  type: object
                  additionalProperties:
                    type: string
                annotations:
                  description: Annotations of the ComputePool
                  type: object
                  additionalProperties:
                    type: string
              required:
                - name
            spec:
              title: ComputePoolSpec
              description: Spec for ComputePool
              type: object
              properties:
                type:
                  description: Type of the ComputePool
                  type: string
                clusterSpec:
                  description: Cluster Spec
                  type: object
                  format: yamlorjson
              required:
                - type
                - clusterSpec
            status:
              title: ComputePoolStatus
              description: Status for ComputePool
              type: object
              properties:
                phase:
                  description: Phase of the ComputePool
                  type: string
                resourceSummary:
                  $ref: '#/components/schemas/ResourceUsageSummary'
              required:
                - phase
          required: # status is optional for ComputePool spec
            - metadata
            - spec

    ComputePoolsPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: ComputePoolPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/ComputePool'
              default: [ ]

    CatalogMetadata:
      title: CatalogMetadata
      description: Metadata about the Catalog
      type: object
      properties:
        name:
          description: Name of the Catalog
          type: string
        creationTimestamp:
          description: Timestamp when the Catalog was created
          type: string
        updateTimestamp:
          description: Timestamp when the Catalog was updated the last time
          type: string
        uid:
          description: Unique identifier of the Catalog
          type: string
        labels:
          description: Labels of the Catalog
          type: object
          additionalProperties:
            type: string
        annotations:
          description: Annotations of the Catalog
          type: object
          additionalProperties:
            type: string
      required:
        - name

    KafkaCatalog:
      title: KafkaCatalog
      description: Represents a the configuration of a Kafka Catalog
      type: object
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            metadata:
              $ref: '#/components/schemas/CatalogMetadata'
            spec:
              title: KafkaCatalogSpec
              description: Spec of a Kafka Catalog
              type: object
              properties:
                srInstance:
                  description: Details about the SchemaRegistry instance of the Catalog
                  type: object
                  properties:
                    connectionConfig:
                      description: connection options for the SR client
                      type: object
                      additionalProperties:
                        type: string
                    connectionSecretId:
                      description: an identifier to look up a Kubernetes secret that contains the connection credentials
                      type: string
                  required:
                    - connectionConfig
                kafkaClusters:
                  type: array
                  items:
                    type: object
                    properties:
                      databaseName:
                        description: the database name under which the Kafka cluster is listed in the Catalog
                        type: string
                      connectionConfig:
                        description: connection options for the Kafka client
                        type: object
                        additionalProperties:
                          type: string
                      connectionSecretId:
                        description: an identifier to look up a Kubernetes secret that contains the connection credentials
                        type: string
                    required:
                      - databaseName
                      - connectionConfig
              required:
                - srInstance
            status:
              title: KafkaCatalogStatus
              description: Status for Kafka Catalog
              type: object
              properties:
                environmentsWithAccess:
                  description: Environments with access to the Kafka Catalog
                  type: array
                  items:
                    type: string
          required:
            - metadata
            - spec

    KafkaCatalogsPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: CatalogPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/KafkaCatalog'
              default: [ ]

    DatabaseMetadata:
      title: DatabaseMetadata
      description: Metadata about the Database
      type: object
      properties:
        name:
          description: Name of the Database
          type: string
        creationTimestamp:
          description: Timestamp when the Database was created
          type: string
        updateTimestamp:
          description: Timestamp when the Database was updated the last time
          type: string
        uid:
          description: Unique identifier of the Database
          type: string
        labels:
          description: Labels of the Database
          type: object
          additionalProperties:
            type: string
        annotations:
          description: Annotations of the Database
          type: object
          additionalProperties:
            type: string
      required:
        - name

    KafkaDatabase:
      title: KafkaDatabase
      description: Represents a the configuration of a Kafka Database
      type: object
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            metadata:
              $ref: '#/components/schemas/DatabaseMetadata'
            spec:
              title: KafkaDatabaseSpec
              description: Spec of a Kafka Database
              type: object
              properties:
                kafkaCluster:
                  description: Details about the Kafka cluster of the database
                  type: object
                  properties:
                    connectionConfig:
                      description: connection options for the Kafka client
                      type: object
                      additionalProperties:
                        type: string
                    connectionSecretId:
                      description: an identifier to look up a secret that contains the connection credentials
                      type: string
                  required:
                    - connectionConfig
                alterEnvironments:
                  description: List of environments that have permission to alter the tables of this database
                  type: array
                  items:
                    type: string
              required:
                - kafkaCluster
            status:
              title: KafkaDatabaseStatus
              description: Status for Kafka Database
              type: object
              properties:
                environmentsWithAccess:
                  description: Environments with access to the Kafka Database
                  type: array
                  items:
                    type: string
          required:
            - metadata
            - spec

    KafkaDatabasesPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: DatabasePageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/KafkaDatabase'
              default: [ ]

    Savepoint:
      title: Savepoint
      description: Represents a Savepoint for a Flink Application or Statement
      type: object
      allOf:
        - $ref: '#/components/schemas/ResourceBaseV2'
        - type: object
          properties:
            metadata:
              title: SavepointMetadata
              description: Metadata about the Savepoint
              type: object
              x-class-extra-annotation: '@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)'
              properties:
                name:
                  description: Name of the Savepoint
                  type: string
                creationTimestamp:
                  description: Timestamp when the Savepoint was created
                  type: string
                uid:
                  description: Unique identifier of the Savepoint
                  type: string
                labels:
                  description: Labels of the Savepoint
                  type: object
                  additionalProperties:
                    type: string
                annotations:
                  description: Annotations of the Savepoint
                  type: object
                  additionalProperties:
                    type: string
            spec:
              title: SavepointSpec
              description: Spec for Savepoint
              type: object
              x-class-extra-annotation: '@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)'
              properties:
                path:
                  description: Path of the Savepoint
                  type: string
                backoffLimit:
                  description: Backoff limit for the Savepoint
                  type: integer
                  format: int32
                  default: -1
                formatType:
                  description: Format type of the Savepoint
                  type: string
                  enum:
                    - CANONICAL
                    - NATIVE
                    - UNKNOWN
                  default: CANONICAL
            status:
              title: SavepointStatus
              description: Status for Savepoint
              type: object
              x-class-extra-annotation: '@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)'
              properties:
                state:
                  description: State of the Savepoint
                  type: string
                path:
                  description: Path of the Savepoint
                  type: string
                triggerTimestamp:
                  description: Timestamp when the Savepoint was triggered
                  type: string
                resultTimestamp:
                  description: Timestamp when the Savepoint result was received
                  type: string
                failures:
                  description: The number of failures of the Savepoint
                  type: integer
                  format: int32
                error:
                  description: The error message for the Savepoint
                  type: string
                pendingDeletion:
                  description: Whether the Savepoint is pending deletion
                  type: boolean
          required:
            - metadata
            - spec

    SavepointsPage:
      type: object
      allOf:
        - $ref: '#/components/schemas/PaginationResponse'
        - type: object
          properties:
            metadata:
              type: object
              title: SavepointPageMetadata
              properties:
                size:
                  type: integer
                  format: int64
                  default: 0
            items:
              type: array
              items:
                $ref: '#/components/schemas/Savepoint'
              default: [ ]
    StatementStartFromSavepoint:
      title: StartStatementFromSavepoint
      description: Configuration for resuming a Statement from a savepoint. Works only with update Statement.
      type: object
      properties:
        savepointName:
          description: The name of the Savepoint resource to start Statement from. The request will be rejected if savepoint that has not completed is referenced.
          type: string
        uid:
          description: The uuid of the Savepoint resource to start from.
          type: string
        initialSavepointPath:
          description: The path of the savepoint to start the Statement from. This could be an external path too.
          type: string
        allowNonRestoredState:
          description: A boolean flag to allow the job to start even if some state could not be restored.
          type: boolean
        savepointRedeployNonce:
          description: Nonce used to trigger a full redeployment of the job from the savepoint. In order to trigger redeployment, change the number to a different non-null value. Rollback is not possible after redeployment.
          type: integer
          format: int64

    SystemInformation:
      title: SystemInformation
      description: Represents system information about the CMF application
      type: object
      properties:
        status:
          title: SystemInformationStatus
          type: object
          properties:
            version:
              description: Version of the CMF application
              type: string
            revision:
              description: Git commit hash of the CMF application
              type: string

    ResourceInformation:
      title: ResourceInformation
      description: Represents resource information and usage statistics for the CMF application
      type: object
      properties:
        status:
          title: ResourceInformationStatus
          type: object
          properties:
            resources:
              title: Resources
              description: Count of various resource types managed by CMF
              type: object
              properties:
                environments:
                  description: Number of environments
                  type: integer
                applications:
                  description: Number of applications
                  type: integer
                computePools:
                  description: Number of compute pools
                  type: integer
                statements:
                  description: Number of statements
                  type: integer
                secrets:
                  description: Number of secrets
                  type: integer
                catalogs:
                  description: Number of catalogs
                  type: integer
                savepoints:
                  description: Number of savepoints
                  type: integer
                detachedSavepoints:
                  description: Number of detached savepoints
                  type: integer
            resourceSummary:
              title: ResourceSummary
              description: Summary of resource usage
              type: object
              properties:
                cpu:
                  description: Total CPU units allocated
                  type: number
                  format: double
                memory:
                  description: Total memory allocated in bytes
                  type: integer
                  format: int64

    ResourceUsageSummary:
      title: ResourceUsageSummary
      description: Represents a summary of resource usage for the CMF resource
      type: object
      properties:
        jobManager:
          title: JobManager
          description: JobManager resource usage
          type: object
          properties:
            cpu:
              description: Total CPU units allocated
              type: number
              format: double
            memory:
              description: Total memory allocated in bytes
              type: integer
              format: int64
            count:
              description: Number of instances
              type: integer
        taskManager:
          title: TaskManager
          description: TaskManager resource usage
          type: object
          properties:
            cpu:
              description: Total CPU units allocated
              type: number
              format: double
            memory:
              description: Total memory allocated in bytes
              type: integer
              format: int64
            count:
              description: Number of instances
              type: integer
