1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use crate::Schema;
/// Map describing protocol-specific definitions for an operation.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct OperationBinding {
/// Protocol-specific information for an HTTP operation
#[serde(skip_serializing_if = "Option::is_none")]
pub http: Option<HTTPOperationBinding>,
/// Protocol-specific information for a WebSockets operation
#[serde(skip_serializing_if = "Option::is_none")]
pub ws: Option<WebSocketsOperationBinding>,
/// Protocol-specific information for a Kafka operation
#[serde(skip_serializing_if = "Option::is_none")]
pub kafka: Option<KafkaOperationBinding>,
/// Protocol-specific information for an Anypoint MQ operation.
#[serde(skip_serializing_if = "Option::is_none")]
pub anypointmq: Option<AnyPointMQOperationBinding>,
/// Protocol-specific information for an AMPQ operation
#[serde(skip_serializing_if = "Option::is_none")]
pub amqp: Option<AMQPOperationBinding>,
/// Protocol-specific information for an AMQP 1.0 operation
#[serde(skip_serializing_if = "Option::is_none")]
pub amqp1: Option<AMQP1OperationBinding>,
/// Protocol-specific information for an MQTT operation
#[serde(skip_serializing_if = "Option::is_none")]
pub mqtt: Option<MQTTOperationBinding>,
/// Protocol-specific information for an MQTT 5 operation
#[serde(skip_serializing_if = "Option::is_none")]
pub mqtt5: Option<MQTT5OperationBinding>,
/// Protocol-specific information for a NATS operation
#[serde(skip_serializing_if = "Option::is_none")]
pub nats: Option<NATSOperationBinding>,
/// Protocol-specific information for a JMS operation
#[serde(skip_serializing_if = "Option::is_none")]
pub jms: Option<JMSOperationBinding>,
/// Protocol-specific information for an SNS operation
#[serde(skip_serializing_if = "Option::is_none")]
pub sns: Option<SNSOperationBinding>,
/// Protocol-specific information for an SQS operation
#[serde(skip_serializing_if = "Option::is_none")]
pub sqs: Option<SQSOperationBinding>,
/// Protocol-specific information for a STOMP operation
#[serde(skip_serializing_if = "Option::is_none")]
pub stomp: Option<STOMPOperationBinding>,
/// Protocol-specific information for a Redis operation
#[serde(skip_serializing_if = "Option::is_none")]
pub redis: Option<RedisOperationBinding>,
/// Protocol-specific information for a Mercure operation
#[serde(skip_serializing_if = "Option::is_none")]
pub mercure: Option<MercureOperationBinding>,
/// This object can be extended with
/// [Specification Extensions](https://www.asyncapi.com/docs/specifications/v2.1.0#specificationExtensions).
#[serde(flatten)]
pub extensions: IndexMap<String, serde_json::Value>,
}
///
///
/// # Examples
/// ```yaml
/// channels:
/// /employees:
/// subscribe:
/// bindings:
/// http:
/// type: request
/// method: GET
/// query:
/// type: object
/// required:
/// - companyId
/// properties:
/// companyId:
/// type: number
/// minimum: 1
/// description: The Id of the company.
/// additionalProperties: false
/// bindingVersion: '0.1.0'
/// ```
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct HTTPOperationBinding {
/// Required. Type of operation. Its value MUST be either `request` or `response`.
#[serde(rename = "type")]
pub typ: String,
/// When `type` is `request`, this is the HTTP method, otherwise it MUST be ignored.
/// Its value MUST be one of `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`,
/// `OPTIONS`, `CONNECT`, and `TRACE`.
#[serde(skip_serializing_if = "Option::is_none")]
pub method: Option<String>,
/// A Schema object containing the definitions for each query parameter.
/// This schema MUST be of type `object` and have a `properties` key.
#[serde(skip_serializing_if = "Option::is_none")]
pub query: Option<Schema>,
/// The version of this binding. If omitted, "latest" MUST be assumed.
#[serde(skip_serializing_if = "Option::is_none")]
pub binding_version: Option<String>,
}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct WebSocketsOperationBinding {}
/// This object contains information about the operation representation in Kafka.
///
/// # Examples
///
/// ```yaml
/// channels:
/// user-signedup:
/// publish:
/// bindings:
/// kafka:
/// groupId:
/// type: string
/// enum: ['myGroupId']
/// clientId:
/// type: string
/// enum: ['myClientId']
/// bindingVersion: '0.1.0'
/// ```
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct KafkaOperationBinding {
/// Id of the consumer group.
#[serde(skip_serializing_if = "Option::is_none")]
pub group_id: Option<Schema>,
/// Id of the consumer inside a consumer group.
#[serde(skip_serializing_if = "Option::is_none")]
pub client_id: Option<String>, // TODO spec says "Schema Object" but examples are different
/// The version of this binding. If omitted, "latest" MUST be assumed.
#[serde(skip_serializing_if = "Option::is_none")]
pub binding_version: Option<String>,
}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct AnyPointMQOperationBinding {}
/// This object contains information about the operation representation in AMQP.
///
/// # Examples
///
/// ```yaml
/// channels:
/// user/signup:
/// publish:
/// bindings:
/// amqp:
/// expiration: 100000
/// userId: guest
/// cc: ['user.logs']
/// priority: 10
/// deliveryMode: 2
/// mandatory: false
/// bcc: ['external.audit']
/// replyTo: user.signedup
/// timestamp: true
/// ack: false
/// bindingVersion: 0.2.0
/// ```
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct AMQPOperationBinding {
/// TTL (Time-To-Live) for the message. It MUST be greater than or equal to zero.
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration: Option<i32>,
/// Identifies the user who has sent the message.
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
/// The routing keys the message should be routed to at the time of publishing.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub cc: Vec<String>,
/// A priority for the message.
#[serde(skip_serializing_if = "Option::is_none")]
pub priority: Option<i32>,
/// Delivery mode of the message. Its value MUST be either 1 (transient) or 2 (persistent).
#[serde(skip_serializing_if = "Option::is_none")]
pub delivery_mode: Option<i32>,
/// Whether the message is mandatory or not.
#[serde(skip_serializing_if = "Option::is_none")]
pub mandatory: Option<bool>,
/// Like [cc](https://github.com/asyncapi/bindings/blob/master/amqp/README.md#operationBindingObjectCC) but consumers will not receive this information.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub bcc: Vec<String>,
/// Name of the queue where the consumer should send the response.
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_to: Option<String>,
/// Whether the message should include a timestamp or not.
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<bool>,
/// Whether the consumer should ack the message or not.
#[serde(skip_serializing_if = "Option::is_none")]
pub ack: Option<bool>,
/// The version of this binding. If omitted, "latest" MUST be assumed.
#[serde(skip_serializing_if = "Option::is_none")]
pub binding_version: Option<String>,
}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct AMQP1OperationBinding {}
/// This object contains information about the operation representation in MQTT.
///
/// # Examples
///
/// ```yaml
/// channels:
/// user/signup:
/// publish:
/// bindings:
/// mqtt:
/// qos: 2
/// retain: true
/// bindingVersion: 0.1.0
/// ```
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct MQTTOperationBinding {
/// Defines the Quality of Service (QoS) levels for the message flow between client
/// and server. Its value MUST be either 0 (At most once delivery),
/// 1 (At least once delivery), or 2 (Exactly once delivery).
#[serde(skip_serializing_if = "Option::is_none")]
pub qos: Option<i32>,
/// Whether the broker should retain the message or not.
#[serde(skip_serializing_if = "Option::is_none")]
pub retain: Option<bool>,
/// The version of this binding. If omitted, "latest" MUST be assumed.
#[serde(skip_serializing_if = "Option::is_none")]
pub binding_version: Option<String>,
}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct MQTT5OperationBinding {}
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct NATSOperationBinding {
/// Defines the name of the queue to use. It MUST NOT exceed 255 characters.
#[serde(skip_serializing_if = "Option::is_none")]
pub queue: Option<String>,
/// The version of this binding. If omitted, "latest" MUST be assumed.
#[serde(skip_serializing_if = "Option::is_none")]
pub binding_version: Option<String>,
}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct JMSOperationBinding {}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct SNSOperationBinding {}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct SQSOperationBinding {}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct STOMPOperationBinding {}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct RedisOperationBinding {}
/// This object MUST NOT contain any properties. Its name is reserved for future use.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct MercureOperationBinding {}