// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!

use crate::b2b::organizations_members::Members;
use crate::b2b::scim::SCIMAttributes;
use percent_encoding;
use serde::{Deserialize, Serialize};
use serde_urlencoded;

/// ActiveSCIMConnection:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ActiveSCIMConnection {
    /// connection_id: The ID of the SCIM connection.
    pub connection_id: String,
    /// display_name: A human-readable display name for the connection.
    pub display_name: String,
    pub bearer_token_last_four: String,
    pub bearer_token_expires_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
}
/// ActiveSSOConnection:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ActiveSSOConnection {
    /// connection_id: Globally unique UUID that identifies a specific SSO `connection_id` for a Member.
    pub connection_id: String,
    /// display_name: A human-readable display name for the connection.
    pub display_name: String,
    pub identity_provider: String,
}
/// EmailImplicitRoleAssignment:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EmailImplicitRoleAssignment {
    /// domain: Email domain that grants the specified Role.
    pub domain: String,
    /// role_id: The unique identifier of the RBAC Role, provided by the developer and intended to be
    /// human-readable.
    ///
    ///   Reserved `role_id`s that are predefined by Stytch include:
    ///
    ///   * `stytch_member`
    ///   * `stytch_admin`
    ///
    ///   Check out the [guide on Stytch default Roles](https://stytch.com/docs/b2b/guides/rbac/stytch-default)
    /// for a more detailed explanation.
    ///
    ///
    pub role_id: String,
}
/// GithubProviderInfo:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GithubProviderInfo {
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// provider_tenant_ids: All tenant IDs returned by the OAuth provider. These is typically used to identify
    /// organizations or groups within the provider's domain. For example, in HubSpot this is a Hub ID, in Slack
    /// this is the Workspace ID, and in GitHub this is an organization ID. Some OAuth providers do not return
    /// tenant IDs, some providers are guaranteed to return one, and some may return multiple. This field will
    /// always be populated if at least one tenant ID was returned from the OAuth provider and developers should
    /// prefer this field over `provider_tenant_id`.
    pub provider_tenant_ids: std::vec::Vec<String>,
    /// access_token: The `access_token` that you may use to access the User's data in the provider's API.
    pub access_token: String,
    /// scopes: The OAuth scopes included for a given provider. See each provider's section above to see which
    /// scopes are included by default and how to add custom scopes.
    pub scopes: std::vec::Vec<String>,
}
/// HubspotProviderInfo:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct HubspotProviderInfo {
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// provider_tenant_id: The tenant ID returned by the OAuth provider. This is typically used to identify an
    /// organization or group within the provider's domain. For example, in HubSpot this is a Hub ID, in Slack
    /// this is the Workspace ID, and in GitHub this is an organization ID. This field will only be populated if
    /// exactly one tenant ID is returned from a successful OAuth authentication and developers should prefer
    /// `provider_tenant_ids` over this since it accounts for the possibility of an OAuth provider yielding
    /// multiple tenant IDs.
    pub provider_tenant_id: String,
    /// access_token: The `access_token` that you may use to access the User's data in the provider's API.
    pub access_token: String,
    /// access_token_expires_in: The number of seconds until the access token expires.
    pub access_token_expires_in: i32,
    /// scopes: The OAuth scopes included for a given provider. See each provider's section above to see which
    /// scopes are included by default and how to add custom scopes.
    pub scopes: std::vec::Vec<String>,
    /// refresh_token: The `refresh_token` that you may use to obtain a new `access_token` for the User within
    /// the provider's API.
    pub refresh_token: std::option::Option<String>,
}
/// Member:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Member {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
    /// member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to
    /// perform operations on a Member, so be sure to preserve this value. You may use an external_id here if
    /// one is set for the member.
    pub member_id: String,
    /// email_address: The email address of the Member.
    pub email_address: String,
    /// status: The status of the Member. The possible values are: `pending`, `invited`, `active`, or `deleted`.
    pub status: String,
    /// name: The name of the Member.
    pub name: String,
    /// sso_registrations: An array of registered
    /// [SAML Connection](https://stytch.com/docs/b2b/api/saml-connection-object) or
    /// [OIDC Connection](https://stytch.com/docs/b2b/api/oidc-connection-object) objects the Member has
    /// authenticated with.
    pub sso_registrations: std::vec::Vec<SSORegistration>,
    /// is_breakglass: Identifies the Member as a break glass user - someone who has permissions to authenticate
    /// into an Organization by bypassing the Organization's settings. A break glass account is typically used
    /// for emergency purposes to gain access outside of normal authentication procedures. Refer to the
    /// [Organization object](https://stytch.com/docs/b2b/api/organization-object) and its `auth_methods` and
    /// `allowed_auth_methods` fields for more details.
    pub is_breakglass: bool,
    /// member_password_id: Globally unique UUID that identifies a Member's password.
    pub member_password_id: String,
    /// oauth_registrations: A list of OAuth registrations for this member.
    pub oauth_registrations: std::vec::Vec<OAuthRegistration>,
    /// email_address_verified: Whether or not the Member's email address is verified.
    pub email_address_verified: bool,
    /// mfa_phone_number_verified: Whether or not the Member's phone number is verified.
    pub mfa_phone_number_verified: bool,
    /// is_admin: Whether or not the Member has the `stytch_admin` Role. This Role is automatically granted to
    /// Members
    ///   who create an Organization through the
    /// [discovery flow](https://stytch.com/docs/b2b/api/create-organization-via-discovery). See the
    ///   [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/stytch-default) for more details on this Role.
    pub is_admin: bool,
    pub totp_registration_id: String,
    /// retired_email_addresses:
    ///   A list of retired email addresses for this member.
    ///   A previously active email address can be marked as retired in one of two ways:
    ///   - It's replaced with a new primary email address during an explicit Member update.
    ///   - A new email address is surfaced by an OAuth, SAML or OIDC provider. In this case the new email
    /// address becomes the
    ///   Member's primary email address and the old primary email address is retired.
    ///
    ///   A retired email address cannot be used by other Members in the same Organization. However, unlinking
    /// retired email
    ///   addresses allows them to be subsequently re-used by other Organization Members. Retired email
    /// addresses can be unlinked
    ///   using the [Unlink Retired Email endpoint](https://stytch.com/docs/b2b/api/unlink-retired-member-email).
    ///
    pub retired_email_addresses: std::vec::Vec<RetiredEmail>,
    pub is_locked: bool,
    /// mfa_enrolled: Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step
    /// whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA
    /// step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
    pub mfa_enrolled: bool,
    /// mfa_phone_number: The Member's phone number. A Member may only have one phone number. The phone number
    /// should be in E.164 format (i.e. +1XXXXXXXXXX).
    pub mfa_phone_number: String,
    pub default_mfa_method: String,
    /// roles: Explicit or implicit Roles assigned to this Member, along with details about the role assignment
    /// source.
    ///    See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information
    /// about role assignment.
    pub roles: std::vec::Vec<MemberRole>,
    /// trusted_metadata: An arbitrary JSON object for storing application-specific data or
    /// identity-provider-specific data.
    pub trusted_metadata: std::option::Option<serde_json::Value>,
    /// untrusted_metadata: An arbitrary JSON object of application-specific data. These fields can be edited
    /// directly by the
    ///   frontend SDK, and should not be used to store critical information. See the
    /// [Metadata resource](https://stytch.com/docs/b2b/api/metadata)
    ///   for complete field behavior details.
    pub untrusted_metadata: std::option::Option<serde_json::Value>,
    /// created_at: The timestamp of the Member's creation. Values conform to the RFC 3339 standard and are
    /// expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
    pub created_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// updated_at: The timestamp of when the Member was last updated. Values conform to the RFC 3339 standard
    /// and are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
    pub updated_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// scim_registration: A scim member registration, referencing a
    /// [SCIM Connection](https://stytch.com/docs/b2b/api/scim-connection-object) object in use for the Member
    /// creation.
    pub scim_registration: std::option::Option<SCIMRegistration>,
    /// external_id: The ID of the member given by the identity provider.
    pub external_id: std::option::Option<String>,
    pub lock_created_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    pub lock_expires_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
}
/// MemberConnectedApp:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MemberConnectedApp {
    /// connected_app_id: The ID of the Connected App.
    pub connected_app_id: String,
    /// name: The name of the Connected App.
    pub name: String,
    /// description: A description of the Connected App.
    pub description: String,
    /// client_type: The type of Connected App. Supported values are `first_party`, `first_party_public`,
    /// `third_party`, and `third_party_public`.
    pub client_type: String,
    /// scopes_granted: The scopes granted to the Connected App at the completion of the last authorization flow.
    pub scopes_granted: String,
    /// logo_url: The logo URL of the Connected App, if any.
    pub logo_url: std::option::Option<String>,
}
/// MemberRole:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MemberRole {
    /// role_id: The unique identifier of the RBAC Role, provided by the developer and intended to be
    /// human-readable.
    ///
    ///   Reserved `role_id`s that are predefined by Stytch include:
    ///
    ///   * `stytch_member`
    ///   * `stytch_admin`
    ///
    ///   Check out the [guide on Stytch default Roles](https://stytch.com/docs/b2b/guides/rbac/stytch-default)
    /// for a more detailed explanation.
    ///
    ///
    pub role_id: String,
    /// sources: A list of sources for this role assignment. A role assignment can come from multiple sources -
    /// for example, the Role could be both explicitly assigned and implicitly granted from the Member's email
    /// domain.
    pub sources: std::vec::Vec<MemberRoleSource>,
}
/// MemberRoleSource:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MemberRoleSource {
    /// type_: The type of role assignment. The possible values are:
    ///
    ///   `direct_assignment` – an explicitly assigned Role.
    ///
    ///   Directly assigned roles can be updated by passing in the `roles` argument to the
    ///   [Update Member](https://stytch.com/docs/b2b/api/update-member) endpoint.
    ///
    ///   `email_assignment` – an implicit Role granted by the Member's email domain, regardless of their login
    /// method.
    ///
    ///   Email implicit role assignments can be updated by passing in the
    /// `rbac_email_implicit_role_assignments` argument to
    ///   the [Update Organization](https://stytch.com/docs/b2b/api/update-organization) endpoint.
    ///
    ///   `sso_connection` – an implicit Role granted by the Member's SSO connection. This is currently only
    /// available
    ///   for SAML connections and not for OIDC. If the Member has a SAML Member registration with the given
    /// connection, this
    ///   role assignment will appear in the list. However, for authorization check purposes (in
    ///   [sessions authenticate](https://stytch.com/docs/b2b/api/authenticate-session) or in any endpoint that
    /// enforces RBAC with session
    ///   headers), the Member will only be granted the Role if their session contains an authentication factor
    /// with the
    ///   specified SAML connection.
    ///
    ///   SAML connection implicit role assignments can be updated by passing in the
    ///   `saml_connection_implicit_role_assignments` argument to the
    ///   [Update SAML connection](https://stytch.com/docs/b2b/api/update-saml-connection) endpoint.
    ///
    ///   `sso_connection_group` – an implicit Role granted by the Member's SSO connection and group. This is
    /// currently only
    ///   available for SAML connections and not for OIDC. If the Member has a SAML Member registration with the
    /// given
    ///   connection, and belongs to a specific group within the IdP, this role assignment will appear in the
    /// list. However,
    ///   for authorization check purposes (in
    /// [sessions authenticate](https://stytch.com/docs/b2b/api/authenticate-session) or in any endpoint
    ///   that enforces RBAC with session headers), the Member will only be granted the role if their session
    /// contains an
    ///   authentication factor with the specified SAML connection.
    ///
    ///   SAML group implicit role assignments can be updated by passing in the
    /// `saml_group_implicit_role_assignments`
    ///   argument to the [Update SAML connection](https://stytch.com/docs/b2b/api/update-saml-connection)
    /// endpoint.
    ///
    /// `scim_connection_group` – an implicit Role granted by the Member's SCIM connection and group. If the
    /// Member has
    ///   a SCIM Member registration with the given connection, and belongs to a specific group within the IdP,
    /// this role assignment will appear in the list.
    ///
    ///   SCIM group implicit role assignments can be updated by passing in the
    /// `scim_group_implicit_role_assignments`
    ///   argument to the [Update SCIM connection](https://stytch.com/docs/b2b/api/update-scim-connection)
    /// endpoint.
    ///
    #[serde(rename = "type")]
    pub type_: String,
    /// details: An object containing additional metadata about the source assignment. The fields will vary
    /// depending
    ///   on the role assignment type as follows:
    ///
    ///   `direct_assignment` – no additional details.
    ///
    ///   `email_assignment` – will contain the email domain that granted the assignment.
    ///
    ///   `sso_connection` – will contain the `connection_id` of the SAML connection that granted the assignment.
    ///
    ///   `sso_connection_group` – will contain the `connection_id` of the SAML connection and the name of the
    /// `group`
    ///   that granted the assignment.
    ///
    ///   `scim_connection_group` – will contain the `connection_id` of the SAML connection and the `group_id`
    ///   that granted the assignment.
    ///
    pub details: std::option::Option<serde_json::Value>,
}
/// OAuthRegistration:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OAuthRegistration {
    /// provider_type: Denotes the OAuth identity provider that the user has authenticated with, e.g. Google,
    /// Microsoft, GitHub etc.
    pub provider_type: String,
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// member_oauth_registration_id: The unique ID of an OAuth registration.
    pub member_oauth_registration_id: String,
    /// profile_picture_url: If available, the `profile_picture_url` is a URL of the User's profile picture set
    /// in OAuth identity the provider that the User has authenticated with, e.g. Google profile picture.
    pub profile_picture_url: std::option::Option<String>,
    /// locale: If available, the `locale` is the Member's locale set in the OAuth identity provider that the
    /// user has authenticated with.
    pub locale: std::option::Option<String>,
}
/// OIDCProviderInfo:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OIDCProviderInfo {
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// id_token: The `id_token` returned by the OAuth provider. ID Tokens are JWTs that contain structured
    /// information about a user. The exact content of each ID Token varies from provider to provider. ID Tokens
    /// are returned from OAuth providers that conform to the [OpenID Connect](https://openid.net/foundation/)
    /// specification, which is based on OAuth.
    pub id_token: String,
    /// access_token: The `access_token` that you may use to access the User's data in the provider's API.
    pub access_token: String,
    /// access_token_expires_in: The number of seconds until the access token expires.
    pub access_token_expires_in: i32,
    /// scopes: The OAuth scopes included for a given provider. See each provider's section above to see which
    /// scopes are included by default and how to add custom scopes.
    pub scopes: std::vec::Vec<String>,
    /// connection_id: Globally unique UUID that identifies a specific SSO `connection_id` for a Member.
    pub connection_id: String,
    /// refresh_token: The `refresh_token` that you may use to obtain a new `access_token` for the User within
    /// the provider's API.
    pub refresh_token: std::option::Option<String>,
}
/// Organization:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Organization {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
    /// organization_name: The name of the Organization. Must be between 1 and 128 characters in length.
    pub organization_name: String,
    /// organization_logo_url: The image URL of the Organization logo.
    pub organization_logo_url: String,
    /// organization_slug: The unique URL slug of the Organization. The slug only accepts alphanumeric
    /// characters and the following reserved characters: `-` `.` `_` `~`. Must be between 2 and 128 characters
    /// in length. Wherever an organization_id is expected in a path or request parameter, you may also use the
    /// organization_slug as a convenience.
    pub organization_slug: String,
    /// sso_jit_provisioning: The authentication setting that controls the JIT provisioning of Members when
    /// authenticating via SSO. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting, new Members will be automatically provisioned upon successful
    /// authentication via any of the Organization's `sso_active_connections`.
    ///
    ///   `RESTRICTED` – only new Members with SSO logins that comply with
    /// `sso_jit_provisioning_allowed_connections` can be provisioned upon authentication.
    ///
    ///   `NOT_ALLOWED` – disable JIT provisioning via SSO.
    ///
    pub sso_jit_provisioning: String,
    /// sso_jit_provisioning_allowed_connections: An array of `connection_id`s that reference
    /// [SAML Connection objects](https://stytch.com/docs/b2b/api/saml-connection-object).
    ///   Only these connections will be allowed to JIT provision Members via SSO when `sso_jit_provisioning` is
    /// set to `RESTRICTED`.
    pub sso_jit_provisioning_allowed_connections: std::vec::Vec<String>,
    /// sso_active_connections: An array of active
    /// [SAML Connection references](https://stytch.com/docs/b2b/api/saml-connection-object) or
    /// [OIDC Connection references](https://stytch.com/docs/b2b/api/oidc-connection-object).
    pub sso_active_connections: std::vec::Vec<ActiveSSOConnection>,
    /// email_allowed_domains: An array of email domains that allow invites or JIT provisioning for new Members.
    /// This list is enforced when either `email_invites` or `email_jit_provisioning` is set to `RESTRICTED`.
    ///
    ///
    /// Common domains such as `gmail.com` are not allowed. See the
    /// [common email domains resource](https://stytch.com/docs/b2b/api/common-email-domains) for the full list.
    pub email_allowed_domains: std::vec::Vec<String>,
    /// email_jit_provisioning: The authentication setting that controls how a new Member can be provisioned by
    /// authenticating via Email Magic Link or OAuth. The accepted values are:
    ///
    ///   `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be
    /// provisioned upon authentication via Email Magic Link or OAuth.
    ///
    ///   `NOT_ALLOWED` – the default setting, disables JIT provisioning via Email Magic Link and OAuth.
    ///
    pub email_jit_provisioning: String,
    /// email_invites: The authentication setting that controls how a new Member can be invited to an
    /// organization by email. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – any new Member can be invited to join via email.
    ///
    ///   `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be
    /// invited via email.
    ///
    ///   `NOT_ALLOWED` – disable email invites.
    ///
    pub email_invites: String,
    /// auth_methods: The setting that controls which authentication methods can be used by Members of an
    /// Organization. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
    ///
    ///   `RESTRICTED` – only methods that comply with `allowed_auth_methods` can be used for authentication.
    /// This setting does not apply to Members with `is_breakglass` set to `true`.
    ///
    pub auth_methods: String,
    /// allowed_auth_methods: An array of allowed authentication methods. This list is enforced when
    /// `auth_methods` is set to `RESTRICTED`.
    ///   The list's accepted values are: `sso`, `magic_link`, `email_otp`, `password`, `google_oauth`,
    /// `microsoft_oauth`, `slack_oauth`, `github_oauth`, and `hubspot_oauth`.
    ///
    pub allowed_auth_methods: std::vec::Vec<String>,
    pub mfa_policy: String,
    /// rbac_email_implicit_role_assignments: Implicit role assignments based off of email domains.
    ///   For each domain-Role pair, all Members whose email addresses have the specified email domain will be
    /// granted the
    ///   associated Role, regardless of their login method. See the
    /// [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
    ///   for more information about role assignment.
    pub rbac_email_implicit_role_assignments: std::vec::Vec<EmailImplicitRoleAssignment>,
    /// mfa_methods: The setting that controls which MFA methods can be used by Members of an Organization. The
    /// accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
    ///
    ///   `RESTRICTED` – only methods that comply with `allowed_mfa_methods` can be used for authentication.
    /// This setting does not apply to Members with `is_breakglass` set to `true`.
    ///
    pub mfa_methods: String,
    /// allowed_mfa_methods: An array of allowed MFA authentication methods. This list is enforced when
    /// `mfa_methods` is set to `RESTRICTED`.
    ///   The list's accepted values are: `sms_otp` and `totp`.
    ///
    pub allowed_mfa_methods: std::vec::Vec<String>,
    /// oauth_tenant_jit_provisioning: The authentication setting that controls how a new Member can JIT
    /// provision into an organization by tenant. The accepted values are:
    ///
    ///   `RESTRICTED` – only new Members with tenants in `allowed_oauth_tenants` can JIT provision via tenant.
    ///
    ///   `NOT_ALLOWED` – the default setting, disables JIT provisioning by OAuth Tenant.
    ///
    pub oauth_tenant_jit_provisioning: String,
    pub claimed_email_domains: std::vec::Vec<String>,
    /// first_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy
    /// towards first party Connected Apps. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting, any first party Connected App in the Project is permitted for use
    /// by Members.
    ///
    ///   `RESTRICTED` – only first party Connected Apps with IDs in `allowed_first_party_connected_apps` can be
    /// used by Members.
    ///
    ///   `NOT_ALLOWED` – no first party Connected Apps are permitted.
    ///
    pub first_party_connected_apps_allowed_type: String,
    /// allowed_first_party_connected_apps: An array of first party Connected App IDs that are allowed for the
    /// Organization. Only used when the Organization's `first_party_connected_apps_allowed_type` is
    /// `RESTRICTED`.
    pub allowed_first_party_connected_apps: std::vec::Vec<String>,
    /// third_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy
    /// towards third party Connected Apps. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting, any third party Connected App in the Project is permitted for use
    /// by Members.
    ///
    ///   `RESTRICTED` – only third party Connected Apps with IDs in `allowed_first_party_connected_apps` can be
    /// used by Members.
    ///
    ///   `NOT_ALLOWED` – no third party Connected Apps are permitted.
    ///
    pub third_party_connected_apps_allowed_type: String,
    /// allowed_third_party_connected_apps: An array of third party Connected App IDs that are allowed for the
    /// Organization. Only used when the Organization's `third_party_connected_apps_allowed_type` is
    /// `RESTRICTED`.
    pub allowed_third_party_connected_apps: std::vec::Vec<String>,
    /// trusted_metadata: An arbitrary JSON object for storing application-specific data or
    /// identity-provider-specific data.
    pub trusted_metadata: std::option::Option<serde_json::Value>,
    /// created_at: The timestamp of the Organization's creation. Values conform to the RFC 3339 standard and
    /// are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
    pub created_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// updated_at: The timestamp of when the Organization was last updated. Values conform to the RFC 3339
    /// standard and are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
    pub updated_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// organization_external_id: A unique identifier for the organization.
    pub organization_external_id: std::option::Option<String>,
    /// sso_default_connection_id: The default connection used for SSO when there are multiple active
    /// connections.
    pub sso_default_connection_id: std::option::Option<String>,
    /// scim_active_connection: An active
    /// [SCIM Connection references](https://stytch.com/docs/b2b/api/scim-connection-object).
    pub scim_active_connection: std::option::Option<ActiveSCIMConnection>,
    /// allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization
    /// will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
    pub allowed_oauth_tenants: std::option::Option<serde_json::Value>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OrganizationConnectedApp {
    pub connected_app_id: String,
    pub name: String,
    pub description: String,
    pub client_type: String,
    pub logo_url: std::option::Option<String>,
}
/// OrganizationConnectedAppActiveMember:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OrganizationConnectedAppActiveMember {
    /// member_id: Globally unique UUID that identifies a specific Member.
    pub member_id: String,
    /// granted_scopes: Scopes that were granted at the completion of the last authorization flow.
    pub granted_scopes: std::vec::Vec<String>,
}
/// ResultsMetadata:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ResultsMetadata {
    /// total: The total number of results returned by your search query. If totals have been disabled for your
    /// Stytch Workspace to improve search performance, the value will always be -1.
    pub total: i32,
    /// next_cursor: The `next_cursor` string is returned when your search result contains more than one page of
    /// results. This value is passed into your next search call in the `cursor` field.
    pub next_cursor: std::option::Option<String>,
}
/// RetiredEmail:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RetiredEmail {
    /// email_id: The globally unique UUID of a Member's email.
    pub email_id: String,
    /// email_address: The email address of the Member.
    pub email_address: String,
}
/// SCIMRegistration:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SCIMRegistration {
    /// connection_id: The ID of the SCIM connection.
    pub connection_id: String,
    /// registration_id: The unique ID of a SCIM Registration.
    pub registration_id: String,
    /// external_id: The ID of the member given by the identity provider.
    pub external_id: std::option::Option<String>,
    /// scim_attributes: An object for storing SCIM attributes brought over from the identity provider.
    pub scim_attributes: std::option::Option<SCIMAttributes>,
}
/// SSORegistration:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SSORegistration {
    /// connection_id: Globally unique UUID that identifies a specific SSO `connection_id` for a Member.
    pub connection_id: String,
    /// external_id: The ID of the member given by the identity provider.
    pub external_id: String,
    /// registration_id: The unique ID of an SSO Registration.
    pub registration_id: String,
    /// sso_attributes: An object for storing SSO attributes brought over from the identity provider.
    pub sso_attributes: std::option::Option<serde_json::Value>,
}
/// SearchQuery:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SearchQuery {
    /// operator: The action to perform on the operands. The accepted values are:
    ///
    ///   `AND` – all the operand values provided must match.
    ///
    ///   `OR` – **[DEPRECATED]** the operator will return any matches to at least one of the operand values you
    /// supply. This parameter is retained for legacy use cases only and is no longer supported. We strongly
    /// recommend breaking down complex queries into multiple search queries instead.
    pub operator: SearchQueryOperator,
    /// operands: An array of operand objects that contains all of the filters and values to apply to your
    /// search query.
    pub operands: std::vec::Vec<serde_json::Value>,
}
/// SlackProviderInfo:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SlackProviderInfo {
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// provider_tenant_id: The tenant ID returned by the OAuth provider. This is typically used to identify an
    /// organization or group within the provider's domain. For example, in HubSpot this is a Hub ID, in Slack
    /// this is the Workspace ID, and in GitHub this is an organization ID. This field will only be populated if
    /// exactly one tenant ID is returned from a successful OAuth authentication and developers should prefer
    /// `provider_tenant_ids` over this since it accounts for the possibility of an OAuth provider yielding
    /// multiple tenant IDs.
    pub provider_tenant_id: String,
    /// access_token: The `access_token` that you may use to access the User's data in the provider's API.
    pub access_token: String,
    /// scopes: The OAuth scopes included for a given provider. See each provider's section above to see which
    /// scopes are included by default and how to add custom scopes.
    pub scopes: std::vec::Vec<String>,
    /// bot_access_token: The `access_token` that you may use to access data as a bot application in Slack. Use
    /// in conjunction with `bot_scopes`.
    pub bot_access_token: String,
    /// bot_scopes: The scopes that the bot application has access to in Slack.
    pub bot_scopes: std::vec::Vec<String>,
}
/// ConnectedAppsRequest: Request type for `Organizations.connected_apps`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct ConnectedAppsRequest {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
}
/// ConnectedAppsResponse: Response type for `Organizations.connected_apps`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ConnectedAppsResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    pub connected_apps: std::vec::Vec<OrganizationConnectedApp>,
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}
/// CreateRequest: Request type for `Organizations.create`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct CreateRequest {
    /// organization_name: The name of the Organization. Must be between 1 and 128 characters in length.
    pub organization_name: String,
    /// organization_slug: The unique URL slug of the Organization. The slug only accepts alphanumeric
    /// characters and the following reserved characters: `-` `.` `_` `~`. Must be between 2 and 128 characters
    /// in length. Wherever an organization_id is expected in a path or request parameter, you may also use the
    /// organization_slug as a convenience.
    pub organization_slug: std::option::Option<String>,
    /// organization_logo_url: The image URL of the Organization logo.
    pub organization_logo_url: std::option::Option<String>,
    /// trusted_metadata: An arbitrary JSON object for storing application-specific data or
    /// identity-provider-specific data.
    pub trusted_metadata: std::option::Option<serde_json::Value>,
    /// organization_external_id: An identifier that can be used in API calls wherever a organization_id is
    /// expected. This is a string consisting of alphanumeric, `.`, `_`, `-`, or `|` characters with a maximum
    /// length of 128 characters. External IDs must be unique within a project, but may be reused across
    /// different projects in the same workspace.
    pub organization_external_id: std::option::Option<String>,
    /// sso_jit_provisioning: The authentication setting that controls the JIT provisioning of Members when
    /// authenticating via SSO. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting, new Members will be automatically provisioned upon successful
    /// authentication via any of the Organization's `sso_active_connections`.
    ///
    ///   `RESTRICTED` – only new Members with SSO logins that comply with
    /// `sso_jit_provisioning_allowed_connections` can be provisioned upon authentication.
    ///
    ///   `NOT_ALLOWED` – disable JIT provisioning via SSO.
    ///
    pub sso_jit_provisioning: std::option::Option<String>,
    /// email_allowed_domains: An array of email domains that allow invites or JIT provisioning for new Members.
    /// This list is enforced when either `email_invites` or `email_jit_provisioning` is set to `RESTRICTED`.
    ///
    ///
    /// Common domains such as `gmail.com` are not allowed. See the
    /// [common email domains resource](https://stytch.com/docs/b2b/api/common-email-domains) for the full list.
    pub email_allowed_domains: std::option::Option<std::vec::Vec<String>>,
    /// email_jit_provisioning: The authentication setting that controls how a new Member can be provisioned by
    /// authenticating via Email Magic Link or OAuth. The accepted values are:
    ///
    ///   `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be
    /// provisioned upon authentication via Email Magic Link or OAuth.
    ///
    ///   `NOT_ALLOWED` – the default setting, disables JIT provisioning via Email Magic Link and OAuth.
    ///
    pub email_jit_provisioning: std::option::Option<String>,
    /// email_invites: The authentication setting that controls how a new Member can be invited to an
    /// organization by email. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – any new Member can be invited to join via email.
    ///
    ///   `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be
    /// invited via email.
    ///
    ///   `NOT_ALLOWED` – disable email invites.
    ///
    pub email_invites: std::option::Option<String>,
    /// auth_methods: The setting that controls which authentication methods can be used by Members of an
    /// Organization. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
    ///
    ///   `RESTRICTED` – only methods that comply with `allowed_auth_methods` can be used for authentication.
    /// This setting does not apply to Members with `is_breakglass` set to `true`.
    ///
    pub auth_methods: std::option::Option<String>,
    /// allowed_auth_methods: An array of allowed authentication methods. This list is enforced when
    /// `auth_methods` is set to `RESTRICTED`.
    ///   The list's accepted values are: `sso`, `magic_link`, `email_otp`, `password`, `google_oauth`,
    /// `microsoft_oauth`, `slack_oauth`, `github_oauth`, and `hubspot_oauth`.
    ///
    pub allowed_auth_methods: std::option::Option<std::vec::Vec<String>>,
    /// mfa_policy: The setting that controls the MFA policy for all Members in the Organization. The accepted
    /// values are:
    ///
    ///   `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time
    /// they wish to log in. However, any active Session that existed prior to this setting change will remain
    /// valid.
    ///
    ///   `OPTIONAL` – The default value. The Organization does not require MFA by default for all Members.
    /// Members will be required to complete MFA only if their `mfa_enrolled` status is set to true.
    ///
    pub mfa_policy: std::option::Option<String>,
    /// rbac_email_implicit_role_assignments: Implicit role assignments based off of email domains.
    ///   For each domain-Role pair, all Members whose email addresses have the specified email domain will be
    /// granted the
    ///   associated Role, regardless of their login method. See the
    /// [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
    ///   for more information about role assignment.
    pub rbac_email_implicit_role_assignments:
        std::option::Option<std::vec::Vec<EmailImplicitRoleAssignment>>,
    /// mfa_methods: The setting that controls which MFA methods can be used by Members of an Organization. The
    /// accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
    ///
    ///   `RESTRICTED` – only methods that comply with `allowed_mfa_methods` can be used for authentication.
    /// This setting does not apply to Members with `is_breakglass` set to `true`.
    ///
    pub mfa_methods: std::option::Option<String>,
    /// allowed_mfa_methods: An array of allowed MFA authentication methods. This list is enforced when
    /// `mfa_methods` is set to `RESTRICTED`.
    ///   The list's accepted values are: `sms_otp` and `totp`.
    ///
    pub allowed_mfa_methods: std::option::Option<std::vec::Vec<String>>,
    /// oauth_tenant_jit_provisioning: The authentication setting that controls how a new Member can JIT
    /// provision into an organization by tenant. The accepted values are:
    ///
    ///   `RESTRICTED` – only new Members with tenants in `allowed_oauth_tenants` can JIT provision via tenant.
    ///
    ///   `NOT_ALLOWED` – the default setting, disables JIT provisioning by OAuth Tenant.
    ///
    pub oauth_tenant_jit_provisioning: std::option::Option<String>,
    /// allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization
    /// will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
    pub allowed_oauth_tenants: std::option::Option<serde_json::Value>,
    /// claimed_email_domains: A list of email domains that are claimed by the Organization.
    pub claimed_email_domains: std::option::Option<std::vec::Vec<String>>,
    /// first_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy
    /// towards first party Connected Apps. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting, any first party Connected App in the Project is permitted for use
    /// by Members.
    ///
    ///   `RESTRICTED` – only first party Connected Apps with IDs in `allowed_first_party_connected_apps` can be
    /// used by Members.
    ///
    ///   `NOT_ALLOWED` – no first party Connected Apps are permitted.
    ///
    pub first_party_connected_apps_allowed_type:
        std::option::Option<CreateRequestFirstPartyConnectedAppsAllowedType>,
    /// allowed_first_party_connected_apps: An array of first party Connected App IDs that are allowed for the
    /// Organization. Only used when the Organization's `first_party_connected_apps_allowed_type` is
    /// `RESTRICTED`.
    pub allowed_first_party_connected_apps: std::option::Option<std::vec::Vec<String>>,
    /// third_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy
    /// towards third party Connected Apps. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting, any third party Connected App in the Project is permitted for use
    /// by Members.
    ///
    ///   `RESTRICTED` – only third party Connected Apps with IDs in `allowed_first_party_connected_apps` can be
    /// used by Members.
    ///
    ///   `NOT_ALLOWED` – no third party Connected Apps are permitted.
    ///
    pub third_party_connected_apps_allowed_type:
        std::option::Option<CreateRequestThirdPartyConnectedAppsAllowedType>,
    /// allowed_third_party_connected_apps: An array of third party Connected App IDs that are allowed for the
    /// Organization. Only used when the Organization's `third_party_connected_apps_allowed_type` is
    /// `RESTRICTED`.
    pub allowed_third_party_connected_apps: std::option::Option<std::vec::Vec<String>>,
}
/// CreateResponse: Response type for `Organizations.create`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CreateResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// organization: The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
    pub organization: Organization,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}
