<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
		xmlns="http://www.springframework.org/schema/integration/cassandra"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema"
		xmlns:tool="http://www.springframework.org/schema/tool"
		xmlns:integration="http://www.springframework.org/schema/integration"
		targetNamespace="http://www.springframework.org/schema/integration/cassandra"
		elementFormDefault="qualified">
	<xsd:import namespace="http://www.springframework.org/schema/beans"/>
	<xsd:import namespace="http://www.springframework.org/schema/tool"/>
	<xsd:import namespace="http://www.springframework.org/schema/integration"
				schemaLocation="https://www.springframework.org/schema/integration/spring-integration.xsd"/>

	<xsd:annotation>
		<xsd:documentation><![CDATA[
			Defines the configuration elements for the Spring Integration Cassandra Adapters.
		]]></xsd:documentation>
	</xsd:annotation>

	<xsd:element name="outbound-channel-adapter">
		<xsd:annotation>
			<xsd:documentation>
				Defines cassandra outbound channel adapter that
				writes the contents of the
				Message into Cassandra cluster
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="outboundType">
					<xsd:choice minOccurs="0" maxOccurs="2">
						<xsd:element name="parameter-expression" type="queryParameterType" minOccurs="0"
									 maxOccurs="unbounded">
							<xsd:annotation>
								<xsd:documentation>
									Specify an expression for parameter variable placeholder in cql statement.
								</xsd:documentation>
							</xsd:annotation>
						</xsd:element>
					</xsd:choice>
					<xsd:attributeGroup ref="integration:channelAdapterAttributes"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:element name="outbound-gateway">
		<xsd:annotation>
			<xsd:documentation>
				Defines cassandra outbound gateway that
				writes the contents of the
				Message into Cassandra cluster
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:complexContent>
				<xsd:extension base="outboundType">
					<xsd:choice minOccurs="0" maxOccurs="2">
						<xsd:element name="parameter-expression" type="queryParameterType" minOccurs="0"
									 maxOccurs="unbounded">
							<xsd:annotation>
								<xsd:documentation>
									Specify an expression for parameter variable placeholder in cql statement.
								</xsd:documentation>
							</xsd:annotation>
						</xsd:element>
					</xsd:choice>
					<xsd:attribute name="reply-channel" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation>
								Message Channel to which replies should be sent after being received from Cassandra
								cluster.
							</xsd:documentation>
							<xsd:appinfo>
								<tool:annotation kind="ref">
									<tool:expected-type
											type="org.springframework.messaging.MessageChannel"/>
								</tool:annotation>
							</xsd:appinfo>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="id" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation>
								Unique ID for this gateway.
							</xsd:documentation>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attribute name="request-channel" type="xsd:string">
						<xsd:annotation>
							<xsd:documentation>
								Message Channel to which Messages should be sent to Cassandra.
							</xsd:documentation>
							<xsd:appinfo>
								<tool:annotation kind="ref">
									<tool:expected-type
											type="org.springframework.messaging.MessageChannel"/>
								</tool:annotation>
							</xsd:appinfo>
						</xsd:annotation>
					</xsd:attribute>
					<xsd:attributeGroup ref="integration:smartLifeCycleAttributeGroup"/>
				</xsd:extension>
			</xsd:complexContent>
		</xsd:complexType>
	</xsd:element>

	<xsd:complexType name="outboundType">
		<xsd:annotation>
			<xsd:documentation>
				Common configuration for cassandra adapters.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:element ref="integration:poller" minOccurs="0"/>
			<xsd:element name="request-handler-advice-chain" type="integration:handlerAdviceChainType" minOccurs="0"/>
		</xsd:sequence>
		<xsd:attribute name="cassandra-template" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
					Reference to an instance of
					'org.springframework.data.cassandra.core.ReactiveCassandraOperations'.
				</xsd:documentation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type
								type="org.springframework.data.cassandra.core.ReactiveCassandraOperations"/>
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="write-options" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
					Reference to an instance of
					'org.springframework.data.cassandra.core.cql.WriteOptions'
				</xsd:documentation>
				<xsd:appinfo>
					<tool:annotation kind="ref">
						<tool:expected-type
								type="org.springframework.data.cassandra.core.cql.WriteOptions"/>
					</tool:annotation>
				</xsd:appinfo>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="mode" default="INSERT">
			<xsd:annotation>
				<xsd:documentation>
					<![CDATA[
					Indicates the `CassandraMessageHandler` behavior.
					Ignored in case of explicit 'query', 'ingest-query' or `statement-expression`.]]>
				</xsd:documentation>
			</xsd:annotation>
			<xsd:simpleType>
				<xsd:union memberTypes="cassandraHandlerType xsd:string"/>
			</xsd:simpleType>
		</xsd:attribute>
		<xsd:attribute name="ingest-query" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
					<![CDATA[Cql query to ingest data]]>
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="query" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
					Statement to use in prepared statement
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="statement-expression" type="xsd:string">
			<xsd:annotation>
				<xsd:documentation>
					Statement expression that represent an executable query
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="async">
			<xsd:annotation>
				<xsd:documentation>
					<![CDATA[
					Process returned 'Mono<WriteResult>' async, reactive manner on the downstream
					'FluxMessageChannel' subscription or via 'Mono.subscribe()' in the handler, if one-way.
					Otherwise the 'Mono.block()' is called immediately before returning from the handler.
					]]>
				</xsd:documentation>
			</xsd:annotation>
			<xsd:simpleType>
				<xsd:union memberTypes="xsd:boolean xsd:string" />
			</xsd:simpleType>
		</xsd:attribute>
	</xsd:complexType>

	<xsd:complexType name="queryParameterType">
		<xsd:annotation>
			<xsd:documentation>
				Expression to be evaluated against the Message to replace a query Parameter
			</xsd:documentation>
		</xsd:annotation>
		<xsd:attribute name="name" use="required">
			<xsd:annotation>
				<xsd:documentation>
					Name of the placeholder to be replaced
				</xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
		<xsd:attribute name="expression" use="required">
			<xsd:annotation>
				<xsd:documentation><![CDATA[
					Expression to be evaluated to determine the replacement value.
					The Message is the root object of the expression, therefore
					the 'payload' and 'headers' are available directly. Any bean
					may be resolved if the bean name is preceded with '@'.
				]]></xsd:documentation>
			</xsd:annotation>
		</xsd:attribute>
	</xsd:complexType>

	<xsd:simpleType name="cassandraHandlerType">
		<xsd:restriction base="xsd:token">
			<xsd:enumeration value="INSERT"/>
			<xsd:enumeration value="UPDATE"/>
			<xsd:enumeration value="DELETE"/>
			<xsd:enumeration value="STATEMENT"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:schema>
