{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/couchbase/main/json-schema/couchbase-database-credential-schema.json",
  "title": "DatabaseCredential",
  "description": "Database access credential",
  "x-generated": "2026-10-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/couchbase-database-credentials-api-openapi.yml#/components/schemas/DatabaseCredential",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Credential UUID"
    },
    "name": {
      "type": "string",
      "description": "Credential name"
    },
    "access": {
      "type": "array",
      "description": "Access privileges",
      "items": {
        "type": "object",
        "properties": {
          "privileges": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "data_reader",
                "data_writer"
              ]
            }
          },
          "resources": {
            "type": "object",
            "properties": {
              "buckets": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "collections": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "audit": {
      "$ref": "#/$defs/AuditInfo"
    }
  },
  "$defs": {
    "AuditInfo": {
      "type": "object",
      "description": "Audit timestamps",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time",
          "description": "Creation timestamp"
        },
        "modifiedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Last modification timestamp"
        },
        "createdBy": {
          "type": "string",
          "description": "User who created the resource"
        },
        "modifiedBy": {
          "type": "string",
          "description": "User who last modified the resource"
        },
        "version": {
          "type": "integer",
          "description": "Resource version number"
        }
      }
    }
  }
}