#![doc = "Generated transport-independent contract objects."]
use std::collections::BTreeMap;
use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_json::Value;
use spiral_contract::error::{ErrorEnvelope, ServiceError};
use spiral_contract::strict::{DeserializeStrict, Strict};
use uuid::Uuid;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum AppAccessDecision {
Allow,
Block,
Unknown(String),
}
impl Serialize for AppAccessDecision {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(match self {
Self::Allow => "allow",
Self::Block => "block",
Self::Unknown(value) => value,
})
}
}
impl<'de> Deserialize<'de> for AppAccessDecision {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
Ok(match String::deserialize(deserializer)?.as_str() {
"allow" => Self::Allow,
"block" => Self::Block,
value => Self::Unknown(value.to_owned()),
})
}
}
impl<'de> DeserializeStrict<'de> for AppAccessDecision {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
enum __Known {
#[serde(rename = "allow")]
Allow,
#[serde(rename = "block")]
Block,
}
Ok(match __Known::deserialize(deserializer)? {
__Known::Allow => Self::Allow,
__Known::Block => Self::Block,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Application {
#[serde(rename = "configuration")]
pub configuration: ApplicationConfiguration,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
#[serde(rename = "projectId")]
pub project_id: String,
#[serde(rename = "status")]
pub status: ApplicationStatus,
}
impl<'de> DeserializeStrict<'de> for Application {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "configuration")]
configuration: Strict<ApplicationConfiguration>,
#[serde(rename = "id")]
id: Strict<String>,
#[serde(rename = "organizationId")]
organization_id: Strict<String>,
#[serde(rename = "projectId")]
project_id: Strict<String>,
#[serde(rename = "status")]
status: Strict<ApplicationStatus>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
configuration: wire.configuration.0,
id: wire.id.0,
organization_id: wire.organization_id.0,
project_id: wire.project_id.0,
status: wire.status.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ApplicationAudience {
Internal,
Public,
Unknown(String),
}
impl Serialize for ApplicationAudience {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(match self {
Self::Internal => "internal",
Self::Public => "public",
Self::Unknown(value) => value,
})
}
}
impl<'de> Deserialize<'de> for ApplicationAudience {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
Ok(match String::deserialize(deserializer)?.as_str() {
"internal" => Self::Internal,
"public" => Self::Public,
value => Self::Unknown(value.to_owned()),
})
}
}
impl<'de> DeserializeStrict<'de> for ApplicationAudience {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
enum __Known {
#[serde(rename = "internal")]
Internal,
#[serde(rename = "public")]
Public,
}
Ok(match __Known::deserialize(deserializer)? {
__Known::Internal => Self::Internal,
__Known::Public => Self::Public,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ApplicationConfiguration {
#[serde(rename = "allowedCorsOrigins")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub allowed_cors_origins: Option<Vec<String>>,
#[serde(rename = "audience")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub audience: Option<ApplicationAudience>,
#[serde(rename = "backgroundIdentity")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub background_identity: Option<BackgroundIdentity>,
#[serde(rename = "enabled")]
pub enabled: bool,
#[serde(rename = "installOnSignIn")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub install_on_sign_in: Option<bool>,
#[serde(rename = "jwks")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub jwks: Option<Value>,
#[serde(rename = "jwtBearerIssuers")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub jwt_bearer_issuers: Option<Vec<BackgroundIdentity>>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "redirectOnUpdate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub redirect_on_update: Option<bool>,
#[serde(rename = "redirectUris")]
pub redirect_uris: Vec<String>,
#[serde(rename = "scopes")]
pub scopes: Vec<String>,
#[serde(rename = "setupUrl")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setup_url: Option<String>,
}
impl<'de> DeserializeStrict<'de> for ApplicationConfiguration {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "allowedCorsOrigins")]
#[serde(default)]
allowed_cors_origins: Strict<Option<Vec<String>>>,
#[serde(rename = "audience")]
#[serde(default)]
audience: Strict<Option<ApplicationAudience>>,
#[serde(rename = "backgroundIdentity")]
#[serde(default)]
background_identity: Strict<Option<BackgroundIdentity>>,
#[serde(rename = "enabled")]
enabled: Strict<bool>,
#[serde(rename = "installOnSignIn")]
#[serde(default)]
install_on_sign_in: Strict<Option<bool>>,
#[serde(rename = "jwks")]
#[serde(default)]
jwks: Strict<Option<Value>>,
#[serde(rename = "jwtBearerIssuers")]
#[serde(default)]
jwt_bearer_issuers: Strict<Option<Vec<BackgroundIdentity>>>,
#[serde(rename = "name")]
name: Strict<String>,
#[serde(rename = "redirectOnUpdate")]
#[serde(default)]
redirect_on_update: Strict<Option<bool>>,
#[serde(rename = "redirectUris")]
redirect_uris: Strict<Vec<String>>,
#[serde(rename = "scopes")]
scopes: Strict<Vec<String>>,
#[serde(rename = "setupUrl")]
#[serde(default)]
setup_url: Strict<Option<String>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
allowed_cors_origins: wire.allowed_cors_origins.0,
audience: wire.audience.0,
background_identity: wire.background_identity.0,
enabled: wire.enabled.0,
install_on_sign_in: wire.install_on_sign_in.0,
jwks: wire.jwks.0,
jwt_bearer_issuers: wire.jwt_bearer_issuers.0,
name: wire.name.0,
redirect_on_update: wire.redirect_on_update.0,
redirect_uris: wire.redirect_uris.0,
scopes: wire.scopes.0,
setup_url: wire.setup_url.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ApplicationPage {
#[serde(rename = "applications")]
pub applications: Vec<Application>,
#[serde(rename = "nextPageToken")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub next_page_token: Option<String>,
}
impl<'de> DeserializeStrict<'de> for ApplicationPage {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "applications")]
applications: Strict<Vec<Application>>,
#[serde(rename = "nextPageToken")]
#[serde(default)]
next_page_token: Strict<Option<String>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
applications: wire.applications.0,
next_page_token: wire.next_page_token.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ApplicationScope {
#[serde(rename = "description")]
pub description: String,
#[serde(rename = "name")]
pub name: String,
}
impl<'de> DeserializeStrict<'de> for ApplicationScope {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "description")]
description: Strict<String>,
#[serde(rename = "name")]
name: Strict<String>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
description: wire.description.0,
name: wire.name.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ApplicationScopes {
#[serde(rename = "scopes")]
pub scopes: Vec<ApplicationScope>,
}
impl<'de> DeserializeStrict<'de> for ApplicationScopes {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "scopes")]
scopes: Strict<Vec<ApplicationScope>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
scopes: wire.scopes.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ApplicationStatus {
Active,
Suspended,
Deleted,
Unknown(String),
}
impl Serialize for ApplicationStatus {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(match self {
Self::Active => "active",
Self::Suspended => "suspended",
Self::Deleted => "deleted",
Self::Unknown(value) => value,
})
}
}
impl<'de> Deserialize<'de> for ApplicationStatus {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
Ok(match String::deserialize(deserializer)?.as_str() {
"active" => Self::Active,
"suspended" => Self::Suspended,
"deleted" => Self::Deleted,
value => Self::Unknown(value.to_owned()),
})
}
}
impl<'de> DeserializeStrict<'de> for ApplicationStatus {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
enum __Known {
#[serde(rename = "active")]
Active,
#[serde(rename = "suspended")]
Suspended,
#[serde(rename = "deleted")]
Deleted,
}
Ok(match __Known::deserialize(deserializer)? {
__Known::Active => Self::Active,
__Known::Suspended => Self::Suspended,
__Known::Deleted => Self::Deleted,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BackgroundIdentity {
#[serde(rename = "audience")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub audience: Option<String>,
#[serde(rename = "claims")]
pub claims: BTreeMap<String, String>,
#[serde(rename = "issuer")]
pub issuer: String,
}
impl<'de> DeserializeStrict<'de> for BackgroundIdentity {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "audience")]
#[serde(default)]
audience: Strict<Option<String>>,
#[serde(rename = "claims")]
claims: Strict<BTreeMap<String, String>>,
#[serde(rename = "issuer")]
issuer: Strict<String>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
audience: wire.audience.0,
claims: wire.claims.0,
issuer: wire.issuer.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ClientAppAccess {
#[serde(rename = "clientId")]
pub client_id: String,
#[serde(rename = "decision")]
pub decision: AppAccessDecision,
}
impl<'de> DeserializeStrict<'de> for ClientAppAccess {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "clientId")]
client_id: Strict<String>,
#[serde(rename = "decision")]
decision: Strict<AppAccessDecision>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
client_id: wire.client_id.0,
decision: wire.decision.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentClient {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "loopbackOnly")]
pub loopback_only: bool,
#[serde(rename = "managed")]
pub managed: bool,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "publisher")]
pub publisher: String,
#[serde(rename = "publisherName")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub publisher_name: Option<String>,
#[serde(rename = "redirectHost")]
pub redirect_host: String,
}
impl<'de> DeserializeStrict<'de> for ConsentClient {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "id")]
id: Strict<String>,
#[serde(rename = "loopbackOnly")]
loopback_only: Strict<bool>,
#[serde(rename = "managed")]
managed: Strict<bool>,
#[serde(rename = "name")]
name: Strict<String>,
#[serde(rename = "publisher")]
publisher: Strict<String>,
#[serde(rename = "publisherName")]
#[serde(default)]
publisher_name: Strict<Option<String>>,
#[serde(rename = "redirectHost")]
redirect_host: Strict<String>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
id: wire.id.0,
loopback_only: wire.loopback_only.0,
managed: wire.managed.0,
name: wire.name.0,
publisher: wire.publisher.0,
publisher_name: wire.publisher_name.0,
redirect_host: wire.redirect_host.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentDecision {
#[serde(rename = "approve")]
pub approve: bool,
#[serde(rename = "scopes")]
pub scopes: Vec<String>,
}
impl<'de> DeserializeStrict<'de> for ConsentDecision {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "approve")]
approve: Strict<bool>,
#[serde(rename = "scopes")]
scopes: Strict<Vec<String>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
approve: wire.approve.0,
scopes: wire.scopes.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentRedirect {
#[serde(rename = "redirectTo")]
pub redirect_to: String,
}
impl<'de> DeserializeStrict<'de> for ConsentRedirect {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "redirectTo")]
redirect_to: Strict<String>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
redirect_to: wire.redirect_to.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentRequest {
#[serde(rename = "client")]
pub client: ConsentClient,
#[serde(rename = "resource")]
pub resource: String,
#[serde(rename = "scopes")]
pub scopes: Vec<String>,
#[serde(rename = "skip")]
pub skip: bool,
#[serde(rename = "subject")]
pub subject: ConsentSubject,
}
impl<'de> DeserializeStrict<'de> for ConsentRequest {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "client")]
client: Strict<ConsentClient>,
#[serde(rename = "resource")]
resource: Strict<String>,
#[serde(rename = "scopes")]
scopes: Strict<Vec<String>>,
#[serde(rename = "skip")]
skip: Strict<bool>,
#[serde(rename = "subject")]
subject: Strict<ConsentSubject>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
client: wire.client.0,
resource: wire.resource.0,
scopes: wire.scopes.0,
skip: wire.skip.0,
subject: wire.subject.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConsentSubject {
#[serde(rename = "organizationId")]
pub organization_id: String,
#[serde(rename = "organizationName")]
pub organization_name: String,
#[serde(rename = "userId")]
pub user_id: String,
}
impl<'de> DeserializeStrict<'de> for ConsentSubject {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "organizationId")]
organization_id: Strict<String>,
#[serde(rename = "organizationName")]
organization_name: Strict<String>,
#[serde(rename = "userId")]
user_id: Strict<String>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
organization_id: wire.organization_id.0,
organization_name: wire.organization_name.0,
user_id: wire.user_id.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallableApplication {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "installOnSignIn")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub install_on_sign_in: Option<bool>,
#[serde(rename = "installation")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub installation: Option<Installation>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
#[serde(rename = "redirectOnUpdate")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub redirect_on_update: Option<bool>,
#[serde(rename = "scopes")]
pub scopes: Vec<String>,
#[serde(rename = "setupUrl")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub setup_url: Option<String>,
#[serde(rename = "status")]
pub status: ApplicationStatus,
}
impl<'de> DeserializeStrict<'de> for InstallableApplication {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "id")]
id: Strict<String>,
#[serde(rename = "installOnSignIn")]
#[serde(default)]
install_on_sign_in: Strict<Option<bool>>,
#[serde(rename = "installation")]
#[serde(default)]
installation: Strict<Option<Installation>>,
#[serde(rename = "name")]
name: Strict<String>,
#[serde(rename = "organizationId")]
organization_id: Strict<String>,
#[serde(rename = "redirectOnUpdate")]
#[serde(default)]
redirect_on_update: Strict<Option<bool>>,
#[serde(rename = "scopes")]
scopes: Strict<Vec<String>>,
#[serde(rename = "setupUrl")]
#[serde(default)]
setup_url: Strict<Option<String>>,
#[serde(rename = "status")]
status: Strict<ApplicationStatus>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
id: wire.id.0,
install_on_sign_in: wire.install_on_sign_in.0,
installation: wire.installation.0,
name: wire.name.0,
organization_id: wire.organization_id.0,
redirect_on_update: wire.redirect_on_update.0,
scopes: wire.scopes.0,
setup_url: wire.setup_url.0,
status: wire.status.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Installation {
#[serde(rename = "applicationId")]
pub application_id: String,
#[serde(rename = "approved")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub approved: Option<InstallationGrant>,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
#[serde(rename = "requested")]
pub requested: InstallationGrant,
#[serde(rename = "status")]
pub status: InstallationStatus,
}
impl<'de> DeserializeStrict<'de> for Installation {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "applicationId")]
application_id: Strict<String>,
#[serde(rename = "approved")]
#[serde(default)]
approved: Strict<Option<InstallationGrant>>,
#[serde(rename = "id")]
id: Strict<String>,
#[serde(rename = "organizationId")]
organization_id: Strict<String>,
#[serde(rename = "requested")]
requested: Strict<InstallationGrant>,
#[serde(rename = "status")]
status: Strict<InstallationStatus>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
application_id: wire.application_id.0,
approved: wire.approved.0,
id: wire.id.0,
organization_id: wire.organization_id.0,
requested: wire.requested.0,
status: wire.status.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationDetails {
#[serde(rename = "apiUrl")]
pub api_url: String,
#[serde(rename = "configurationUrl")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub configuration_url: Option<String>,
#[serde(rename = "installation")]
pub installation: Installation,
}
impl<'de> DeserializeStrict<'de> for InstallationDetails {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "apiUrl")]
api_url: Strict<String>,
#[serde(rename = "configurationUrl")]
#[serde(default)]
configuration_url: Strict<Option<String>>,
#[serde(rename = "installation")]
installation: Strict<Installation>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
api_url: wire.api_url.0,
configuration_url: wire.configuration_url.0,
installation: wire.installation.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationGrant {
#[serde(rename = "projects")]
pub projects: InstallationProjects,
#[serde(rename = "scopes")]
pub scopes: Vec<String>,
}
impl<'de> DeserializeStrict<'de> for InstallationGrant {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "projects")]
projects: Strict<InstallationProjects>,
#[serde(rename = "scopes")]
scopes: Strict<Vec<String>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
projects: wire.projects.0,
scopes: wire.scopes.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationPage {
#[serde(rename = "installations")]
pub installations: Vec<Installation>,
#[serde(rename = "nextPageToken")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub next_page_token: Option<String>,
}
impl<'de> DeserializeStrict<'de> for InstallationPage {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "installations")]
installations: Strict<Vec<Installation>>,
#[serde(rename = "nextPageToken")]
#[serde(default)]
next_page_token: Strict<Option<String>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
installations: wire.installations.0,
next_page_token: wire.next_page_token.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationProject {
#[serde(rename = "description")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
}
impl<'de> DeserializeStrict<'de> for InstallationProject {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "description")]
#[serde(default)]
description: Strict<Option<String>>,
#[serde(rename = "id")]
id: Strict<String>,
#[serde(rename = "organizationId")]
organization_id: Strict<String>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
description: wire.description.0,
id: wire.id.0,
organization_id: wire.organization_id.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationProjectPage {
#[serde(rename = "nextPageToken")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub next_page_token: Option<String>,
#[serde(rename = "projects")]
pub projects: Vec<InstallationProject>,
}
impl<'de> DeserializeStrict<'de> for InstallationProjectPage {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "nextPageToken")]
#[serde(default)]
next_page_token: Strict<Option<String>>,
#[serde(rename = "projects")]
projects: Strict<Vec<InstallationProject>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
next_page_token: wire.next_page_token.0,
projects: wire.projects.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationProjects {
#[serde(rename = "all")]
pub all: bool,
#[serde(rename = "projectIds")]
pub project_ids: Vec<String>,
}
impl<'de> DeserializeStrict<'de> for InstallationProjects {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "all")]
all: Strict<bool>,
#[serde(rename = "projectIds")]
project_ids: Strict<Vec<String>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
all: wire.all.0,
project_ids: wire.project_ids.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationRequest {
#[serde(rename = "applicationId")]
pub application_id: String,
#[serde(rename = "projects")]
pub projects: InstallationProjects,
#[serde(rename = "scopes")]
pub scopes: Vec<String>,
}
impl<'de> DeserializeStrict<'de> for InstallationRequest {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "applicationId")]
application_id: Strict<String>,
#[serde(rename = "projects")]
projects: Strict<InstallationProjects>,
#[serde(rename = "scopes")]
scopes: Strict<Vec<String>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
application_id: wire.application_id.0,
projects: wire.projects.0,
scopes: wire.scopes.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationReview {
#[serde(rename = "approve")]
pub approve: bool,
#[serde(rename = "requested")]
pub requested: InstallationGrant,
}
impl<'de> DeserializeStrict<'de> for InstallationReview {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "approve")]
approve: Strict<bool>,
#[serde(rename = "requested")]
requested: Strict<InstallationGrant>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
approve: wire.approve.0,
requested: wire.requested.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum InstallationStatus {
Requested,
Active,
Suspended,
Unknown(String),
}
impl Serialize for InstallationStatus {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(match self {
Self::Requested => "requested",
Self::Active => "active",
Self::Suspended => "suspended",
Self::Unknown(value) => value,
})
}
}
impl<'de> Deserialize<'de> for InstallationStatus {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
Ok(match String::deserialize(deserializer)?.as_str() {
"requested" => Self::Requested,
"active" => Self::Active,
"suspended" => Self::Suspended,
value => Self::Unknown(value.to_owned()),
})
}
}
impl<'de> DeserializeStrict<'de> for InstallationStatus {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
enum __Known {
#[serde(rename = "requested")]
Requested,
#[serde(rename = "active")]
Active,
#[serde(rename = "suspended")]
Suspended,
}
Ok(match __Known::deserialize(deserializer)? {
__Known::Requested => Self::Requested,
__Known::Active => Self::Active,
__Known::Suspended => Self::Suspended,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationStatusChange {
#[serde(rename = "enabled")]
pub enabled: bool,
}
impl<'de> DeserializeStrict<'de> for InstallationStatusChange {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "enabled")]
enabled: Strict<bool>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
enabled: wire.enabled.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstallationSummary {
#[serde(rename = "apiUrl")]
pub api_url: String,
#[serde(rename = "applicationId")]
pub application_id: String,
#[serde(rename = "approvedScopes")]
pub approved_scopes: Vec<String>,
#[serde(rename = "configurationUrl")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub configuration_url: Option<String>,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "organizationId")]
pub organization_id: String,
#[serde(rename = "requestedScopes")]
pub requested_scopes: Vec<String>,
#[serde(rename = "status")]
pub status: InstallationStatus,
}
impl<'de> DeserializeStrict<'de> for InstallationSummary {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "apiUrl")]
api_url: Strict<String>,
#[serde(rename = "applicationId")]
application_id: Strict<String>,
#[serde(rename = "approvedScopes")]
approved_scopes: Strict<Vec<String>>,
#[serde(rename = "configurationUrl")]
#[serde(default)]
configuration_url: Strict<Option<String>>,
#[serde(rename = "id")]
id: Strict<String>,
#[serde(rename = "organizationId")]
organization_id: Strict<String>,
#[serde(rename = "requestedScopes")]
requested_scopes: Strict<Vec<String>>,
#[serde(rename = "status")]
status: Strict<InstallationStatus>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
api_url: wire.api_url.0,
application_id: wire.application_id.0,
approved_scopes: wire.approved_scopes.0,
configuration_url: wire.configuration_url.0,
id: wire.id.0,
organization_id: wire.organization_id.0,
requested_scopes: wire.requested_scopes.0,
status: wire.status.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ListApplicationsRequest {
#[serde(rename = "pageSize")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub page_size: Option<u32>,
#[serde(rename = "pageToken")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub page_token: Option<String>,
}
impl<'de> DeserializeStrict<'de> for ListApplicationsRequest {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "pageSize")]
#[serde(default)]
page_size: Strict<Option<u32>>,
#[serde(rename = "pageToken")]
#[serde(default)]
page_token: Strict<Option<String>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
page_size: wire.page_size.0,
page_token: wire.page_token.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrganizationAppAccess {
#[serde(rename = "clients")]
pub clients: Vec<ClientAppAccess>,
#[serde(rename = "unlisted")]
pub unlisted: UnlistedAppAccess,
}
impl<'de> DeserializeStrict<'de> for OrganizationAppAccess {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "clients")]
clients: Strict<Vec<ClientAppAccess>>,
#[serde(rename = "unlisted")]
unlisted: Strict<UnlistedAppAccess>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
clients: wire.clients.0,
unlisted: wire.unlisted.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum UnlistedAppAccess {
AllowReviewed,
Block,
Unknown(String),
}
impl Serialize for UnlistedAppAccess {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(match self {
Self::AllowReviewed => "allow_reviewed",
Self::Block => "block",
Self::Unknown(value) => value,
})
}
}
impl<'de> Deserialize<'de> for UnlistedAppAccess {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
Ok(match String::deserialize(deserializer)?.as_str() {
"allow_reviewed" => Self::AllowReviewed,
"block" => Self::Block,
value => Self::Unknown(value.to_owned()),
})
}
}
impl<'de> DeserializeStrict<'de> for UnlistedAppAccess {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
enum __Known {
#[serde(rename = "allow_reviewed")]
AllowReviewed,
#[serde(rename = "block")]
Block,
}
Ok(match __Known::deserialize(deserializer)? {
__Known::AllowReviewed => Self::AllowReviewed,
__Known::Block => Self::Block,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct UserInstallation {
#[serde(rename = "installation")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub installation: Option<InstallationSummary>,
}
impl<'de> DeserializeStrict<'de> for UserInstallation {
fn deserialize_strict<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct __Wire {
#[serde(rename = "installation")]
#[serde(default)]
installation: Strict<Option<InstallationSummary>>,
}
let wire = __Wire::deserialize(deserializer)?;
Ok(Self {
installation: wire.installation.0,
})
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum AppsError {
Conflict { application_id: String },
ConsentConflict { reason: String },
InvalidArgument { reason: String },
InvalidConsent { reason: String },
NotFound { application_id: String },
RegistrationUnavailable { application_id: String },
}
impl AppsError {
pub fn status(&self) -> u16 {
match self {
Self::Conflict { .. } => 409,
Self::ConsentConflict { .. } => 409,
Self::InvalidArgument { .. } => 400,
Self::InvalidConsent { .. } => 400,
Self::NotFound { .. } => 404,
Self::RegistrationUnavailable { .. } => 500,
}
}
pub fn envelope(&self, instance: String) -> ErrorEnvelope {
match self {
Self::Conflict { application_id } => {
let mut envelope = ErrorEnvelope::new("CONFLICT", "Apps:Conflict", instance);
envelope
.parameters
.insert("applicationId".into(), application_id.to_string());
envelope
}
Self::ConsentConflict { reason } => {
let mut envelope = ErrorEnvelope::new("CONFLICT", "Apps:ConsentConflict", instance);
envelope
.parameters
.insert("reason".into(), reason.to_string());
envelope
}
Self::InvalidArgument { reason } => {
let mut envelope =
ErrorEnvelope::new("INVALID_ARGUMENT", "Apps:InvalidArgument", instance);
envelope
.parameters
.insert("reason".into(), reason.to_string());
envelope
}
Self::InvalidConsent { reason } => {
let mut envelope =
ErrorEnvelope::new("INVALID_ARGUMENT", "Apps:InvalidConsent", instance);
envelope
.parameters
.insert("reason".into(), reason.to_string());
envelope
}
Self::NotFound { application_id } => {
let mut envelope = ErrorEnvelope::new("NOT_FOUND", "Apps:NotFound", instance);
envelope
.parameters
.insert("applicationId".into(), application_id.to_string());
envelope
}
Self::RegistrationUnavailable { application_id } => {
let mut envelope =
ErrorEnvelope::new("INTERNAL", "Apps:RegistrationUnavailable", instance);
envelope
.parameters
.insert("applicationId".into(), application_id.to_string());
envelope
}
}
}
pub fn decode_envelope(envelope: &ErrorEnvelope) -> Option<Self> {
if envelope.error_instance_id.len() != 36
|| Uuid::parse_str(&envelope.error_instance_id).is_err()
{
return None;
}
match envelope.error_name.as_str() {
"Apps:Conflict" => {
if envelope.error_code != "CONFLICT" {
return None;
}
let application_id = envelope.parameters.get("applicationId")?.clone();
Some(Self::Conflict { application_id })
}
"Apps:ConsentConflict" => {
if envelope.error_code != "CONFLICT" {
return None;
}
let reason = envelope.parameters.get("reason")?.clone();
Some(Self::ConsentConflict { reason })
}
"Apps:InvalidArgument" => {
if envelope.error_code != "INVALID_ARGUMENT" {
return None;
}
let reason = envelope.parameters.get("reason")?.clone();
Some(Self::InvalidArgument { reason })
}
"Apps:InvalidConsent" => {
if envelope.error_code != "INVALID_ARGUMENT" {
return None;
}
let reason = envelope.parameters.get("reason")?.clone();
Some(Self::InvalidConsent { reason })
}
"Apps:NotFound" => {
if envelope.error_code != "NOT_FOUND" {
return None;
}
let application_id = envelope.parameters.get("applicationId")?.clone();
Some(Self::NotFound { application_id })
}
"Apps:RegistrationUnavailable" => {
if envelope.error_code != "INTERNAL" {
return None;
}
let application_id = envelope.parameters.get("applicationId")?.clone();
Some(Self::RegistrationUnavailable { application_id })
}
_ => None,
}
}
}
impl Display for AppsError {
fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::Conflict { application_id } => write!(
formatter,
"Apps:Conflict (applicationId: {})",
application_id
),
Self::ConsentConflict { reason } => {
write!(formatter, "Apps:ConsentConflict (reason: {})", reason)
}
Self::InvalidArgument { reason } => {
write!(formatter, "Apps:InvalidArgument (reason: {})", reason)
}
Self::InvalidConsent { reason } => {
write!(formatter, "Apps:InvalidConsent (reason: {})", reason)
}
Self::NotFound { application_id } => write!(
formatter,
"Apps:NotFound (applicationId: {})",
application_id
),
Self::RegistrationUnavailable { application_id } => write!(
formatter,
"Apps:RegistrationUnavailable (applicationId: {})",
application_id
),
}
}
}
impl StdError for AppsError {}
impl ServiceError for AppsError {
fn to_envelope(&self, instance: String) -> ErrorEnvelope {
Self::envelope(self, instance)
}
fn from_envelope(envelope: &ErrorEnvelope) -> Option<Self> {
Self::decode_envelope(envelope)
}
}
#[automatically_derived]
impl Default for ListApplicationsRequest {
fn default() -> Self {
Self {
page_size: None,
page_token: None,
}
}
}