workos 1.0.1

Official Rust SDK for the WorkOS API
Documentation
// Code generated by oagen. DO NOT EDIT.

use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
use serde::Serialize;

pub struct OrganizationDomainsApi<'a> {
    pub(crate) client: &'a Client,
}

#[derive(Debug, Clone, Serialize)]
pub struct CreateOrganizationDomainParams {
    /// Request body sent with this call.
    ///
    /// Required.
    #[serde(skip)]
    pub body: CreateOrganizationDomain,
}

impl CreateOrganizationDomainParams {
    /// Construct a new `CreateOrganizationDomainParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(body: CreateOrganizationDomain) -> Self {
        Self { body }
    }
}

impl<'a> OrganizationDomainsApi<'a> {
    /// Create an Organization Domain
    ///
    /// Creates a new Organization Domain.
    pub async fn create_organization_domain(
        &self,
        params: CreateOrganizationDomainParams,
    ) -> Result<OrganizationDomain, Error> {
        self.create_organization_domain_with_options(params, None)
            .await
    }

    /// Variant of [`Self::create_organization_domain`] that accepts per-request [`crate::RequestOptions`].
    pub async fn create_organization_domain_with_options(
        &self,
        params: CreateOrganizationDomainParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<OrganizationDomain, Error> {
        let path = "/organization_domains".to_string();
        let method = http::Method::POST;
        self.client
            .request_with_body_opts(method, &path, &params, Some(&params.body), options)
            .await
    }

    /// Get an Organization Domain
    ///
    /// Get the details of an existing organization domain.
    pub async fn get_organization_domain(
        &self,
        id: &str,
    ) -> Result<OrganizationDomainStandAlone, Error> {
        self.get_organization_domain_with_options(id, None).await
    }

    /// Variant of [`Self::get_organization_domain`] that accepts per-request [`crate::RequestOptions`].
    pub async fn get_organization_domain_with_options(
        &self,
        id: &str,
        options: Option<&crate::RequestOptions>,
    ) -> Result<OrganizationDomainStandAlone, Error> {
        let id = crate::client::path_segment(id);
        let path = format!("/organization_domains/{id}");
        let method = http::Method::GET;
        self.client
            .request_with_query_opts(method, &path, &(), options)
            .await
    }

    /// Delete an Organization Domain
    ///
    /// Permanently deletes an organization domain. It cannot be undone.
    pub async fn delete_organization_domain(&self, id: &str) -> Result<(), Error> {
        self.delete_organization_domain_with_options(id, None).await
    }

    /// Variant of [`Self::delete_organization_domain`] that accepts per-request [`crate::RequestOptions`].
    pub async fn delete_organization_domain_with_options(
        &self,
        id: &str,
        options: Option<&crate::RequestOptions>,
    ) -> Result<(), Error> {
        let id = crate::client::path_segment(id);
        let path = format!("/organization_domains/{id}");
        let method = http::Method::DELETE;
        self.client
            .request_with_query_opts_empty(method, &path, &(), options)
            .await
    }

    /// Verify an Organization Domain
    ///
    /// Initiates verification process for an Organization Domain.
    pub async fn verify_organization_domain(
        &self,
        id: &str,
    ) -> Result<OrganizationDomainStandAlone, Error> {
        self.verify_organization_domain_with_options(id, None).await
    }

    /// Variant of [`Self::verify_organization_domain`] that accepts per-request [`crate::RequestOptions`].
    pub async fn verify_organization_domain_with_options(
        &self,
        id: &str,
        options: Option<&crate::RequestOptions>,
    ) -> Result<OrganizationDomainStandAlone, Error> {
        let id = crate::client::path_segment(id);
        let path = format!("/organization_domains/{id}/verify");
        let method = http::Method::POST;
        self.client
            .request_with_query_opts(method, &path, &(), options)
            .await
    }
}