{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/google-cloud-sql/json-schema/google-cloud-sql-blue-green-deployment-schema.json",
  "title": "BlueGreenDeployment",
  "description": "A `BlueGreenDeployment` resource represents a Cloud SQL blue-green deployment setup.",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/google-cloud-sql-blue-green-deployments-api-openapi.yml#/components/schemas/BlueGreenDeployment",
  "properties": {
    "deploymentTasks": {
      "$ref": "#/$defs/DeploymentTasks",
      "description": "Output only. Combined list of tasks for all paired nodes."
    },
    "switchoverTargetInstance": {
      "type": "string",
      "readOnly": true,
      "description": "Output only. The full resource name of the primary target instance (the \"green\" instance) that will be promoted during switchover. This field is always populated once the deployment is created. Format: projects/{project}/instances/{instance}"
    },
    "name": {
      "description": "Output only. Identifier. The full resource name of the deployment. Format: projects/{project}/locations/{location}/blueGreenDeployments/{deployment_id}",
      "type": "string",
      "readOnly": true
    },
    "deploymentMappings": {
      "description": "Output only. A list representing the pairs of source and target instances in the deployment.",
      "items": {
        "$ref": "#/$defs/SourceTargetPairedNode"
      },
      "readOnly": true,
      "type": "array"
    },
    "state": {
      "description": "Output only. The current state of the blue-green deployment.",
      "enum": [
        "STATE_UNSPECIFIED",
        "PROVISIONING",
        "SWITCHOVER_READY",
        "SWITCHOVER_NOT_READY",
        "SWITCHOVER_IN_PROGRESS",
        "SWITCHOVER_COMPLETED",
        "DELETING"
      ],
      "type": "string",
      "readOnly": true
    },
    "createTime": {
      "description": "Output only. The time when the deployment was created. Example: `2024-01-01T00:00:00Z`",
      "type": "string",
      "format": "google-datetime",
      "readOnly": true
    },
    "description": {
      "type": "string",
      "description": "Optional. User-provided description for the deployment. The description can be up to 255 characters long."
    },
    "sourceInstance": {
      "description": "Required. Immutable. Required on create, and immutable. The full resource name of the source instance (the \"blue\" instance). Format: projects/{project}/instances/{instance}",
      "type": "string"
    },
    "requestedConfig": {
      "$ref": "#/$defs/RequestedConfig",
      "description": "Optional. Immutable. Optional on create, and immutable. The configuration intended for the target instance(s) when the deployment was created."
    },
    "errorDetail": {
      "type": "string",
      "description": "Output only. Provides details on why switchover is not possible. This field is empty unless a switchover attempt failed or the state is `SWITCHOVER_NOT_READY`. Example: \"The target database version does not match the source instance database version.\"",
      "readOnly": true
    }
  },
  "type": "object",
  "$defs": {
    "ConfigDiff": {
      "properties": {
        "targetValue": {
          "type": "string",
          "readOnly": true,
          "description": "Output only. The value on the target instance."
        },
        "field": {
          "description": "Output only. The name of the field that differs in the blue and green instances, fully-qualified. Example: `settings.tier`",
          "readOnly": true,
          "type": "string"
        },
        "sourceValue": {
          "description": "Output only. The value on the source instance.",
          "readOnly": true,
          "type": "string"
        }
      },
      "type": "object",
      "description": "Represents a specific configuration difference between blue and green instances."
    },
    "DeploymentTask": {
      "type": "object",
      "properties": {
        "errorMessage": {
          "readOnly": true,
          "description": "Output only. Optional error details if the task state is `FAILED`.",
          "type": "string"
        },
        "type": {
          "enum": [
            "TYPE_UNSPECIFIED",
            "PROVISION",
            "UPGRADE",
            "SWITCHOVER",
            "DELETE",
            "POST_SWITCHOVER_OPERATIONS"
          ],
          "type": "string",
          "readOnly": true,
          "description": "Output only. The type of the task."
        },
        "endTime": {
          "description": "Output only. Task end time (if completed).",
          "format": "google-datetime",
          "readOnly": true,
          "type": "string"
        },
        "startTime": {
          "description": "Output only. Task start time.",
          "readOnly": true,
          "format": "google-datetime",
          "type": "string"
        },
        "state": {
          "enum": [
            "STATE_UNSPECIFIED",
            "PENDING",
            "RUNNING",
            "SUCCEEDED",
            "FAILED"
          ],
          "type": "string",
          "readOnly": true,
          "description": "Output only. The current state of the task."
        }
      },
      "description": "Represents a task executed as part of the deployment on a target instance."
    },
    "DeploymentTasks": {
      "type": "object",
      "properties": {
        "task": {
          "readOnly": true,
          "description": "Output only. Tasks performed or being performed on the paired nodes of the deployment at a consolidated level.",
          "items": {
            "$ref": "#/$defs/DeploymentTask"
          },
          "type": "array"
        }
      },
      "description": "Combined list of tasks for all paired nodes in the deployment."
    },
    "IpMapping": {
      "type": "object",
      "description": "Database instance IP mapping",
      "properties": {
        "timeToRetire": {
          "format": "google-datetime",
          "description": "The due time for this IP to be retired in [RFC 3339](https://tools.ietf.org/html/rfc3339) format, for example `2012-11-15T16:19:00.094Z`. This field is only available when the IP is scheduled to be retired.",
          "type": "string"
        },
        "type": {
          "enum": [
            "SQL_IP_ADDRESS_TYPE_UNSPECIFIED",
            "PRIMARY",
            "OUTGOING",
            "PRIVATE",
            "MIGRATED_1ST_GEN"
          ],
          "description": "The type of this IP address. A `PRIMARY` address is a public address that can accept incoming connections. A `PRIVATE` address is a private address that can accept incoming connections. An `OUTGOING` address is the source address of connections originating from the instance, if supported.",
          "type": "string"
        },
        "ipAddress": {
          "type": "string",
          "description": "The IP address assigned."
        }
      }
    },
    "NodeInfo": {
      "description": "Details about an instance within the deployment.",
      "type": "object",
      "properties": {
        "instance": {
          "description": "Output only. The full resource name of the instance. Format: projects/{project}/instances/{instance}",
          "readOnly": true,
          "type": "string"
        },
        "ipMappings": {
          "description": "Output only. The list of IP addresses for this instance.",
          "readOnly": true,
          "items": {
            "$ref": "#/$defs/IpMapping"
          },
          "type": "array"
        },
        "connection": {
          "readOnly": true,
          "description": "Output only. The instance connection name.",
          "type": "string"
        },
        "dns": {
          "type": "string",
          "description": "Output only. The unique DNS name for this instance.",
          "readOnly": true
        }
      }
    },
    "RequestedConfig": {
      "properties": {
        "databaseVersion": {
          "type": "string",
          "description": "Optional. The target database major version for the upgrade. For example, `MYSQL_8_0` or `POSTGRES_15`."
        }
      },
      "type": "object",
      "description": "Configuration specified by the user at creation time for the target (green) instance."
    },
    "SourceTargetPairedNode": {
      "properties": {
        "diffs": {
          "readOnly": true,
          "description": "Output only. Describes the list of differences for the `SourceTargetPairedNode`.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/ConfigDiff"
          }
        },
        "state": {
          "description": "Output only. Specifies the current state of this specific source-target pair.",
          "enum": [
            "STATE_UNSPECIFIED",
            "PROVISIONING",
            "PROVISIONED",
            "UPGRADING",
            "UPGRADED",
            "UPGRADE_FAILED",
            "SWITCHOVER_IN_PROGRESS",
            "SWITCHOVER_FAILED",
            "SWITCHOVER_SUCCEEDED",
            "DELETING"
          ],
          "type": "string",
          "readOnly": true
        },
        "source": {
          "$ref": "#/$defs/NodeInfo",
          "description": "Output only. Specifies the resource name of the source instance in this pair."
        },
        "target": {
          "$ref": "#/$defs/NodeInfo",
          "description": "Output only. Specifies details of the corresponding target instance in this pair."
        }
      },
      "description": "Represents a pairing of a source instance node and a target instance node.",
      "type": "object"
    }
  }
}