workos 2.2.0

Official Rust SDK for the WorkOS API
Documentation
// This file is auto-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 PipesProviderApi<'a> {
    pub(crate) client: &'a Client,
}

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

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

impl<'a> PipesProviderApi<'a> {
    /// List providers for an organization
    ///
    /// Returns a list of all providers available to the specified organization, along with any configured custom OAuth scopes, enabled state, and organization-managed credentials where applicable.
    pub async fn list_organization_data_integration_configurations(
        &self,
        organization_id: &str,
    ) -> Result<DataIntegrationConfigurationListResponse, Error> {
        self.list_organization_data_integration_configurations_with_options(organization_id, None)
            .await
    }

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

    /// Configure a provider for an organization
    ///
    /// Creates or updates an organization's provider configuration. Use this endpoint to enable or disable a provider, set custom OAuth scopes, or supply organization-managed OAuth credentials.
    pub async fn update_organization_data_integration_configuration(
        &self,
        organization_id: &str,
        slug: &str,
        params: UpdateOrganizationDataIntegrationConfigurationParams,
    ) -> Result<DataIntegrationConfigurationResponse, Error> {
        self.update_organization_data_integration_configuration_with_options(
            organization_id,
            slug,
            params,
            None,
        )
        .await
    }

    /// Variant of [`Self::update_organization_data_integration_configuration`] that accepts per-request [`crate::RequestOptions`].
    pub async fn update_organization_data_integration_configuration_with_options(
        &self,
        organization_id: &str,
        slug: &str,
        params: UpdateOrganizationDataIntegrationConfigurationParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<DataIntegrationConfigurationResponse, Error> {
        let organization_id = crate::client::path_segment(organization_id);
        let slug = crate::client::path_segment(slug);
        let path =
            format!("/organizations/{organization_id}/data_integration_configurations/{slug}");
        let method = http::Method::PUT;
        self.client
            .request_with_body_opts(method, &path, &params, Some(&params.body), options)
            .await
    }
}