use pact_models::prelude::OptionalBody;
use pact_models::content_types::ContentTypeHint;
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InitPluginRequest {
#[prost(string, tag = "1")]
pub implementation: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub version: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CatalogueEntry {
#[prost(enumeration = "catalogue_entry::EntryType", tag = "1")]
pub r#type: i32,
#[prost(string, tag = "2")]
pub key: ::prost::alloc::string::String,
#[prost(map = "string, string", tag = "3")]
pub values: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
pub mod catalogue_entry {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum EntryType {
ContentMatcher = 0,
ContentGenerator = 1,
Transport = 2,
Matcher = 3,
Interaction = 4,
}
impl EntryType {
pub fn as_str_name(&self) -> &'static str {
match self {
EntryType::ContentMatcher => "CONTENT_MATCHER",
EntryType::ContentGenerator => "CONTENT_GENERATOR",
EntryType::Transport => "TRANSPORT",
EntryType::Matcher => "MATCHER",
EntryType::Interaction => "INTERACTION",
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InitPluginResponse {
#[prost(message, repeated, tag = "1")]
pub catalogue: ::prost::alloc::vec::Vec<CatalogueEntry>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Catalogue {
#[prost(message, repeated, tag = "1")]
pub catalogue: ::prost::alloc::vec::Vec<CatalogueEntry>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Body {
#[prost(string, tag = "1")]
pub content_type: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub content: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
#[prost(enumeration = "body::ContentTypeHint", tag = "3")]
pub content_type_hint: i32,
}
pub mod body {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum ContentTypeHint {
Default = 0,
Text = 1,
Binary = 2,
}
impl ContentTypeHint {
pub fn as_str_name(&self) -> &'static str {
match self {
ContentTypeHint::Default => "DEFAULT",
ContentTypeHint::Text => "TEXT",
ContentTypeHint::Binary => "BINARY",
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompareContentsRequest {
#[prost(message, optional, tag = "1")]
pub expected: ::core::option::Option<Body>,
#[prost(message, optional, tag = "2")]
pub actual: ::core::option::Option<Body>,
#[prost(bool, tag = "3")]
pub allow_unexpected_keys: bool,
#[prost(map = "string, message", tag = "4")]
pub rules: ::std::collections::HashMap<
::prost::alloc::string::String,
MatchingRules,
>,
#[prost(message, optional, tag = "5")]
pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ContentTypeMismatch {
#[prost(string, tag = "1")]
pub expected: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub actual: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ContentMismatch {
#[prost(message, optional, tag = "1")]
pub expected: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
#[prost(message, optional, tag = "2")]
pub actual: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
#[prost(string, tag = "3")]
pub mismatch: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub path: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub diff: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ContentMismatches {
#[prost(message, repeated, tag = "1")]
pub mismatches: ::prost::alloc::vec::Vec<ContentMismatch>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompareContentsResponse {
#[prost(string, tag = "1")]
pub error: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub type_mismatch: ::core::option::Option<ContentTypeMismatch>,
#[prost(map = "string, message", tag = "3")]
pub results: ::std::collections::HashMap<
::prost::alloc::string::String,
ContentMismatches,
>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConfigureInteractionRequest {
#[prost(string, tag = "1")]
pub content_type: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub contents_config: ::core::option::Option<::prost_types::Struct>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MatchingRule {
#[prost(string, tag = "1")]
pub r#type: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub values: ::core::option::Option<::prost_types::Struct>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MatchingRules {
#[prost(message, repeated, tag = "1")]
pub rule: ::prost::alloc::vec::Vec<MatchingRule>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Generator {
#[prost(string, tag = "1")]
pub r#type: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub values: ::core::option::Option<::prost_types::Struct>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PluginConfiguration {
#[prost(message, optional, tag = "1")]
pub interaction_configuration: ::core::option::Option<::prost_types::Struct>,
#[prost(message, optional, tag = "2")]
pub pact_configuration: ::core::option::Option<::prost_types::Struct>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InteractionResponse {
#[prost(message, optional, tag = "1")]
pub contents: ::core::option::Option<Body>,
#[prost(map = "string, message", tag = "2")]
pub rules: ::std::collections::HashMap<
::prost::alloc::string::String,
MatchingRules,
>,
#[prost(map = "string, message", tag = "3")]
pub generators: ::std::collections::HashMap<
::prost::alloc::string::String,
Generator,
>,
#[prost(message, optional, tag = "4")]
pub message_metadata: ::core::option::Option<::prost_types::Struct>,
#[prost(message, optional, tag = "5")]
pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
#[prost(string, tag = "6")]
pub interaction_markup: ::prost::alloc::string::String,
#[prost(enumeration = "interaction_response::MarkupType", tag = "7")]
pub interaction_markup_type: i32,
#[prost(string, tag = "8")]
pub part_name: ::prost::alloc::string::String,
}
pub mod interaction_response {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum MarkupType {
CommonMark = 0,
Html = 1,
}
impl MarkupType {
pub fn as_str_name(&self) -> &'static str {
match self {
MarkupType::CommonMark => "COMMON_MARK",
MarkupType::Html => "HTML",
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConfigureInteractionResponse {
#[prost(string, tag = "1")]
pub error: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
pub interaction: ::prost::alloc::vec::Vec<InteractionResponse>,
#[prost(message, optional, tag = "3")]
pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateContentRequest {
#[prost(message, optional, tag = "1")]
pub contents: ::core::option::Option<Body>,
#[prost(map = "string, message", tag = "2")]
pub generators: ::std::collections::HashMap<
::prost::alloc::string::String,
Generator,
>,
#[prost(message, optional, tag = "3")]
pub plugin_configuration: ::core::option::Option<PluginConfiguration>,
#[prost(message, optional, tag = "4")]
pub test_context: ::core::option::Option<::prost_types::Struct>,
#[prost(enumeration = "generate_content_request::TestMode", tag = "5")]
pub test_mode: i32,
#[prost(enumeration = "generate_content_request::ContentFor", tag = "6")]
pub content_for: i32,
}
pub mod generate_content_request {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum TestMode {
Unknown = 0,
Consumer = 1,
Provider = 2,
}
impl TestMode {
pub fn as_str_name(&self) -> &'static str {
match self {
TestMode::Unknown => "Unknown",
TestMode::Consumer => "Consumer",
TestMode::Provider => "Provider",
}
}
}
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum ContentFor {
Request = 0,
Response = 1,
}
impl ContentFor {
pub fn as_str_name(&self) -> &'static str {
match self {
ContentFor::Request => "Request",
ContentFor::Response => "Response",
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateContentResponse {
#[prost(message, optional, tag = "1")]
pub contents: ::core::option::Option<Body>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StartMockServerRequest {
#[prost(string, tag = "1")]
pub host_interface: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub port: u32,
#[prost(bool, tag = "3")]
pub tls: bool,
#[prost(string, tag = "4")]
pub pact: ::prost::alloc::string::String,
#[prost(message, optional, tag = "5")]
pub test_context: ::core::option::Option<::prost_types::Struct>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StartMockServerResponse {
#[prost(oneof = "start_mock_server_response::Response", tags = "1, 2")]
pub response: ::core::option::Option<start_mock_server_response::Response>,
}
pub mod start_mock_server_response {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(string, tag = "1")]
Error(::prost::alloc::string::String),
#[prost(message, tag = "2")]
Details(super::MockServerDetails),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MockServerDetails {
#[prost(string, tag = "1")]
pub key: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub port: u32,
#[prost(string, tag = "3")]
pub address: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ShutdownMockServerRequest {
#[prost(string, tag = "1")]
pub server_key: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MockServerRequest {
#[prost(string, tag = "1")]
pub server_key: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MockServerResult {
#[prost(string, tag = "1")]
pub path: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub error: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub mismatches: ::prost::alloc::vec::Vec<ContentMismatch>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ShutdownMockServerResponse {
#[prost(bool, tag = "1")]
pub ok: bool,
#[prost(message, repeated, tag = "2")]
pub results: ::prost::alloc::vec::Vec<MockServerResult>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MockServerResults {
#[prost(bool, tag = "1")]
pub ok: bool,
#[prost(message, repeated, tag = "2")]
pub results: ::prost::alloc::vec::Vec<MockServerResult>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerificationPreparationRequest {
#[prost(string, tag = "1")]
pub pact: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub interaction_key: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub config: ::core::option::Option<::prost_types::Struct>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MetadataValue {
#[prost(oneof = "metadata_value::Value", tags = "1, 2")]
pub value: ::core::option::Option<metadata_value::Value>,
}
pub mod metadata_value {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
#[prost(message, tag = "1")]
NonBinaryValue(::prost_types::Value),
#[prost(bytes, tag = "2")]
BinaryValue(::prost::alloc::vec::Vec<u8>),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InteractionData {
#[prost(message, optional, tag = "1")]
pub body: ::core::option::Option<Body>,
#[prost(map = "string, message", tag = "2")]
pub metadata: ::std::collections::HashMap<
::prost::alloc::string::String,
MetadataValue,
>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerificationPreparationResponse {
#[prost(oneof = "verification_preparation_response::Response", tags = "1, 2")]
pub response: ::core::option::Option<verification_preparation_response::Response>,
}
pub mod verification_preparation_response {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(string, tag = "1")]
Error(::prost::alloc::string::String),
#[prost(message, tag = "2")]
InteractionData(super::InteractionData),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerifyInteractionRequest {
#[prost(message, optional, tag = "1")]
pub interaction_data: ::core::option::Option<InteractionData>,
#[prost(message, optional, tag = "2")]
pub config: ::core::option::Option<::prost_types::Struct>,
#[prost(string, tag = "3")]
pub pact: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub interaction_key: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerificationResultItem {
#[prost(oneof = "verification_result_item::Result", tags = "1, 2")]
pub result: ::core::option::Option<verification_result_item::Result>,
}
pub mod verification_result_item {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Result {
#[prost(string, tag = "1")]
Error(::prost::alloc::string::String),
#[prost(message, tag = "2")]
Mismatch(super::ContentMismatch),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerificationResult {
#[prost(bool, tag = "1")]
pub success: bool,
#[prost(message, optional, tag = "2")]
pub response_data: ::core::option::Option<InteractionData>,
#[prost(message, repeated, tag = "3")]
pub mismatches: ::prost::alloc::vec::Vec<VerificationResultItem>,
#[prost(string, repeated, tag = "4")]
pub output: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerifyInteractionResponse {
#[prost(oneof = "verify_interaction_response::Response", tags = "1, 2")]
pub response: ::core::option::Option<verify_interaction_response::Response>,
}
pub mod verify_interaction_response {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(string, tag = "1")]
Error(::prost::alloc::string::String),
#[prost(message, tag = "2")]
Result(super::VerificationResult),
}
}
pub mod pact_plugin_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct PactPluginClient<T> {
inner: tonic::client::Grpc<T>,
}
impl PactPluginClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> PactPluginClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> PactPluginClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
PactPluginClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
pub async fn init_plugin(
&mut self,
request: impl tonic::IntoRequest<super::InitPluginRequest>,
) -> Result<tonic::Response<super::InitPluginResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/InitPlugin",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn update_catalogue(
&mut self,
request: impl tonic::IntoRequest<super::Catalogue>,
) -> Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/UpdateCatalogue",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn compare_contents(
&mut self,
request: impl tonic::IntoRequest<super::CompareContentsRequest>,
) -> Result<tonic::Response<super::CompareContentsResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/CompareContents",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn configure_interaction(
&mut self,
request: impl tonic::IntoRequest<super::ConfigureInteractionRequest>,
) -> Result<
tonic::Response<super::ConfigureInteractionResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/ConfigureInteraction",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn generate_content(
&mut self,
request: impl tonic::IntoRequest<super::GenerateContentRequest>,
) -> Result<tonic::Response<super::GenerateContentResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/GenerateContent",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn start_mock_server(
&mut self,
request: impl tonic::IntoRequest<super::StartMockServerRequest>,
) -> Result<tonic::Response<super::StartMockServerResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/StartMockServer",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn shutdown_mock_server(
&mut self,
request: impl tonic::IntoRequest<super::ShutdownMockServerRequest>,
) -> Result<tonic::Response<super::ShutdownMockServerResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/ShutdownMockServer",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn get_mock_server_results(
&mut self,
request: impl tonic::IntoRequest<super::MockServerRequest>,
) -> Result<tonic::Response<super::MockServerResults>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/GetMockServerResults",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn prepare_interaction_for_verification(
&mut self,
request: impl tonic::IntoRequest<super::VerificationPreparationRequest>,
) -> Result<
tonic::Response<super::VerificationPreparationResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/PrepareInteractionForVerification",
);
self.inner.unary(request.into_request(), path, codec).await
}
pub async fn verify_interaction(
&mut self,
request: impl tonic::IntoRequest<super::VerifyInteractionRequest>,
) -> Result<tonic::Response<super::VerifyInteractionResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/io.pact.plugin.PactPlugin/VerifyInteraction",
);
self.inner.unary(request.into_request(), path, codec).await
}
}
}
pub mod pact_plugin_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait PactPlugin: Send + Sync + 'static {
async fn init_plugin(
&self,
request: tonic::Request<super::InitPluginRequest>,
) -> Result<tonic::Response<super::InitPluginResponse>, tonic::Status>;
async fn update_catalogue(
&self,
request: tonic::Request<super::Catalogue>,
) -> Result<tonic::Response<()>, tonic::Status>;
async fn compare_contents(
&self,
request: tonic::Request<super::CompareContentsRequest>,
) -> Result<tonic::Response<super::CompareContentsResponse>, tonic::Status>;
async fn configure_interaction(
&self,
request: tonic::Request<super::ConfigureInteractionRequest>,
) -> Result<tonic::Response<super::ConfigureInteractionResponse>, tonic::Status>;
async fn generate_content(
&self,
request: tonic::Request<super::GenerateContentRequest>,
) -> Result<tonic::Response<super::GenerateContentResponse>, tonic::Status>;
async fn start_mock_server(
&self,
request: tonic::Request<super::StartMockServerRequest>,
) -> Result<tonic::Response<super::StartMockServerResponse>, tonic::Status>;
async fn shutdown_mock_server(
&self,
request: tonic::Request<super::ShutdownMockServerRequest>,
) -> Result<tonic::Response<super::ShutdownMockServerResponse>, tonic::Status>;
async fn get_mock_server_results(
&self,
request: tonic::Request<super::MockServerRequest>,
) -> Result<tonic::Response<super::MockServerResults>, tonic::Status>;
async fn prepare_interaction_for_verification(
&self,
request: tonic::Request<super::VerificationPreparationRequest>,
) -> Result<
tonic::Response<super::VerificationPreparationResponse>,
tonic::Status,
>;
async fn verify_interaction(
&self,
request: tonic::Request<super::VerifyInteractionRequest>,
) -> Result<tonic::Response<super::VerifyInteractionResponse>, tonic::Status>;
}
#[derive(Debug)]
pub struct PactPluginServer<T: PactPlugin> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
}
struct _Inner<T>(Arc<T>);
impl<T: PactPlugin> PactPluginServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for PactPluginServer<T>
where
T: PactPlugin,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/io.pact.plugin.PactPlugin/InitPlugin" => {
#[allow(non_camel_case_types)]
struct InitPluginSvc<T: PactPlugin>(pub Arc<T>);
impl<
T: PactPlugin,
> tonic::server::UnaryService<super::InitPluginRequest>
for InitPluginSvc<T> {
type Response = super::InitPluginResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::InitPluginRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).init_plugin(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = InitPluginSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.pact.plugin.PactPlugin/UpdateCatalogue" => {
#[allow(non_camel_case_types)]
struct UpdateCatalogueSvc<T: PactPlugin>(pub Arc<T>);
impl<T: PactPlugin> tonic::server::UnaryService<super::Catalogue>
for UpdateCatalogueSvc<T> {
type Response = ();
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::Catalogue>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).update_catalogue(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = UpdateCatalogueSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.pact.plugin.PactPlugin/CompareContents" => {
#[allow(non_camel_case_types)]
struct CompareContentsSvc<T: PactPlugin>(pub Arc<T>);
impl<
T: PactPlugin,
> tonic::server::UnaryService<super::CompareContentsRequest>
for CompareContentsSvc<T> {
type Response = super::CompareContentsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CompareContentsRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).compare_contents(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = CompareContentsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.pact.plugin.PactPlugin/ConfigureInteraction" => {
#[allow(non_camel_case_types)]
struct ConfigureInteractionSvc<T: PactPlugin>(pub Arc<T>);
impl<
T: PactPlugin,
> tonic::server::UnaryService<super::ConfigureInteractionRequest>
for ConfigureInteractionSvc<T> {
type Response = super::ConfigureInteractionResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ConfigureInteractionRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).configure_interaction(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ConfigureInteractionSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.pact.plugin.PactPlugin/GenerateContent" => {
#[allow(non_camel_case_types)]
struct GenerateContentSvc<T: PactPlugin>(pub Arc<T>);
impl<
T: PactPlugin,
> tonic::server::UnaryService<super::GenerateContentRequest>
for GenerateContentSvc<T> {
type Response = super::GenerateContentResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GenerateContentRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).generate_content(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = GenerateContentSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.pact.plugin.PactPlugin/StartMockServer" => {
#[allow(non_camel_case_types)]
struct StartMockServerSvc<T: PactPlugin>(pub Arc<T>);
impl<
T: PactPlugin,
> tonic::server::UnaryService<super::StartMockServerRequest>
for StartMockServerSvc<T> {
type Response = super::StartMockServerResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::StartMockServerRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).start_mock_server(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = StartMockServerSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.pact.plugin.PactPlugin/ShutdownMockServer" => {
#[allow(non_camel_case_types)]
struct ShutdownMockServerSvc<T: PactPlugin>(pub Arc<T>);
impl<
T: PactPlugin,
> tonic::server::UnaryService<super::ShutdownMockServerRequest>
for ShutdownMockServerSvc<T> {
type Response = super::ShutdownMockServerResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::ShutdownMockServerRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).shutdown_mock_server(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ShutdownMockServerSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.pact.plugin.PactPlugin/GetMockServerResults" => {
#[allow(non_camel_case_types)]
struct GetMockServerResultsSvc<T: PactPlugin>(pub Arc<T>);
impl<
T: PactPlugin,
> tonic::server::UnaryService<super::MockServerRequest>
for GetMockServerResultsSvc<T> {
type Response = super::MockServerResults;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::MockServerRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).get_mock_server_results(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = GetMockServerResultsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.pact.plugin.PactPlugin/PrepareInteractionForVerification" => {
#[allow(non_camel_case_types)]
struct PrepareInteractionForVerificationSvc<T: PactPlugin>(
pub Arc<T>,
);
impl<
T: PactPlugin,
> tonic::server::UnaryService<super::VerificationPreparationRequest>
for PrepareInteractionForVerificationSvc<T> {
type Response = super::VerificationPreparationResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
super::VerificationPreparationRequest,
>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).prepare_interaction_for_verification(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = PrepareInteractionForVerificationSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/io.pact.plugin.PactPlugin/VerifyInteraction" => {
#[allow(non_camel_case_types)]
struct VerifyInteractionSvc<T: PactPlugin>(pub Arc<T>);
impl<
T: PactPlugin,
> tonic::server::UnaryService<super::VerifyInteractionRequest>
for VerifyInteractionSvc<T> {
type Response = super::VerifyInteractionResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::VerifyInteractionRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move {
(*inner).verify_interaction(request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = VerifyInteractionSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: PactPlugin> Clone for PactPluginServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
}
}
}
impl<T: PactPlugin> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: PactPlugin> tonic::server::NamedService for PactPluginServer<T> {
const NAME: &'static str = "io.pact.plugin.PactPlugin";
}
}
impl From<&OptionalBody> for Body {
fn from(body: &OptionalBody) -> Self {
match body {
OptionalBody::Present(bytes, ct, ct_hint) => Body {
content_type: ct.as_ref().map(|ct| ct.to_string()).unwrap_or_default(),
content: Some(bytes.to_vec()),
content_type_hint: match ct_hint {
Some(ct_hint) => match ct_hint {
ContentTypeHint::BINARY => body::ContentTypeHint::Binary as i32,
ContentTypeHint::TEXT => body::ContentTypeHint::Text as i32,
ContentTypeHint::DEFAULT => body::ContentTypeHint::Default as i32
}
None => body::ContentTypeHint::Default as i32
}
},
_ => Body {
content_type: "".to_string(),
content: None,
content_type_hint: body::ContentTypeHint::Default as i32
}
}
}
}