/// DeleteRequest: Request type for `Organizations.delete`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct DeleteRequest {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
}
/// DeleteResponse: Response type for `Organizations.delete`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DeleteResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value.
    pub organization_id: String,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}
/// GetConnectedAppRequest: Request type for `Organizations.get_connected_app`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct GetConnectedAppRequest {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
    /// connected_app_id: The ID of the Connected App.
    pub connected_app_id: String,
}
/// GetConnectedAppResponse: Response type for `Organizations.get_connected_app`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GetConnectedAppResponse {
    /// connected_app_id: The ID of the Connected App.
    pub connected_app_id: String,
    /// name: The name of the Connected App.
    pub name: String,
    /// description: A description of the Connected App.
    pub description: String,
    /// client_type: The type of Connected App. Supported values are `first_party`, `first_party_public`,
    /// `third_party`, and `third_party_public`.
    pub client_type: String,
    /// active_members: Details about Members who has installed a Connected App.
    pub active_members: std::vec::Vec<OrganizationConnectedAppActiveMember>,
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
    pub logo_url: std::option::Option<String>,
}
/// GetRequest: Request type for `Organizations.get`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct GetRequest {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
}
/// GetResponse: Response type for `Organizations.get`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GetResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// organization: The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
    pub organization: Organization,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct MetricsRequest {
    pub organization_id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MetricsResponse {
    pub request_id: String,
    pub member_count: u32,
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}
/// SearchRequest: Request type for `Organizations.search`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct SearchRequest {
    /// cursor: The `cursor` field allows you to paginate through your results. Each result array is limited to
    /// 1000 results. If your query returns more than 1000 results, you will need to paginate the responses
    /// using the `cursor`. If you receive a response that includes a non-null `next_cursor` in the
    /// `results_metadata` object, repeat the search call with the `next_cursor` value set to the `cursor` field
    /// to retrieve the next page of results. Continue to make search calls until the `next_cursor` in the
    /// response is null.
    pub cursor: std::option::Option<String>,
    /// limit: The number of search results to return per page. The default limit is 100. A maximum of 1000
    /// results can be returned by a single search request. If the total size of your result set is greater than
    /// one page size, you must paginate the response. See the `cursor` field.
    pub limit: std::option::Option<u32>,
    /// query: The optional query object contains the operator, i.e. `AND` or `OR`, and the operands that will
    /// filter your results. Only an operator is required. If you include no operands, no filtering will be
    /// applied. If you include no query object, it will return all Organizations with no filtering applied.
    pub query: std::option::Option<SearchQuery>,
}
/// SearchResponse: Response type for `Organizations.search`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SearchResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// organizations: An array of [Organization objects](https://stytch.com/docs/b2b/api/organization-object).
    pub organizations: std::vec::Vec<Organization>,
    /// results_metadata: The search `results_metadata` object contains metadata relevant to your specific query
    /// like `total` and `next_cursor`.
    pub results_metadata: ResultsMetadata,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}
