diff --git a/examples/openapi.rs b/examples/openapi.rs index e332968..20a3dec 100644 --- a/examples/openapi.rs +++ b/examples/openapi.rs @@ -251,10 +251,18 @@ mod openapi { let mut path_snake_case = path.to_string(); - let parameters = parameters + let call_parameters = parameters.into_iter().flatten().collect::>(); + + let parameters = call_parameters + .clone() .into_iter() - .chain(self.parameters.as_deref()) - .flatten() + .chain( + self.parameters + .as_deref() + .into_iter() + .flatten() + .filter(|p| !call_parameters.iter().any(|cp| cp.name == p.name)), + ) .map(|parameter| { let mut param_name = parameter.name.to_snake_case(); while RESERVED_WORDS.contains(¶m_name.as_str()) { @@ -310,7 +318,7 @@ mod openapi { output.extend(comments); - if let [tag] = self.tags.as_deref().unwrap_or_else(|| &[]) { + if let [tag] = self.tags.as_deref().unwrap_or(&[]) { use heck::ToKebabCase; let tag = tag.to_kebab_case(); output.push(format!(r#"#[cfg(feature = "tag-{tag}")]"#)); @@ -347,7 +355,7 @@ mod openapi { let param_type = if let Some(desc) = desc.as_ref() { let from_type = desc.from_type.as_str(); if from_type != param_type { - let redundant = ¶m_type == &desc.rust_type; + let redundant = param_type == desc.rust_type; let full_header = format!(r#"[path."{path}:{method_string_lc}:{param_name}"]"#); if redundant { delete_mapping(&full_header); @@ -381,7 +389,7 @@ mod openapi { if let Some(desc) = desc.as_ref() { let from_type = desc.from_type.as_str(); if from_type != result_type_value { - let redundant = result_type_value == &desc.rust_type; + let redundant = result_type_value == desc.rust_type; let full_header = format!(r#"[path."{path}:{method_string_lc}:"]"#); if redundant { delete_mapping(&full_header); @@ -460,7 +468,7 @@ mod openapi { )); if let Some(ReturnType { body, convert, .. }) = result_type.as_ref() { - let body = body.as_deref().unwrap_or_else(|| "json".into()); + let body = body.as_deref().unwrap_or("json"); output.push(" let response = builder.send().await?;".into()); output.push(format!( " Ok(error_check(response).await?.{body}().await{}?)", @@ -487,7 +495,7 @@ mod openapi { fn comments( &self, - parameters: &Vec<(&Parameter, String)>, + parameters: &[(&Parameter, String)], method_string: String, path: &str, path_snake_case: &String, @@ -530,7 +538,7 @@ mod openapi { if to_id { comments.push(vec!["Returns id of created resource".into()]); } - if let [tag] = self.tags.as_deref().unwrap_or_else(|| &[]) { + if let [tag] = self.tags.as_deref().unwrap_or(&[]) { comments.push(vec![format!("Resource: `{tag}`").into()]); } comments.push(vec![format!( @@ -598,11 +606,9 @@ mod openapi { } else { acc.push(x); } - } else { - if x.starts_with("[path.") { - in_header = false; - acc.push(x); - } + } else if x.starts_with("[path.") { + in_header = false; + acc.push(x); } acc }) @@ -1100,6 +1106,7 @@ impl KeycloakAdmin {{ "### ); let mut path_counts = spec.paths.len(); + let default = std::borrow::Cow::from("default"); let tag_paths = spec .tags .iter() @@ -1118,6 +1125,20 @@ impl KeycloakAdmin {{ .collect::>(), ) }) + .chain([( + &default, + spec.paths + .iter() + .filter(|(_, path_spec)| { + path_spec.calls.iter().all(|(_, call)| { + call.tags + .as_ref() + .map(|tags| tags.is_empty()) + .unwrap_or(true) + }) + }) + .collect(), + )]) .collect::>(); for (tag, paths) in tag_paths { println!(" //

{tag}

\n"); diff --git a/src/rest/generated_rest.rs b/src/rest/generated_rest.rs index 73a0b45..caf314e 100644 --- a/src/rest/generated_rest.rs +++ b/src/rest/generated_rest.rs @@ -10885,6 +10885,1547 @@ impl KeycloakAdmin { let response = builder.send().await?; Ok(error_check(response).await?.json().await?) } + + //

default

+ + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server` + pub async fn realm_clients_with_client_uuid_authz_resource_server_get( + &self, + realm: &str, + client_uuid: &str, + ) -> Result { + let builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + Ok(error_check(response).await?.json().await?) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `body` + /// + /// `PUT /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server` + /// + /// Documentation: + /// + /// REST method: `PUT /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server` + pub async fn realm_clients_with_client_uuid_authz_resource_server_put( + &self, + realm: &str, + client_uuid: &str, + body: ResourceServerRepresentation, + ) -> Result<(), KeycloakError> { + let builder = self + .client + .put(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `body` + /// + /// Returns id of created resource + /// + /// `POST /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/import` + /// + /// Documentation: + /// + /// REST method: `POST /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/import` + pub async fn realm_clients_with_client_uuid_authz_resource_server_import_post( + &self, + realm: &str, + client_uuid: &str, + body: ResourceServerRepresentation, + ) -> Result, KeycloakError> { + let builder = self + .client + .post(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/import", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await.map(to_id) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `fields` + /// - `first` + /// - `max` + /// - `name` + /// - `owner` + /// - `permission` + /// - `policy_id` + /// - `resource` + /// - `scope` + /// - `type_` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/permission` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_permission_get( + &self, + realm: &str, + client_uuid: &str, + fields: Option, + first: Option, + max: Option, + name: Option, + owner: Option, + permission: Option, + policy_id: Option, + resource: Option, + scope: Option, + type_: Option, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = fields { + builder = builder.query(&[("fields", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = permission { + builder = builder.query(&[("permission", v)]); + } + if let Some(v) = policy_id { + builder = builder.query(&[("policyId", v)]); + } + if let Some(v) = resource { + builder = builder.query(&[("resource", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `body` + /// + /// Returns id of created resource + /// + /// `POST /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission` + /// + /// Documentation: + /// + /// REST method: `POST /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/permission` + pub async fn realm_clients_with_client_uuid_authz_resource_server_permission_post( + &self, + realm: &str, + client_uuid: &str, + body: String, + ) -> Result, KeycloakError> { + let builder = self + .client + .post(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await.map(to_id) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `body` + /// + /// Returns id of created resource + /// + /// `POST /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission/evaluate` + /// + /// Documentation: + /// + /// REST method: `POST /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/permission/evaluate` + pub async fn realm_clients_with_client_uuid_authz_resource_server_permission_evaluate_post( + &self, + realm: &str, + client_uuid: &str, + body: PolicyEvaluationRequest, + ) -> Result, KeycloakError> { + let builder = self + .client + .post(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission/evaluate", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await.map(to_id) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission/providers` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/permission/providers` + pub async fn realm_clients_with_client_uuid_authz_resource_server_permission_providers_get( + &self, + realm: &str, + client_uuid: &str, + ) -> Result, KeycloakError> { + let builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission/providers", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + Ok(error_check(response).await?.json().await?) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `fields` + /// - `name` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission/search` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/permission/search` + pub async fn realm_clients_with_client_uuid_authz_resource_server_permission_search_get( + &self, + realm: &str, + client_uuid: &str, + fields: Option, + name: Option, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/permission/search", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = fields { + builder = builder.query(&[("fields", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `fields` + /// - `first` + /// - `max` + /// - `name` + /// - `owner` + /// - `permission` + /// - `policy_id` + /// - `resource` + /// - `scope` + /// - `type_` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/policy` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_policy_get( + &self, + realm: &str, + client_uuid: &str, + fields: Option, + first: Option, + max: Option, + name: Option, + owner: Option, + permission: Option, + policy_id: Option, + resource: Option, + scope: Option, + type_: Option, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = fields { + builder = builder.query(&[("fields", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = permission { + builder = builder.query(&[("permission", v)]); + } + if let Some(v) = policy_id { + builder = builder.query(&[("policyId", v)]); + } + if let Some(v) = resource { + builder = builder.query(&[("resource", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `body` + /// + /// Returns id of created resource + /// + /// `POST /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy` + /// + /// Documentation: + /// + /// REST method: `POST /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/policy` + pub async fn realm_clients_with_client_uuid_authz_resource_server_policy_post( + &self, + realm: &str, + client_uuid: &str, + body: String, + ) -> Result, KeycloakError> { + let builder = self + .client + .post(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await.map(to_id) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `body` + /// + /// Returns id of created resource + /// + /// `POST /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy/evaluate` + /// + /// Documentation: + /// + /// REST method: `POST /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/policy/evaluate` + pub async fn realm_clients_with_client_uuid_authz_resource_server_policy_evaluate_post( + &self, + realm: &str, + client_uuid: &str, + body: PolicyEvaluationRequest, + ) -> Result, KeycloakError> { + let builder = self + .client + .post(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy/evaluate", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await.map(to_id) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy/providers` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/policy/providers` + pub async fn realm_clients_with_client_uuid_authz_resource_server_policy_providers_get( + &self, + realm: &str, + client_uuid: &str, + ) -> Result, KeycloakError> { + let builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy/providers", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + Ok(error_check(response).await?.json().await?) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `fields` + /// - `name` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy/search` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/policy/search` + pub async fn realm_clients_with_client_uuid_authz_resource_server_policy_search_get( + &self, + realm: &str, + client_uuid: &str, + fields: Option, + name: Option, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/policy/search", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = fields { + builder = builder.query(&[("fields", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `id` + /// - `deep` + /// - `exact_name` + /// - `first` + /// - `matching_uri` + /// - `max` + /// - `name` + /// - `owner` + /// - `scope` + /// - `type_` + /// - `uri` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/resource` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_resource_get( + &self, + realm: &str, + client_uuid: &str, + id: Option, + deep: Option, + exact_name: Option, + first: Option, + matching_uri: Option, + max: Option, + name: Option, + owner: Option, + scope: Option, + type_: Option, + uri: Option, + ) -> Result, KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = id { + builder = builder.query(&[("_id", v)]); + } + if let Some(v) = deep { + builder = builder.query(&[("deep", v)]); + } + if let Some(v) = exact_name { + builder = builder.query(&[("exactName", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = matching_uri { + builder = builder.query(&[("matchingUri", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + if let Some(v) = uri { + builder = builder.query(&[("uri", v)]); + } + let response = builder.send().await?; + Ok(error_check(response).await?.json().await?) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `id` + /// - `deep` + /// - `exact_name` + /// - `first` + /// - `matching_uri` + /// - `max` + /// - `name` + /// - `owner` + /// - `scope` + /// - `type_` + /// - `uri` + /// - `body` + /// + /// Returns id of created resource + /// + /// `POST /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource` + /// + /// Documentation: + /// + /// REST method: `POST /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/resource` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_resource_post( + &self, + realm: &str, + client_uuid: &str, + id: Option, + deep: Option, + exact_name: Option, + first: Option, + matching_uri: Option, + max: Option, + name: Option, + owner: Option, + scope: Option, + type_: Option, + uri: Option, + body: ResourceRepresentation, + ) -> Result, KeycloakError> { + let mut builder = self + .client + .post(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = id { + builder = builder.query(&[("_id", v)]); + } + if let Some(v) = deep { + builder = builder.query(&[("deep", v)]); + } + if let Some(v) = exact_name { + builder = builder.query(&[("exactName", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = matching_uri { + builder = builder.query(&[("matchingUri", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + if let Some(v) = uri { + builder = builder.query(&[("uri", v)]); + } + let response = builder.send().await?; + error_check(response).await.map(to_id) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `id` + /// - `deep` + /// - `exact_name` + /// - `first` + /// - `matching_uri` + /// - `max` + /// - `name` + /// - `owner` + /// - `scope` + /// - `type_` + /// - `uri` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/search` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/resource/search` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_resource_search_get( + &self, + realm: &str, + client_uuid: &str, + id: Option, + deep: Option, + exact_name: Option, + first: Option, + matching_uri: Option, + max: Option, + name: Option, + owner: Option, + scope: Option, + type_: Option, + uri: Option, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/search", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = id { + builder = builder.query(&[("_id", v)]); + } + if let Some(v) = deep { + builder = builder.query(&[("deep", v)]); + } + if let Some(v) = exact_name { + builder = builder.query(&[("exactName", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = matching_uri { + builder = builder.query(&[("matchingUri", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + if let Some(v) = uri { + builder = builder.query(&[("uri", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `id` + /// - `deep` + /// - `exact_name` + /// - `first` + /// - `matching_uri` + /// - `max` + /// - `name` + /// - `owner` + /// - `scope` + /// - `type_` + /// - `uri` + /// - `resource_id` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/resource/{resource-id}` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_resource_with_resource_id_get( + &self, + realm: &str, + client_uuid: &str, + id: Option, + deep: Option, + exact_name: Option, + first: Option, + matching_uri: Option, + max: Option, + name: Option, + owner: Option, + scope: Option, + type_: Option, + uri: Option, + resource_id: &str, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = id { + builder = builder.query(&[("_id", v)]); + } + if let Some(v) = deep { + builder = builder.query(&[("deep", v)]); + } + if let Some(v) = exact_name { + builder = builder.query(&[("exactName", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = matching_uri { + builder = builder.query(&[("matchingUri", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + if let Some(v) = uri { + builder = builder.query(&[("uri", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `id` + /// - `deep` + /// - `exact_name` + /// - `first` + /// - `matching_uri` + /// - `max` + /// - `name` + /// - `owner` + /// - `scope` + /// - `type_` + /// - `uri` + /// - `resource_id` + /// - `body` + /// + /// `PUT /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}` + /// + /// Documentation: + /// + /// REST method: `PUT /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/resource/{resource-id}` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_resource_with_resource_id_put( + &self, + realm: &str, + client_uuid: &str, + id: Option, + deep: Option, + exact_name: Option, + first: Option, + matching_uri: Option, + max: Option, + name: Option, + owner: Option, + scope: Option, + type_: Option, + uri: Option, + resource_id: &str, + body: ResourceRepresentation, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .put(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = id { + builder = builder.query(&[("_id", v)]); + } + if let Some(v) = deep { + builder = builder.query(&[("deep", v)]); + } + if let Some(v) = exact_name { + builder = builder.query(&[("exactName", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = matching_uri { + builder = builder.query(&[("matchingUri", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + if let Some(v) = uri { + builder = builder.query(&[("uri", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `id` + /// - `deep` + /// - `exact_name` + /// - `first` + /// - `matching_uri` + /// - `max` + /// - `name` + /// - `owner` + /// - `scope` + /// - `type_` + /// - `uri` + /// - `resource_id` + /// + /// `DELETE /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}` + /// + /// Documentation: + /// + /// REST method: `DELETE /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/resource/{resource-id}` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_resource_with_resource_id_delete( + &self, + realm: &str, + client_uuid: &str, + id: Option, + deep: Option, + exact_name: Option, + first: Option, + matching_uri: Option, + max: Option, + name: Option, + owner: Option, + scope: Option, + type_: Option, + uri: Option, + resource_id: &str, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .delete(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = id { + builder = builder.query(&[("_id", v)]); + } + if let Some(v) = deep { + builder = builder.query(&[("deep", v)]); + } + if let Some(v) = exact_name { + builder = builder.query(&[("exactName", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = matching_uri { + builder = builder.query(&[("matchingUri", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + if let Some(v) = uri { + builder = builder.query(&[("uri", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `id` + /// - `deep` + /// - `exact_name` + /// - `first` + /// - `matching_uri` + /// - `max` + /// - `name` + /// - `owner` + /// - `scope` + /// - `type_` + /// - `uri` + /// - `resource_id` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}/attributes` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/resource/{resource-id}/attributes` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_resource_with_resource_id_attributes_get( + &self, + realm: &str, + client_uuid: &str, + id: Option, + deep: Option, + exact_name: Option, + first: Option, + matching_uri: Option, + max: Option, + name: Option, + owner: Option, + scope: Option, + type_: Option, + uri: Option, + resource_id: &str, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}/attributes", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = id { + builder = builder.query(&[("_id", v)]); + } + if let Some(v) = deep { + builder = builder.query(&[("deep", v)]); + } + if let Some(v) = exact_name { + builder = builder.query(&[("exactName", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = matching_uri { + builder = builder.query(&[("matchingUri", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + if let Some(v) = uri { + builder = builder.query(&[("uri", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `id` + /// - `deep` + /// - `exact_name` + /// - `first` + /// - `matching_uri` + /// - `max` + /// - `name` + /// - `owner` + /// - `scope` + /// - `type_` + /// - `uri` + /// - `resource_id` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}/permissions` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/resource/{resource-id}/permissions` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_resource_with_resource_id_permissions_get( + &self, + realm: &str, + client_uuid: &str, + id: Option, + deep: Option, + exact_name: Option, + first: Option, + matching_uri: Option, + max: Option, + name: Option, + owner: Option, + scope: Option, + type_: Option, + uri: Option, + resource_id: &str, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}/permissions", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = id { + builder = builder.query(&[("_id", v)]); + } + if let Some(v) = deep { + builder = builder.query(&[("deep", v)]); + } + if let Some(v) = exact_name { + builder = builder.query(&[("exactName", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = matching_uri { + builder = builder.query(&[("matchingUri", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + if let Some(v) = uri { + builder = builder.query(&[("uri", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `id` + /// - `deep` + /// - `exact_name` + /// - `first` + /// - `matching_uri` + /// - `max` + /// - `name` + /// - `owner` + /// - `scope` + /// - `type_` + /// - `uri` + /// - `resource_id` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}/scopes` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/resource/{resource-id}/scopes` + #[allow(clippy::too_many_arguments)] + pub async fn realm_clients_with_client_uuid_authz_resource_server_resource_with_resource_id_scopes_get( + &self, + realm: &str, + client_uuid: &str, + id: Option, + deep: Option, + exact_name: Option, + first: Option, + matching_uri: Option, + max: Option, + name: Option, + owner: Option, + scope: Option, + type_: Option, + uri: Option, + resource_id: &str, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/resource/{resource_id}/scopes", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = id { + builder = builder.query(&[("_id", v)]); + } + if let Some(v) = deep { + builder = builder.query(&[("deep", v)]); + } + if let Some(v) = exact_name { + builder = builder.query(&[("exactName", v)]); + } + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = matching_uri { + builder = builder.query(&[("matchingUri", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = owner { + builder = builder.query(&[("owner", v)]); + } + if let Some(v) = scope { + builder = builder.query(&[("scope", v)]); + } + if let Some(v) = type_ { + builder = builder.query(&[("type", v)]); + } + if let Some(v) = uri { + builder = builder.query(&[("uri", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `first` + /// - `max` + /// - `name` + /// - `scope_id` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/scope` + pub async fn realm_clients_with_client_uuid_authz_resource_server_scope_get( + &self, + realm: &str, + client_uuid: &str, + first: Option, + max: Option, + name: Option, + scope_id: Option, + ) -> Result, KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = first { + builder = builder.query(&[("first", v)]); + } + if let Some(v) = max { + builder = builder.query(&[("max", v)]); + } + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + if let Some(v) = scope_id { + builder = builder.query(&[("scopeId", v)]); + } + let response = builder.send().await?; + Ok(error_check(response).await?.json().await?) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `body` + /// + /// Returns id of created resource + /// + /// `POST /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope` + /// + /// Documentation: + /// + /// REST method: `POST /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/scope` + pub async fn realm_clients_with_client_uuid_authz_resource_server_scope_post( + &self, + realm: &str, + client_uuid: &str, + body: ScopeRepresentation, + ) -> Result, KeycloakError> { + let builder = self + .client + .post(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await.map(to_id) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `name` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/search` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/scope/search` + pub async fn realm_clients_with_client_uuid_authz_resource_server_scope_search_get( + &self, + realm: &str, + client_uuid: &str, + name: Option, + ) -> Result<(), KeycloakError> { + let mut builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/search", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + if let Some(v) = name { + builder = builder.query(&[("name", v)]); + } + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `scope_id` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/scope/{scope-id}` + pub async fn realm_clients_with_client_uuid_authz_resource_server_scope_with_scope_id_get( + &self, + realm: &str, + client_uuid: &str, + scope_id: &str, + ) -> Result<(), KeycloakError> { + let builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `scope_id` + /// - `body` + /// + /// `PUT /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}` + /// + /// Documentation: + /// + /// REST method: `PUT /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/scope/{scope-id}` + pub async fn realm_clients_with_client_uuid_authz_resource_server_scope_with_scope_id_put( + &self, + realm: &str, + client_uuid: &str, + scope_id: &str, + body: ScopeRepresentation, + ) -> Result<(), KeycloakError> { + let builder = self + .client + .put(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}", + self.url + )) + .json(&body) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `scope_id` + /// + /// `DELETE /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}` + /// + /// Documentation: + /// + /// REST method: `DELETE /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/scope/{scope-id}` + pub async fn realm_clients_with_client_uuid_authz_resource_server_scope_with_scope_id_delete( + &self, + realm: &str, + client_uuid: &str, + scope_id: &str, + ) -> Result<(), KeycloakError> { + let builder = self + .client + .delete(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `scope_id` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}/permissions` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/scope/{scope-id}/permissions` + pub async fn realm_clients_with_client_uuid_authz_resource_server_scope_with_scope_id_permissions_get( + &self, + realm: &str, + client_uuid: &str, + scope_id: &str, + ) -> Result<(), KeycloakError> { + let builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}/permissions", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// - `scope_id` + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}/resources` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/scope/{scope-id}/resources` + pub async fn realm_clients_with_client_uuid_authz_resource_server_scope_with_scope_id_resources_get( + &self, + realm: &str, + client_uuid: &str, + scope_id: &str, + ) -> Result<(), KeycloakError> { + let builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/scope/{scope_id}/resources", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + error_check(response).await?; + Ok(()) + } + + /// Parameters: + /// + /// - `realm`: realm name (not id!) + /// - `client_uuid`: id of client (not client-id!) + /// + /// `GET /admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/settings` + /// + /// Documentation: + /// + /// REST method: `GET /admin/realms/{realm}/clients/{client-uuid}/authz/resource-server/settings` + pub async fn realm_clients_with_client_uuid_authz_resource_server_settings_get( + &self, + realm: &str, + client_uuid: &str, + ) -> Result { + let builder = self + .client + .get(&format!( + "{}/admin/realms/{realm}/clients/{client_uuid}/authz/resource-server/settings", + self.url + )) + .bearer_auth(self.token_supplier.get(&self.url).await?); + let response = builder.send().await?; + Ok(error_check(response).await?.json().await?) + } } -// not all paths processed -// left 22