rippling_base_api/
saml.rs1use anyhow::Result;
2
3use crate::Client;
4#[derive(Clone, Debug)]
5pub struct Saml {
6 pub client: Client,
7}
8
9impl Saml {
10 #[doc(hidden)]
11 pub fn new(client: Client) -> Self {
12 Self { client }
13 }
14
15 #[doc = "GET SAML Metadata\n\nReturns a SAML IDP metadata file for the current app \
16 integration. Note that this endpoint is only accessible using a token associated with \
17 an app integration that has SAML enabled; otherwise it returns a 404 \
18 error.\n\nRippling's SAML Metadata is per customer app installation. It is not the \
19 same across all customers. It is not the same if the customer uninstalls and \
20 reinstalls your app. Any time a new app is installed, unique SAML Metadata will be \
21 generated specific to that app.\n\n```rust,no_run\nasync fn \
22 example_saml_get_idp_metadata() -> anyhow::Result<()> {\n let client = \
23 rippling_base_api::Client::new_from_env();\n let result: String = \
24 client.saml().get_idp_metadata().await?;\n println!(\"{:?}\", result);\n \
25 Ok(())\n}\n```"]
26 #[tracing::instrument]
27 pub async fn get_idp_metadata<'a>(&'a self) -> Result<String, crate::types::error::Error> {
28 let mut req = self.client.client.request(
29 http::Method::GET,
30 &format!(
31 "{}/{}",
32 self.client.base_url, "platform/api/saml/idp_metadata"
33 ),
34 );
35 req = req.bearer_auth(&self.client.token);
36 let resp = req.send().await?;
37 let status = resp.status();
38 if status.is_success() {
39 let text = resp.text().await?;
40 Ok(text)
41 } else {
42 let text = resp.text().await.unwrap_or_default();
43 return Err(crate::types::error::Error::Server {
44 body: text.to_string(),
45 status,
46 });
47 }
48 }
49}