{
  "description": "Database is the Schema for the databases API",
  "properties": {
    "apiVersion": {
      "description": "APIVersion defines the versioned schema of this representation of an object.\nServers should convert recognized schemas to the latest internal value, and\nmay reject unrecognized values.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
      "type": "string"
    },
    "kind": {
      "description": "Kind is a string value representing the REST resource this object represents.\nServers may infer this from the endpoint the client submits requests to.\nCannot be updated.\nIn CamelCase.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
      "type": "string"
    },
    "metadata": {
      "type": "object"
    },
    "spec": {
      "description": "Specification of the desired Database.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status",
      "properties": {
        "allowConnections": {
          "description": "Maps to the `ALLOW_CONNECTIONS` parameter of `CREATE DATABASE` and\n`ALTER DATABASE`. If false then no one can connect to this database.",
          "type": "boolean"
        },
        "builtinLocale": {
          "description": "Maps to the `BUILTIN_LOCALE` parameter of `CREATE DATABASE`. This\nsetting cannot be changed. Specifies the locale name when the\nbuiltin provider is used. This option requires `localeProvider` to\nbe set to `builtin`. Available from PostgreSQL 17.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "builtinLocale is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "cluster": {
          "description": "The name of the PostgreSQL cluster hosting the database.",
          "properties": {
            "name": {
              "default": "",
              "description": "Name of the referent.\nThis field is effectively required, but due to backwards compatibility is\nallowed to be empty. Instances of this type with an empty value here are\nalmost certainly wrong.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names",
              "type": "string"
            }
          },
          "type": "object",
          "x-kubernetes-map-type": "atomic",
          "additionalProperties": false
        },
        "collationVersion": {
          "description": "Maps to the `COLLATION_VERSION` parameter of `CREATE DATABASE`. This\nsetting cannot be changed.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "collationVersion is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "connectionLimit": {
          "description": "Maps to the `CONNECTION LIMIT` clause of `CREATE DATABASE` and\n`ALTER DATABASE`. How many concurrent connections can be made to\nthis database. -1 (the default) means no limit.",
          "type": "integer"
        },
        "databaseReclaimPolicy": {
          "default": "retain",
          "description": "The policy for end-of-life maintenance of this database.",
          "enum": [
            "delete",
            "retain"
          ],
          "type": "string"
        },
        "encoding": {
          "description": "Maps to the `ENCODING` parameter of `CREATE DATABASE`. This setting\ncannot be changed. Character set encoding to use in the database.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "encoding is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "ensure": {
          "default": "present",
          "description": "Ensure the PostgreSQL database is `present` or `absent` - defaults to \"present\".",
          "enum": [
            "present",
            "absent"
          ],
          "type": "string"
        },
        "extensions": {
          "description": "The list of extensions to be managed in the database",
          "items": {
            "description": "ExtensionSpec configures an extension in a database",
            "properties": {
              "ensure": {
                "default": "present",
                "description": "Specifies whether an extension/schema should be present or absent in\nthe database. If set to `present`, the extension/schema will be\ncreated if it does not exist. If set to `absent`, the\nextension/schema will be removed if it exists.",
                "enum": [
                  "present",
                  "absent"
                ],
                "type": "string"
              },
              "name": {
                "description": "Name of the extension/schema",
                "type": "string"
              },
              "schema": {
                "description": "The name of the schema in which to install the extension's objects,\nin case the extension allows its contents to be relocated. If not\nspecified (default), and the extension's control file does not\nspecify a schema either, the current default object creation schema\nis used.",
                "type": "string"
              },
              "version": {
                "description": "The version of the extension to install. If empty, the operator will\ninstall the default version (whatever is specified in the\nextension's control file)",
                "type": "string"
              }
            },
            "required": [
              "name"
            ],
            "type": "object",
            "additionalProperties": false
          },
          "type": "array"
        },
        "icuLocale": {
          "description": "Maps to the `ICU_LOCALE` parameter of `CREATE DATABASE`. This\nsetting cannot be changed. Specifies the ICU locale when the ICU\nprovider is used. This option requires `localeProvider` to be set to\n`icu`. Available from PostgreSQL 15.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "icuLocale is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "icuRules": {
          "description": "Maps to the `ICU_RULES` parameter of `CREATE DATABASE`. This setting\ncannot be changed. Specifies additional collation rules to customize\nthe behavior of the default collation. This option requires\n`localeProvider` to be set to `icu`. Available from PostgreSQL 16.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "icuRules is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "isTemplate": {
          "description": "Maps to the `IS_TEMPLATE` parameter of `CREATE DATABASE` and `ALTER\nDATABASE`. If true, this database is considered a template and can\nbe cloned by any user with `CREATEDB` privileges.",
          "type": "boolean"
        },
        "locale": {
          "description": "Maps to the `LOCALE` parameter of `CREATE DATABASE`. This setting\ncannot be changed. Sets the default collation order and character\nclassification in the new database.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "locale is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "localeCType": {
          "description": "Maps to the `LC_CTYPE` parameter of `CREATE DATABASE`. This setting\ncannot be changed.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "localeCType is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "localeCollate": {
          "description": "Maps to the `LC_COLLATE` parameter of `CREATE DATABASE`. This\nsetting cannot be changed.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "localeCollate is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "localeProvider": {
          "description": "Maps to the `LOCALE_PROVIDER` parameter of `CREATE DATABASE`. This\nsetting cannot be changed. This option sets the locale provider for\ndatabases created in the new cluster. Available from PostgreSQL 16.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "localeProvider is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "name": {
          "description": "The name of the database to create inside PostgreSQL. This setting cannot be changed.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "name is immutable",
              "rule": "self == oldSelf"
            },
            {
              "message": "the name postgres is reserved",
              "rule": "self != 'postgres'"
            },
            {
              "message": "the name template0 is reserved",
              "rule": "self != 'template0'"
            },
            {
              "message": "the name template1 is reserved",
              "rule": "self != 'template1'"
            }
          ]
        },
        "owner": {
          "description": "Maps to the `OWNER` parameter of `CREATE DATABASE`.\nMaps to the `OWNER TO` command of `ALTER DATABASE`.\nThe role name of the user who owns the database inside PostgreSQL.",
          "type": "string"
        },
        "schemas": {
          "description": "The list of schemas to be managed in the database",
          "items": {
            "description": "SchemaSpec configures a schema in a database",
            "properties": {
              "ensure": {
                "default": "present",
                "description": "Specifies whether an extension/schema should be present or absent in\nthe database. If set to `present`, the extension/schema will be\ncreated if it does not exist. If set to `absent`, the\nextension/schema will be removed if it exists.",
                "enum": [
                  "present",
                  "absent"
                ],
                "type": "string"
              },
              "name": {
                "description": "Name of the extension/schema",
                "type": "string"
              },
              "owner": {
                "description": "The role name of the user who owns the schema inside PostgreSQL.\nIt maps to the `AUTHORIZATION` parameter of `CREATE SCHEMA` and the\n`OWNER TO` command of `ALTER SCHEMA`.",
                "type": "string"
              }
            },
            "required": [
              "name"
            ],
            "type": "object",
            "additionalProperties": false
          },
          "type": "array"
        },
        "tablespace": {
          "description": "Maps to the `TABLESPACE` parameter of `CREATE DATABASE`.\nMaps to the `SET TABLESPACE` command of `ALTER DATABASE`.\nThe name of the tablespace (in PostgreSQL) that will be associated\nwith the new database. This tablespace will be the default\ntablespace used for objects created in this database.",
          "type": "string"
        },
        "template": {
          "description": "Maps to the `TEMPLATE` parameter of `CREATE DATABASE`. This setting\ncannot be changed. The name of the template from which to create\nthis database.",
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "template is immutable",
              "rule": "self == oldSelf"
            }
          ]
        }
      },
      "required": [
        "cluster",
        "name",
        "owner"
      ],
      "type": "object",
      "x-kubernetes-validations": [
        {
          "message": "builtinLocale is only available when localeProvider is set to `builtin`",
          "rule": "!has(self.builtinLocale) || self.localeProvider == 'builtin'"
        },
        {
          "message": "icuLocale is only available when localeProvider is set to `icu`",
          "rule": "!has(self.icuLocale) || self.localeProvider == 'icu'"
        },
        {
          "message": "icuRules is only available when localeProvider is set to `icu`",
          "rule": "!has(self.icuRules) || self.localeProvider == 'icu'"
        }
      ],
      "additionalProperties": false
    },
    "status": {
      "description": "Most recently observed status of the Database. This data may not be up to\ndate. Populated by the system. Read-only.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status",
      "properties": {
        "applied": {
          "description": "Applied is true if the database was reconciled correctly",
          "type": "boolean"
        },
        "extensions": {
          "description": "Extensions is the status of the managed extensions",
          "items": {
            "description": "DatabaseObjectStatus is the status of the managed database objects",
            "properties": {
              "applied": {
                "description": "True of the object has been installed successfully in\nthe database",
                "type": "boolean"
              },
              "message": {
                "description": "Message is the object reconciliation message",
                "type": "string"
              },
              "name": {
                "description": "The name of the object",
                "type": "string"
              }
            },
            "required": [
              "applied",
              "name"
            ],
            "type": "object",
            "additionalProperties": false
          },
          "type": "array"
        },
        "message": {
          "description": "Message is the reconciliation output message",
          "type": "string"
        },
        "observedGeneration": {
          "description": "A sequence number representing the latest\ndesired state that was synchronized",
          "format": "int64",
          "type": "integer"
        },
        "schemas": {
          "description": "Schemas is the status of the managed schemas",
          "items": {
            "description": "DatabaseObjectStatus is the status of the managed database objects",
            "properties": {
              "applied": {
                "description": "True of the object has been installed successfully in\nthe database",
                "type": "boolean"
              },
              "message": {
                "description": "Message is the object reconciliation message",
                "type": "string"
              },
              "name": {
                "description": "The name of the object",
                "type": "string"
              }
            },
            "required": [
              "applied",
              "name"
            ],
            "type": "object",
            "additionalProperties": false
          },
          "type": "array"
        }
      },
      "type": "object",
      "additionalProperties": false
    }
  },
  "required": [
    "metadata",
    "spec"
  ],
  "type": "object"
}
