{
  "apiVersion": "apiextensions.k8s.io/v1",
  "kind": "CustomResourceDefinition",
  "metadata": {
    "name": "replays.cloud.pingcap.com",
    "labels": {}
  },
  "spec": {
    "conversion": {
      "strategy": "None"
    },
    "group": "cloud.pingcap.com",
    "names": {
      "kind": "Replay",
      "listKind": "ReplayList",
      "plural": "replays",
      "shortNames": [
        "rp"
      ],
      "singular": "replay"
    },
    "scope": "Namespaced",
    "versions": [
      {
        "additionalPrinterColumns": [
          {
            "jsonPath": ".spec.clusterId",
            "name": "ClusterID",
            "type": "string"
          },
          {
            "jsonPath": ".spec.state",
            "name": "State",
            "type": "string"
          },
          {
            "jsonPath": ".status.phase",
            "name": "Phase",
            "type": "string"
          },
          {
            "jsonPath": ".metadata.creationTimestamp",
            "name": "Age",
            "type": "date"
          }
        ],
        "name": "v1",
        "schema": {
          "openAPIV3Schema": {
            "description": "Replay is the Schema for the replays 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": "ReplaySpec defines the desired state of Replay",
                "properties": {
                  "kubernetes": {
                    "description": "Kubernetses defines the Kubernetes cluster information where the replay task will run",
                    "properties": {
                      "account": {
                        "description": "aws: account id\ngcp: project name",
                        "type": "string"
                      },
                      "caData": {
                        "description": "client ca of kubernetes",
                        "format": "byte",
                        "type": "string"
                      },
                      "cloud": {
                        "description": "It defines some cloud specific fields",
                        "properties": {
                          "aws": {
                            "properties": {
                              "adminNodeRole": {
                                "description": "AdminNodeRole is the admin nodegroup's node role",
                                "type": "string"
                              },
                              "eksSecurityGroup": {
                                "description": "Security group of eks control-plane",
                                "type": "string"
                              },
                              "subnetGroups": {
                                "description": "all subnets defined for nodegroup or external service",
                                "items": {
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    },
                                    "subnets": {
                                      "items": {
                                        "properties": {
                                          "subnetID": {
                                            "type": "string"
                                          },
                                          "zone": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "subnetID"
                                        ],
                                        "type": "object"
                                      },
                                      "type": "array"
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "subnets"
                                  ],
                                  "type": "object"
                                },
                                "type": "array"
                              }
                            },
                            "required": [
                              "subnetGroups"
                            ],
                            "type": "object"
                          },
                          "azure": {
                            "properties": {
                              "nodeResourceGroup": {
                                "type": "string"
                              },
                              "nodeSubnets": {
                                "items": {
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "name"
                                  ],
                                  "type": "object"
                                },
                                "type": "array"
                              },
                              "nodeZones": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              "podSubnets": {
                                "items": {
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "name"
                                  ],
                                  "type": "object"
                                },
                                "type": "array"
                              },
                              "resourceGroup": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "nodeResourceGroup",
                              "nodeSubnets",
                              "nodeZones",
                              "podSubnets",
                              "resourceGroup"
                            ],
                            "type": "object"
                          },
                          "gcp": {
                            "properties": {
                              "adminNodeSa": {
                                "type": "string"
                              },
                              "nodeZones": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              }
                            },
                            "required": [
                              "adminNodeSa",
                              "nodeZones"
                            ],
                            "type": "object"
                          }
                        },
                        "type": "object"
                      },
                      "endpoint": {
                        "description": "e.g. https://aaa.bbb.ccc",
                        "type": "string"
                      },
                      "kubeConfigSecretRef": {
                        "description": "kubeConfigSecretRef is the secret reference to the kubeconfig of the general dataplane k8s",
                        "properties": {
                          "name": {
                            "description": "name is unique within a namespace to reference a secret resource.",
                            "type": "string"
                          },
                          "namespace": {
                            "description": "namespace defines the space within which the secret name must be unique.",
                            "type": "string"
                          }
                        },
                        "type": "object",
                        "x-kubernetes-map-type": "atomic"
                      },
                      "name": {
                        "description": "name of eks/gke",
                        "type": "string"
                      },
                      "network": {
                        "description": "aws: vpc id\ngcp: network name",
                        "type": "string"
                      },
                      "provider": {
                        "description": "provider of this kubernetes\naws/gcp",
                        "type": "string"
                      },
                      "version": {
                        "description": "Version of kubernetes",
                        "type": "string"
                      }
                    },
                    "required": [
                      "account",
                      "endpoint",
                      "name",
                      "network",
                      "provider"
                    ],
                    "type": "object"
                  },
                  "passwordSecretRef": {
                    "description": "PasswordSecretRef references the secret containing the database password",
                    "properties": {
                      "name": {
                        "description": "name is unique within a namespace to reference a secret resource.",
                        "type": "string"
                      },
                      "namespace": {
                        "description": "namespace defines the space within which the secret name must be unique.",
                        "type": "string"
                      }
                    },
                    "type": "object",
                    "x-kubernetes-map-type": "atomic"
                  },
                  "paused": {
                    "description": "Paused indicates whether controller should stop reconciling this CR",
                    "type": "boolean"
                  },
                  "replayConfig": {
                    "description": "ReplayConfig defines the configuration for the replay",
                    "properties": {
                      "bufSize": {
                        "description": "BufSize is the size of buffer for reordering commands from audit files",
                        "format": "int32",
                        "type": "integer"
                      },
                      "checkpointPath": {
                        "description": "CheckpointPath is the file path to store replay checkpoint information\nIf the file exists and not empty, the internal state will be loaded from the file to resume replaying",
                        "type": "string"
                      },
                      "commandEndTime": {
                        "description": "CommandEndTime is the end time to replay the traffic, format is RFC3339\nThe command whose end ts is before or equal this end time will be ignored",
                        "type": "string"
                      },
                      "commandStartTime": {
                        "description": "CommandStartTime is the start time to replay the traffic, format is RFC3339\nThe command before this start time will be ignored",
                        "type": "string"
                      },
                      "customArguments": {
                        "additionalProperties": {
                          "type": "string"
                        },
                        "description": "CustomArguments specifies user-defined key-value pairs that will be passed as additional arguments to the component.",
                        "type": "object"
                      },
                      "dryRun": {
                        "description": "DryRun indicates whether to run in dry-run mode (don't actually connect to TiDB)",
                        "type": "boolean"
                      },
                      "dynamicInput": {
                        "description": "DynamicInput is the dynamic input path for continuous replay",
                        "type": "boolean"
                      },
                      "format": {
                        "description": "Format is the audit log format",
                        "type": "string"
                      },
                      "ignoreErrs": {
                        "description": "IgnoreErrs indicates whether to ignore errors during replay",
                        "type": "boolean"
                      },
                      "image": {
                        "description": "Image is the replayer container image",
                        "type": "string"
                      },
                      "logFile": {
                        "description": "LogFile is the path to the log file",
                        "type": "string"
                      },
                      "outputPath": {
                        "description": "OutputPath is the file path to store replayed sql. Empty indicates do not output replayed sql.",
                        "type": "string"
                      },
                      "psClose": {
                        "description": "PsClose defines the prepared statement close policy",
                        "type": "string"
                      },
                      "readOnly": {
                        "description": "ReadOnly indicates whether to only replay read-only queries",
                        "type": "boolean"
                      },
                      "replayerCount": {
                        "description": "ReplayerCount is the total number of replayer instances\nUsed for distributed replay to split the workload",
                        "format": "int32",
                        "type": "integer"
                      },
                      "replayerIndex": {
                        "description": "ReplayerIndex is the index of current replayer instance (0-based)\nUsed for distributed replay to identify each instance",
                        "format": "int32",
                        "type": "integer"
                      },
                      "speed": {
                        "description": "Speed is the replay speed multiplier (e.g., 1.0 for normal speed, 2.0 for 2x speed)",
                        "type": "string"
                      },
                      "startTime": {
                        "description": "StartTime is the actual start time of the replay task",
                        "type": "string"
                      }
                    },
                    "type": "object"
                  },
                  "sourceClusterID": {
                    "description": "SourceClusterID is the ID of the source dedicated cluster from which audit logs will be replayed",
                    "type": "string"
                  },
                  "sourceClusterType": {
                    "description": "SourceClusterType indicates the type of the source cluster",
                    "type": "string"
                  },
                  "sourceProvider": {
                    "description": "SourceProvider indicates the cloud provider of the source cluster",
                    "type": "string"
                  },
                  "sourceRegion": {
                    "description": "SourceRegion indicates the region of the source cluster",
                    "type": "string"
                  },
                  "state": {
                    "description": "State represents the desired state of the Replay",
                    "enum": [
                      "Deploy",
                      "Active",
                      "Pause",
                      "Delete"
                    ],
                    "type": "string"
                  },
                  "targetClusterID": {
                    "description": "TargetClusterID is the ID of the target cluster where the replay will be executed，dedicated/serverless/next-gen",
                    "type": "string"
                  },
                  "targetClusterType": {
                    "description": "TargetClusterType indicates the type of the target cluster",
                    "type": "string"
                  },
                  "targetProvider": {
                    "description": "TargetProvider indicates the cloud provider of the target cluster",
                    "type": "string"
                  },
                  "targetRegion": {
                    "description": "TargetRegion indicates the region of the target cluster",
                    "type": "string"
                  },
                  "tasks": {
                    "description": "Tasks defines the list of replay tasks to be executed",
                    "items": {
                      "description": "ReplayTask defines a single replay task",
                      "properties": {
                        "commandEndTime": {
                          "description": "CommandEndTime is the end time to replay the traffic, format is RFC3339\nThe command whose end ts is before or equal this end time will be ignored",
                          "type": "string"
                        },
                        "commandStartTime": {
                          "description": "CommandStartTime is the start time to replay the traffic, format is RFC3339\nThe command before this start time will be ignored",
                          "type": "string"
                        },
                        "name": {
                          "description": "Name is the name of the task",
                          "type": "string"
                        },
                        "replayConfigs": {
                          "description": "ReplayConfigs defines the per-replay configurations for this task",
                          "items": {
                            "description": "ReplayConfig defines the configuration for the replay process",
                            "properties": {
                              "bufSize": {
                                "description": "BufSize is the size of buffer for reordering commands from audit files",
                                "format": "int32",
                                "type": "integer"
                              },
                              "checkpointPath": {
                                "description": "CheckpointPath is the file path to store replay checkpoint information\nIf the file exists and not empty, the internal state will be loaded from the file to resume replaying",
                                "type": "string"
                              },
                              "commandEndTime": {
                                "description": "CommandEndTime is the end time to replay the traffic, format is RFC3339\nThe command whose end ts is before or equal this end time will be ignored",
                                "type": "string"
                              },
                              "commandStartTime": {
                                "description": "CommandStartTime is the start time to replay the traffic, format is RFC3339\nThe command before this start time will be ignored",
                                "type": "string"
                              },
                              "customArguments": {
                                "additionalProperties": {
                                  "type": "string"
                                },
                                "description": "CustomArguments specifies user-defined key-value pairs that will be passed as additional arguments to the component.",
                                "type": "object"
                              },
                              "dryRun": {
                                "description": "DryRun indicates whether to run in dry-run mode (don't actually connect to TiDB)",
                                "type": "boolean"
                              },
                              "dynamicInput": {
                                "description": "DynamicInput is the dynamic input path for continuous replay",
                                "type": "boolean"
                              },
                              "format": {
                                "description": "Format is the audit log format",
                                "type": "string"
                              },
                              "ignoreErrs": {
                                "description": "IgnoreErrs indicates whether to ignore errors during replay",
                                "type": "boolean"
                              },
                              "image": {
                                "description": "Image is the replayer container image",
                                "type": "string"
                              },
                              "logFile": {
                                "description": "LogFile is the path to the log file",
                                "type": "string"
                              },
                              "outputPath": {
                                "description": "OutputPath is the file path to store replayed sql. Empty indicates do not output replayed sql.",
                                "type": "string"
                              },
                              "psClose": {
                                "description": "PsClose defines the prepared statement close policy",
                                "type": "string"
                              },
                              "readOnly": {
                                "description": "ReadOnly indicates whether to only replay read-only queries",
                                "type": "boolean"
                              },
                              "replayerCount": {
                                "description": "ReplayerCount is the total number of replayer instances\nUsed for distributed replay to split the workload",
                                "format": "int32",
                                "type": "integer"
                              },
                              "replayerIndex": {
                                "description": "ReplayerIndex is the index of current replayer instance (0-based)\nUsed for distributed replay to identify each instance",
                                "format": "int32",
                                "type": "integer"
                              },
                              "speed": {
                                "description": "Speed is the replay speed multiplier (e.g., 1.0 for normal speed, 2.0 for 2x speed)",
                                "type": "string"
                              },
                              "startTime": {
                                "description": "StartTime is the actual start time of the replay task",
                                "type": "string"
                              }
                            },
                            "type": "object"
                          },
                          "type": "array"
                        },
                        "replicas": {
                          "description": "Replicas is the number of replicas for this task",
                          "format": "int32",
                          "type": "integer"
                        },
                        "resources": {
                          "description": "Resources defines the compute resources required by the replay task",
                          "properties": {
                            "cpu": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "string"
                                }
                              ],
                              "description": "CPU is the CPU resource requirement",
                              "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$",
                              "x-kubernetes-int-or-string": true
                            },
                            "instanceType": {
                              "description": "InstanceType is the instance type for the replay task",
                              "type": "string"
                            },
                            "memory": {
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "string"
                                }
                              ],
                              "description": "Memory is the memory resource requirement",
                              "pattern": "^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$",
                              "x-kubernetes-int-or-string": true
                            },
                            "storageSize": {
                              "description": "StorageSize is the storage size for the replay task",
                              "type": "string"
                            }
                          },
                          "type": "object"
                        },
                        "sourceAuditLogAddrs": {
                          "description": "SourceAuditLogAddrs is the list of audit log addresses to replay from",
                          "items": {
                            "description": "AuditLogAddr defines the audit log address configuration",
                            "properties": {
                              "aws": {
                                "description": "AWS is the AWS audit log configuration",
                                "properties": {
                                  "externalID": {
                                    "description": "ExternalID is the external ID for assuming the IAM role",
                                    "type": "string"
                                  },
                                  "roleArn": {
                                    "description": "RoleArn is the ARN of the IAM role to access the S3 bucket",
                                    "type": "string"
                                  },
                                  "s3URL": {
                                    "description": "S3URL is the S3 URL of the audit log",
                                    "type": "string"
                                  }
                                },
                                "type": "object"
                              }
                            },
                            "type": "object"
                          },
                          "type": "array"
                        },
                        "startTime": {
                          "description": "StartTime is the actual start time of the replay task",
                          "type": "string"
                        },
                        "targetEndpoint": {
                          "description": "TargetEndpoint is the target TiDB endpoint to replay to",
                          "type": "string"
                        },
                        "username": {
                          "description": "Username is the username to connect to TiDB",
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "sourceAuditLogAddrs",
                        "targetEndpoint",
                        "username"
                      ],
                      "type": "object"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "kubernetes",
                  "passwordSecretRef",
                  "replayConfig",
                  "sourceClusterType",
                  "sourceProvider",
                  "sourceRegion",
                  "state",
                  "targetClusterID",
                  "targetClusterType",
                  "targetProvider",
                  "targetRegion",
                  "tasks"
                ],
                "type": "object"
              },
              "status": {
                "description": "ReplayStatus defines the observed state of Replay",
                "properties": {
                  "awsNodeRoleARN": {
                    "description": "AWSNodeRoleARN is the ARN of the AWS node role.",
                    "type": "string"
                  },
                  "lastUpdateTime": {
                    "description": "LastUpdateTime is the last time the status was updated",
                    "format": "date-time",
                    "type": "string"
                  },
                  "message": {
                    "description": "Message provides additional information about the replay status",
                    "type": "string"
                  },
                  "phase": {
                    "description": "Phase denotes current replay progress",
                    "enum": [
                      "Creating",
                      "Running",
                      "Stopped",
                      "Deleted"
                    ],
                    "type": "string"
                  },
                  "tasks": {
                    "description": "Tasks contains the status of individual replay tasks",
                    "items": {
                      "description": "ReplayTaskStatus defines the status of a replay task",
                      "properties": {
                        "message": {
                          "description": "Message provides additional information about the task (e.g., errors during task creation)",
                          "type": "string"
                        },
                        "name": {
                          "description": "Name is the name of the task",
                          "type": "string"
                        },
                        "replicaStatuses": {
                          "description": "ReplicaStatuses contains the status of each individual replica",
                          "items": {
                            "description": "ReplayReplicaStatus defines the status of a single replica in a replay task",
                            "properties": {
                              "index": {
                                "description": "Index is the replica index (0-based)",
                                "format": "int32",
                                "type": "integer"
                              },
                              "message": {
                                "description": "Message provides error or status information for this replica\nThis replaces the separate ErrorMessage field",
                                "type": "string"
                              },
                              "phase": {
                                "description": "Phase is the current phase of this replica",
                                "type": "string"
                              },
                              "podName": {
                                "description": "PodName is the name of the pod running this replica",
                                "type": "string"
                              },
                              "ready": {
                                "description": "Ready indicates whether this replica is ready",
                                "type": "boolean"
                              },
                              "taskInfo": {
                                "description": "TaskInfo contains detailed replay information from the replayer API",
                                "properties": {
                                  "endTime": {
                                    "description": "EndTime is the end time of the job",
                                    "type": "string"
                                  },
                                  "error": {
                                    "description": "Error is the error message of the job\nIt's recorded when the job is stopped due to an error",
                                    "type": "string"
                                  },
                                  "failedCommands": {
                                    "description": "FailedCommands is the number of commands that failed during replay",
                                    "format": "int64",
                                    "type": "integer"
                                  },
                                  "lastCommandTimestamp": {
                                    "description": "LastCommandTimestamp is the start timestamp of the latest command being replayed",
                                    "type": "string"
                                  },
                                  "processedBytes": {
                                    "description": "ProcessedBytes is the number of bytes that have been processed",
                                    "format": "int64",
                                    "type": "integer"
                                  },
                                  "progress": {
                                    "description": "Progress is the progress of the job (0-100)\nNote: Always 0 for audit log format",
                                    "format": "int32",
                                    "type": "integer"
                                  },
                                  "replayedCommands": {
                                    "description": "ReplayedCommands is the number of commands that have been replayed",
                                    "format": "int64",
                                    "type": "integer"
                                  },
                                  "sourceAuditLogAddrs": {
                                    "description": "SourceAuditLogAddrs contains the audit log addresses being processed",
                                    "items": {
                                      "description": "AuditLogAddr defines the audit log address configuration",
                                      "properties": {
                                        "aws": {
                                          "description": "AWS is the AWS audit log configuration",
                                          "properties": {
                                            "externalID": {
                                              "description": "ExternalID is the external ID for assuming the IAM role",
                                              "type": "string"
                                            },
                                            "roleArn": {
                                              "description": "RoleArn is the ARN of the IAM role to access the S3 bucket",
                                              "type": "string"
                                            },
                                            "s3URL": {
                                              "description": "S3URL is the S3 URL of the audit log",
                                              "type": "string"
                                            }
                                          },
                                          "type": "object"
                                        }
                                      },
                                      "type": "object"
                                    },
                                    "type": "array"
                                  },
                                  "startTime": {
                                    "description": "StartTime is the start time of the job",
                                    "type": "string"
                                  },
                                  "status": {
                                    "description": "Status is the current status of the job\nPossible values: \"canceled\", \"done\", \"running\"",
                                    "type": "string"
                                  },
                                  "totalBytes": {
                                    "description": "TotalBytes is the total size of audit logs to replay (in bytes)",
                                    "format": "int64",
                                    "type": "integer"
                                  },
                                  "totalCommands": {
                                    "description": "TotalCommands is the total number of commands to replay",
                                    "format": "int64",
                                    "type": "integer"
                                  },
                                  "type": {
                                    "description": "Type indicates the job type (replay or capture)",
                                    "type": "string"
                                  }
                                },
                                "type": "object"
                              }
                            },
                            "required": [
                              "podName"
                            ],
                            "type": "object"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "name"
                      ],
                      "type": "object"
                    },
                    "type": "array"
                  }
                },
                "type": "object"
              }
            },
            "type": "object"
          }
        },
        "served": true,
        "storage": true,
        "subresources": {
          "status": {}
        }
      }
    ]
  }
}
