1use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum OrganizationSponsorshipSelfHostedOrgIdSponsoredGetError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeleteError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeletePostError {
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdFamiliesForEnterprisePostError {
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdSponsoredFriendlyNameRevokeDeleteError {
53 UnknownValue(serde_json::Value),
54}
55
56pub async fn organization_sponsorship_self_hosted_org_id_sponsored_get(
57 configuration: &configuration::Configuration,
58 org_id: uuid::Uuid,
59) -> Result<
60 models::OrganizationSponsorshipInvitesResponseModelListResponseModel,
61 Error<OrganizationSponsorshipSelfHostedOrgIdSponsoredGetError>,
62> {
63 let p_org_id = org_id;
65
66 let uri_str = format!(
67 "{}/organization/sponsorship/self-hosted/{orgId}/sponsored",
68 configuration.base_path,
69 orgId = crate::apis::urlencode(p_org_id.to_string())
70 );
71 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
72
73 if let Some(ref user_agent) = configuration.user_agent {
74 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
75 }
76 if let Some(ref token) = configuration.oauth_access_token {
77 req_builder = req_builder.bearer_auth(token.to_owned());
78 };
79
80 let req = req_builder.build()?;
81 let resp = configuration.client.execute(req).await?;
82
83 let status = resp.status();
84 let content_type = resp
85 .headers()
86 .get("content-type")
87 .and_then(|v| v.to_str().ok())
88 .unwrap_or("application/octet-stream");
89 let content_type = super::ContentType::from(content_type);
90
91 if !status.is_client_error() && !status.is_server_error() {
92 let content = resp.text().await?;
93 match content_type {
94 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
95 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationSponsorshipInvitesResponseModelListResponseModel`"))),
96 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::OrganizationSponsorshipInvitesResponseModelListResponseModel`")))),
97 }
98 } else {
99 let content = resp.text().await?;
100 let entity: Option<OrganizationSponsorshipSelfHostedOrgIdSponsoredGetError> =
101 serde_json::from_str(&content).ok();
102 Err(Error::ResponseError(ResponseContent {
103 status,
104 content,
105 entity,
106 }))
107 }
108}
109
110pub async fn organization_sponsorship_self_hosted_sponsoring_org_id_delete(
111 configuration: &configuration::Configuration,
112 sponsoring_org_id: uuid::Uuid,
113) -> Result<(), Error<OrganizationSponsorshipSelfHostedSponsoringOrgIdDeleteError>> {
114 let p_sponsoring_org_id = sponsoring_org_id;
116
117 let uri_str = format!(
118 "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}",
119 configuration.base_path,
120 sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string())
121 );
122 let mut req_builder = configuration
123 .client
124 .request(reqwest::Method::DELETE, &uri_str);
125
126 if let Some(ref user_agent) = configuration.user_agent {
127 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
128 }
129 if let Some(ref token) = configuration.oauth_access_token {
130 req_builder = req_builder.bearer_auth(token.to_owned());
131 };
132
133 let req = req_builder.build()?;
134 let resp = configuration.client.execute(req).await?;
135
136 let status = resp.status();
137
138 if !status.is_client_error() && !status.is_server_error() {
139 Ok(())
140 } else {
141 let content = resp.text().await?;
142 let entity: Option<OrganizationSponsorshipSelfHostedSponsoringOrgIdDeleteError> =
143 serde_json::from_str(&content).ok();
144 Err(Error::ResponseError(ResponseContent {
145 status,
146 content,
147 entity,
148 }))
149 }
150}
151
152pub async fn organization_sponsorship_self_hosted_sponsoring_org_id_delete_post(
153 configuration: &configuration::Configuration,
154 sponsoring_org_id: uuid::Uuid,
155) -> Result<(), Error<OrganizationSponsorshipSelfHostedSponsoringOrgIdDeletePostError>> {
156 let p_sponsoring_org_id = sponsoring_org_id;
158
159 let uri_str = format!(
160 "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/delete",
161 configuration.base_path,
162 sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string())
163 );
164 let mut req_builder = configuration
165 .client
166 .request(reqwest::Method::POST, &uri_str);
167
168 if let Some(ref user_agent) = configuration.user_agent {
169 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
170 }
171 if let Some(ref token) = configuration.oauth_access_token {
172 req_builder = req_builder.bearer_auth(token.to_owned());
173 };
174
175 let req = req_builder.build()?;
176 let resp = configuration.client.execute(req).await?;
177
178 let status = resp.status();
179
180 if !status.is_client_error() && !status.is_server_error() {
181 Ok(())
182 } else {
183 let content = resp.text().await?;
184 let entity: Option<OrganizationSponsorshipSelfHostedSponsoringOrgIdDeletePostError> =
185 serde_json::from_str(&content).ok();
186 Err(Error::ResponseError(ResponseContent {
187 status,
188 content,
189 entity,
190 }))
191 }
192}
193
194pub async fn organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post(
195 configuration: &configuration::Configuration,
196 sponsoring_org_id: uuid::Uuid,
197 organization_sponsorship_create_request_model: Option<
198 models::OrganizationSponsorshipCreateRequestModel,
199 >,
200) -> Result<(), Error<OrganizationSponsorshipSelfHostedSponsoringOrgIdFamiliesForEnterprisePostError>>
201{
202 let p_sponsoring_org_id = sponsoring_org_id;
204 let p_organization_sponsorship_create_request_model =
205 organization_sponsorship_create_request_model;
206
207 let uri_str = format!(
208 "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/families-for-enterprise",
209 configuration.base_path,
210 sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string())
211 );
212 let mut req_builder = configuration
213 .client
214 .request(reqwest::Method::POST, &uri_str);
215
216 if let Some(ref user_agent) = configuration.user_agent {
217 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
218 }
219 if let Some(ref token) = configuration.oauth_access_token {
220 req_builder = req_builder.bearer_auth(token.to_owned());
221 };
222 req_builder = req_builder.json(&p_organization_sponsorship_create_request_model);
223
224 let req = req_builder.build()?;
225 let resp = configuration.client.execute(req).await?;
226
227 let status = resp.status();
228
229 if !status.is_client_error() && !status.is_server_error() {
230 Ok(())
231 } else {
232 let content = resp.text().await?;
233 let entity: Option<
234 OrganizationSponsorshipSelfHostedSponsoringOrgIdFamiliesForEnterprisePostError,
235 > = serde_json::from_str(&content).ok();
236 Err(Error::ResponseError(ResponseContent {
237 status,
238 content,
239 entity,
240 }))
241 }
242}
243
244pub async fn organization_sponsorship_self_hosted_sponsoring_org_id_sponsored_friendly_name_revoke_delete(
245 configuration: &configuration::Configuration,
246 sponsoring_org_id: uuid::Uuid,
247 sponsored_friendly_name: &str,
248) -> Result<
249 (),
250 Error<OrganizationSponsorshipSelfHostedSponsoringOrgIdSponsoredFriendlyNameRevokeDeleteError>,
251> {
252 let p_sponsoring_org_id = sponsoring_org_id;
254 let p_sponsored_friendly_name = sponsored_friendly_name;
255
256 let uri_str = format!(
257 "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/{sponsoredFriendlyName}/revoke",
258 configuration.base_path,
259 sponsoringOrgId = crate::apis::urlencode(p_sponsoring_org_id.to_string()),
260 sponsoredFriendlyName = crate::apis::urlencode(p_sponsored_friendly_name)
261 );
262 let mut req_builder = configuration
263 .client
264 .request(reqwest::Method::DELETE, &uri_str);
265
266 if let Some(ref user_agent) = configuration.user_agent {
267 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
268 }
269 if let Some(ref token) = configuration.oauth_access_token {
270 req_builder = req_builder.bearer_auth(token.to_owned());
271 };
272
273 let req = req_builder.build()?;
274 let resp = configuration.client.execute(req).await?;
275
276 let status = resp.status();
277
278 if !status.is_client_error() && !status.is_server_error() {
279 Ok(())
280 } else {
281 let content = resp.text().await?;
282 let entity: Option<
283 OrganizationSponsorshipSelfHostedSponsoringOrgIdSponsoredFriendlyNameRevokeDeleteError,
284 > = serde_json::from_str(&content).ok();
285 Err(Error::ResponseError(ResponseContent {
286 status,
287 content,
288 entity,
289 }))
290 }
291}