/// UpdateRequest: Request type for `Organizations.update`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct UpdateRequest {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
    /// organization_name: The name of the Organization. Must be between 1 and 128 characters in length.
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.info.name` action on the `stytch.organization` Resource.
    pub organization_name: std::option::Option<String>,
    /// organization_slug: The unique URL slug of the Organization. The slug only accepts alphanumeric
    /// characters and the following reserved characters: `-` `.` `_` `~`. Must be between 2 and 128 characters
    /// in length. Wherever an organization_id is expected in a path or request parameter, you may also use the
    /// organization_slug as a convenience.
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.info.slug` action on the `stytch.organization` Resource.
    pub organization_slug: std::option::Option<String>,
    /// organization_logo_url: The image URL of the Organization logo.
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.info.logo-url` action on the `stytch.organization` Resource.
    pub organization_logo_url: std::option::Option<String>,
    /// trusted_metadata: An arbitrary JSON object for storing application-specific data or
    /// identity-provider-specific data.
    ///   If a session header is passed into the request, this field may **not** be passed into the request. You
    /// cannot
    ///   update trusted metadata when acting as a Member.
    pub trusted_metadata: std::option::Option<serde_json::Value>,
    /// organization_external_id: An identifier that can be used in API calls wherever a organization_id is
    /// expected. This is a string consisting of alphanumeric, `.`, `_`, `-`, or `|` characters with a maximum
    /// length of 128 characters. External IDs must be unique within a project, but may be reused across
    /// different projects in the same workspace.
    pub organization_external_id: std::option::Option<String>,
    /// sso_default_connection_id: The default connection used for SSO when there are multiple active
    /// connections.
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.default-sso-connection` action on the `stytch.organization`
    /// Resource.
    pub sso_default_connection_id: std::option::Option<String>,
    /// sso_jit_provisioning: The authentication setting that controls the JIT provisioning of Members when
    /// authenticating via SSO. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting, new Members will be automatically provisioned upon successful
    /// authentication via any of the Organization's `sso_active_connections`.
    ///
    ///   `RESTRICTED` – only new Members with SSO logins that comply with
    /// `sso_jit_provisioning_allowed_connections` can be provisioned upon authentication.
    ///
    ///   `NOT_ALLOWED` – disable JIT provisioning via SSO.
    ///
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.sso-jit-provisioning` action on the `stytch.organization`
    /// Resource.
    pub sso_jit_provisioning: std::option::Option<String>,
    /// sso_jit_provisioning_allowed_connections: An array of `connection_id`s that reference
    /// [SAML Connection objects](https://stytch.com/docs/b2b/api/saml-connection-object).
    ///   Only these connections will be allowed to JIT provision Members via SSO when `sso_jit_provisioning` is
    /// set to `RESTRICTED`.
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.sso-jit-provisioning` action on the `stytch.organization`
    /// Resource.
    pub sso_jit_provisioning_allowed_connections: std::option::Option<std::vec::Vec<String>>,
    /// email_allowed_domains: An array of email domains that allow invites or JIT provisioning for new Members.
    /// This list is enforced when either `email_invites` or `email_jit_provisioning` is set to `RESTRICTED`.
    ///
    ///
    /// Common domains such as `gmail.com` are not allowed. See the
    /// [common email domains resource](https://stytch.com/docs/b2b/api/common-email-domains) for the full list.
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.allowed-domains` action on the `stytch.organization` Resource.
    pub email_allowed_domains: std::option::Option<std::vec::Vec<String>>,
    /// email_jit_provisioning: The authentication setting that controls how a new Member can be provisioned by
    /// authenticating via Email Magic Link or OAuth. The accepted values are:
    ///
    ///   `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be
    /// provisioned upon authentication via Email Magic Link or OAuth.
    ///
    ///   `NOT_ALLOWED` – the default setting, disables JIT provisioning via Email Magic Link and OAuth.
    ///
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.email-jit-provisioning` action on the `stytch.organization`
    /// Resource.
    pub email_jit_provisioning: std::option::Option<String>,
    /// email_invites: The authentication setting that controls how a new Member can be invited to an
    /// organization by email. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – any new Member can be invited to join via email.
    ///
    ///   `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be
    /// invited via email.
    ///
    ///   `NOT_ALLOWED` – disable email invites.
    ///
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.email-invites` action on the `stytch.organization` Resource.
    pub email_invites: std::option::Option<String>,
    /// auth_methods: The setting that controls which authentication methods can be used by Members of an
    /// Organization. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
    ///
    ///   `RESTRICTED` – only methods that comply with `allowed_auth_methods` can be used for authentication.
    /// This setting does not apply to Members with `is_breakglass` set to `true`.
    ///
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.allowed-auth-methods` action on the `stytch.organization`
    /// Resource.
    pub auth_methods: std::option::Option<String>,
    /// allowed_auth_methods: An array of allowed authentication methods. This list is enforced when
    /// `auth_methods` is set to `RESTRICTED`.
    ///   The list's accepted values are: `sso`, `magic_link`, `email_otp`, `password`, `google_oauth`,
    /// `microsoft_oauth`, `slack_oauth`, `github_oauth`, and `hubspot_oauth`.
    ///
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.allowed-auth-methods` action on the `stytch.organization`
    /// Resource.
    pub allowed_auth_methods: std::option::Option<std::vec::Vec<String>>,
    /// mfa_policy: The setting that controls the MFA policy for all Members in the Organization. The accepted
    /// values are:
    ///
    ///   `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time
    /// they wish to log in. However, any active Session that existed prior to this setting change will remain
    /// valid.
    ///
    ///   `OPTIONAL` – The default value. The Organization does not require MFA by default for all Members.
    /// Members will be required to complete MFA only if their `mfa_enrolled` status is set to true.
    ///
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.mfa-policy` action on the `stytch.organization` Resource.
    pub mfa_policy: std::option::Option<String>,
    /// rbac_email_implicit_role_assignments: Implicit role assignments based off of email domains.
    ///   For each domain-Role pair, all Members whose email addresses have the specified email domain will be
    /// granted the
    ///   associated Role, regardless of their login method. See the
    /// [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
    ///   for more information about role assignment.
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.implicit-roles` action on the `stytch.organization` Resource.
    pub rbac_email_implicit_role_assignments:
        std::option::Option<std::vec::Vec<EmailImplicitRoleAssignment>>,
    /// mfa_methods: The setting that controls which MFA methods can be used by Members of an Organization. The
    /// accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
    ///
    ///   `RESTRICTED` – only methods that comply with `allowed_mfa_methods` can be used for authentication.
    /// This setting does not apply to Members with `is_breakglass` set to `true`.
    ///
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.allowed-mfa-methods` action on the `stytch.organization`
    /// Resource.
    pub mfa_methods: std::option::Option<String>,
    /// allowed_mfa_methods: An array of allowed MFA authentication methods. This list is enforced when
    /// `mfa_methods` is set to `RESTRICTED`.
    ///   The list's accepted values are: `sms_otp` and `totp`.
    ///
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.allowed-mfa-methods` action on the `stytch.organization`
    /// Resource.
    pub allowed_mfa_methods: std::option::Option<std::vec::Vec<String>>,
    /// oauth_tenant_jit_provisioning: The authentication setting that controls how a new Member can JIT
    /// provision into an organization by tenant. The accepted values are:
    ///
    ///   `RESTRICTED` – only new Members with tenants in `allowed_oauth_tenants` can JIT provision via tenant.
    ///
    ///   `NOT_ALLOWED` – the default setting, disables JIT provisioning by OAuth Tenant.
    ///
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.oauth-tenant-jit-provisioning` action on the
    /// `stytch.organization` Resource.
    pub oauth_tenant_jit_provisioning: std::option::Option<String>,
    /// allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization
    /// will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
    ///
    /// If this field is provided and a session header is passed into the request, the Member Session must have
    /// permission to perform the `update.settings.allowed-oauth-tenants` action on the `stytch.organization`
    /// Resource.
    pub allowed_oauth_tenants: std::option::Option<serde_json::Value>,
    /// claimed_email_domains: A list of email domains that are claimed by the Organization.
    pub claimed_email_domains: std::option::Option<std::vec::Vec<String>>,
    /// first_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy
    /// towards first party Connected Apps. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting, any first party Connected App in the Project is permitted for use
    /// by Members.
    ///
    ///   `RESTRICTED` – only first party Connected Apps with IDs in `allowed_first_party_connected_apps` can be
    /// used by Members.
    ///
    ///   `NOT_ALLOWED` – no first party Connected Apps are permitted.
    ///
    pub first_party_connected_apps_allowed_type:
        std::option::Option<UpdateRequestFirstPartyConnectedAppsAllowedType>,
    /// allowed_first_party_connected_apps: An array of first party Connected App IDs that are allowed for the
    /// Organization. Only used when the Organization's `first_party_connected_apps_allowed_type` is
    /// `RESTRICTED`.
    pub allowed_first_party_connected_apps: std::option::Option<std::vec::Vec<String>>,
    /// third_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy
    /// towards third party Connected Apps. The accepted values are:
    ///
    ///   `ALL_ALLOWED` – the default setting, any third party Connected App in the Project is permitted for use
    /// by Members.
    ///
    ///   `RESTRICTED` – only third party Connected Apps with IDs in `allowed_first_party_connected_apps` can be
    /// used by Members.
    ///
    ///   `NOT_ALLOWED` – no third party Connected Apps are permitted.
    ///
    pub third_party_connected_apps_allowed_type:
        std::option::Option<UpdateRequestThirdPartyConnectedAppsAllowedType>,
    /// allowed_third_party_connected_apps: An array of third party Connected App IDs that are allowed for the
    /// Organization. Only used when the Organization's `third_party_connected_apps_allowed_type` is
    /// `RESTRICTED`.
    pub allowed_third_party_connected_apps: std::option::Option<std::vec::Vec<String>>,
}
/// UpdateResponse: Response type for `Organizations.update`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct UpdateResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// organization: The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
    pub organization: Organization,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum CreateRequestFirstPartyConnectedAppsAllowedType {
    #[serde(rename = "ALL_ALLOWED")]
    #[default]
    ALLALLOWED,
    #[serde(rename = "RESTRICTED")]
    RESTRICTED,
    #[serde(rename = "NOT_ALLOWED")]
    NOTALLOWED,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum CreateRequestThirdPartyConnectedAppsAllowedType {
    #[serde(rename = "ALL_ALLOWED")]
    #[default]
    ALLALLOWED,
    #[serde(rename = "RESTRICTED")]
    RESTRICTED,
    #[serde(rename = "NOT_ALLOWED")]
    NOTALLOWED,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum SearchQueryOperator {
    #[serde(rename = "OR")]
    #[default]
    OR,
    #[serde(rename = "AND")]
    AND,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum UpdateRequestFirstPartyConnectedAppsAllowedType {
    #[serde(rename = "ALL_ALLOWED")]
    #[default]
    ALLALLOWED,
    #[serde(rename = "RESTRICTED")]
    RESTRICTED,
    #[serde(rename = "NOT_ALLOWED")]
    NOTALLOWED,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum UpdateRequestThirdPartyConnectedAppsAllowedType {
    #[serde(rename = "ALL_ALLOWED")]
    #[default]
    ALLALLOWED,
    #[serde(rename = "RESTRICTED")]
    RESTRICTED,
    #[serde(rename = "NOT_ALLOWED")]
    NOTALLOWED,
}

pub struct Organizations {
    http_client: crate::client::Client,
    pub members: Members,
}

impl Organizations {
    pub fn new(http_client: crate::client::Client) -> Self {
        Self {
            http_client: http_client.clone(),
            members: Members::new(http_client.clone()),
        }
    }

    pub async fn create(&self, body: CreateRequest) -> crate::Result<CreateResponse> {
        let path = String::from("/v1/b2b/organizations");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
    pub async fn get(&self, body: GetRequest) -> crate::Result<GetResponse> {
        let organization_id = percent_encoding::utf8_percent_encode(
            &body.organization_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let path = format!(
            "/v1/b2b/organizations/{organization_id}?{}",
            serde_urlencoded::to_string(body).unwrap()
        );
        self.http_client
            .send(crate::Request {
                method: http::Method::GET,
                path,
                body: serde_json::json!({}),
            })
            .await
    }
    pub async fn update(&self, body: UpdateRequest) -> crate::Result<UpdateResponse> {
        let organization_id = percent_encoding::utf8_percent_encode(
            &body.organization_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let path = format!("/v1/b2b/organizations/{organization_id}");
        self.http_client
            .send(crate::Request {
                method: http::Method::PUT,
                path,
                body,
            })
            .await
    }
    pub async fn delete(&self, body: DeleteRequest) -> crate::Result<DeleteResponse> {
        let organization_id = percent_encoding::utf8_percent_encode(
            &body.organization_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let path = format!("/v1/b2b/organizations/{organization_id}");
        self.http_client
            .send(crate::Request {
                method: http::Method::DELETE,
                path,
                body,
            })
            .await
    }
    pub async fn search(&self, body: SearchRequest) -> crate::Result<SearchResponse> {
        let path = String::from("/v1/b2b/organizations/search");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
    pub async fn metrics(&self, body: MetricsRequest) -> crate::Result<MetricsResponse> {
        let organization_id = percent_encoding::utf8_percent_encode(
            &body.organization_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let path = format!(
            "/v1/b2b/organizations/{organization_id}/metrics?{}",
            serde_urlencoded::to_string(body).unwrap()
        );
        self.http_client
            .send(crate::Request {
                method: http::Method::GET,
                path,
                body: serde_json::json!({}),
            })
            .await
    }
    pub async fn connected_apps(
        &self,
        body: ConnectedAppsRequest,
    ) -> crate::Result<ConnectedAppsResponse> {
        let organization_id = percent_encoding::utf8_percent_encode(
            &body.organization_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let path = format!(
            "/v1/b2b/organizations/{organization_id}/connected_apps?{}",
            serde_urlencoded::to_string(body).unwrap()
        );
        self.http_client
            .send(crate::Request {
                method: http::Method::GET,
                path,
                body: serde_json::json!({}),
            })
            .await
    }
    pub async fn get_connected_app(
        &self,
        body: GetConnectedAppRequest,
    ) -> crate::Result<GetConnectedAppResponse> {
        let organization_id = percent_encoding::utf8_percent_encode(
            &body.organization_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let connected_app_id = percent_encoding::utf8_percent_encode(
            &body.connected_app_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let path = format!(
            "/v1/b2b/organizations/{organization_id}/connected_apps/{connected_app_id}?{}",
            serde_urlencoded::to_string(body).unwrap()
        );
        self.http_client
            .send(crate::Request {
                method: http::Method::GET,
                path,
                body: serde_json::json!({}),
            })
            .await
    }
}
