use anyhow::Result;
use crate::Client;
pub struct AuthorizationServers {
pub client: Client,
}
impl AuthorizationServers {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
AuthorizationServers { client }
}
pub async fn list(
&self,
q: &str,
limit: &str,
after: &str,
) -> Result<Vec<crate::types::AuthorizationServer>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !after.is_empty() {
query_args.push(("after".to_string(), after.to_string()));
}
if !limit.is_empty() {
query_args.push(("limit".to_string(), limit.to_string()));
}
if !q.is_empty() {
query_args.push(("q".to_string(), q.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!("/api/v1/authorizationServers?{}", query_);
self.client.get(&url, None).await
}
pub async fn list_all(&self, q: &str) -> Result<Vec<crate::types::AuthorizationServer>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !q.is_empty() {
query_args.push(("q".to_string(), q.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!("/api/v1/authorizationServers?{}", query_);
self.client.get_all_pages(&url, None).await
}
pub async fn create(
&self,
body: &crate::types::AuthorizationServer,
) -> Result<crate::types::AuthorizationServer> {
let url = "/api/v1/authorizationServers".to_string();
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn get(&self, auth_server_id: &str) -> Result<crate::types::AuthorizationServer> {
let url = format!(
"/api/v1/authorizationServers/{}",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.get(&url, None).await
}
pub async fn update(
&self,
auth_server_id: &str,
body: &crate::types::AuthorizationServer,
) -> Result<crate::types::AuthorizationServer> {
let url = format!(
"/api/v1/authorizationServers/{}",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client
.put(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn delete(&self, auth_server_id: &str) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.delete(&url, None).await
}
pub async fn list_o_auth_2_claims(
&self,
auth_server_id: &str,
) -> Result<Vec<crate::types::OAuth2Claim>> {
let url = format!(
"/api/v1/authorizationServers/{}/claims",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.get(&url, None).await
}
pub async fn list_all_o_auth_2_claims(
&self,
auth_server_id: &str,
) -> Result<Vec<crate::types::OAuth2Claim>> {
let url = format!(
"/api/v1/authorizationServers/{}/claims",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.get_all_pages(&url, None).await
}
pub async fn create_o_auth_2_claim(
&self,
auth_server_id: &str,
body: &crate::types::OAuth2Claim,
) -> Result<crate::types::OAuth2Claim> {
let url = format!(
"/api/v1/authorizationServers/{}/claims",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn get_o_auth_2_claim(
&self,
auth_server_id: &str,
claim_id: &str,
) -> Result<crate::types::OAuth2Claim> {
let url = format!(
"/api/v1/authorizationServers/{}/claims/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(claim_id),
);
self.client.get(&url, None).await
}
pub async fn update_o_auth_2_claim(
&self,
auth_server_id: &str,
claim_id: &str,
body: &crate::types::OAuth2Claim,
) -> Result<crate::types::OAuth2Claim> {
let url = format!(
"/api/v1/authorizationServers/{}/claims/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(claim_id),
);
self.client
.put(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn delete_o_auth_2_claim(&self, auth_server_id: &str, claim_id: &str) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/claims/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(claim_id),
);
self.client.delete(&url, None).await
}
pub async fn list_o_auth_2_clients_fors(
&self,
auth_server_id: &str,
) -> Result<Vec<crate::types::OAuth2Client>> {
let url = format!(
"/api/v1/authorizationServers/{}/clients",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.get(&url, None).await
}
pub async fn list_all_o_auth_2_clients_fors(
&self,
auth_server_id: &str,
) -> Result<Vec<crate::types::OAuth2Client>> {
let url = format!(
"/api/v1/authorizationServers/{}/clients",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.get_all_pages(&url, None).await
}
pub async fn list_refresh_tokens_for_and_clients(
&self,
auth_server_id: &str,
client_id: &str,
expand: &str,
after: &str,
limit: i64,
) -> Result<Vec<crate::types::OAuth2RefreshToken>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !after.is_empty() {
query_args.push(("after".to_string(), after.to_string()));
}
if !expand.is_empty() {
query_args.push(("expand".to_string(), expand.to_string()));
}
if limit > 0 {
query_args.push(("limit".to_string(), limit.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!(
"/api/v1/authorizationServers/{}/clients/{}/tokens?{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(client_id),
query_
);
self.client.get(&url, None).await
}
pub async fn list_all_refresh_tokens_for_and_clients(
&self,
auth_server_id: &str,
client_id: &str,
expand: &str,
) -> Result<Vec<crate::types::OAuth2RefreshToken>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !expand.is_empty() {
query_args.push(("expand".to_string(), expand.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!(
"/api/v1/authorizationServers/{}/clients/{}/tokens?{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(client_id),
query_
);
self.client.get_all_pages(&url, None).await
}
pub async fn revoke_refresh_tokens_for_and_client(
&self,
auth_server_id: &str,
client_id: &str,
) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/clients/{}/tokens",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(client_id),
);
self.client.delete(&url, None).await
}
pub async fn get_refresh_token_for_and_client(
&self,
auth_server_id: &str,
client_id: &str,
token_id: &str,
expand: &str,
) -> Result<crate::types::OAuth2RefreshToken> {
let mut query_args: Vec<(String, String)> = Default::default();
if !expand.is_empty() {
query_args.push(("expand".to_string(), expand.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!(
"/api/v1/authorizationServers/{}/clients/{}/tokens/{}?{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(client_id),
crate::progenitor_support::encode_path(token_id),
query_
);
self.client.get(&url, None).await
}
pub async fn revoke_refresh_token_for_and_client(
&self,
auth_server_id: &str,
client_id: &str,
token_id: &str,
) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/clients/{}/tokens/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(client_id),
crate::progenitor_support::encode_path(token_id),
);
self.client.delete(&url, None).await
}
pub async fn list_keys(&self, auth_server_id: &str) -> Result<Vec<crate::types::JsonWebKey>> {
let url = format!(
"/api/v1/authorizationServers/{}/credentials/keys",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.get(&url, None).await
}
pub async fn list_all_keys(
&self,
auth_server_id: &str,
) -> Result<Vec<crate::types::JsonWebKey>> {
let url = format!(
"/api/v1/authorizationServers/{}/credentials/keys",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.get_all_pages(&url, None).await
}
pub async fn rotate_keys(
&self,
auth_server_id: &str,
body: &crate::types::JwkUse,
) -> Result<Vec<crate::types::JsonWebKey>> {
let url = format!(
"/api/v1/authorizationServers/{}/credentials/lifecycle/keyRotate",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn activate(&self, auth_server_id: &str) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/lifecycle/activate",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.post(&url, None).await
}
pub async fn deactivate(&self, auth_server_id: &str) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/lifecycle/deactivate",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.post(&url, None).await
}
pub async fn list_policies(
&self,
auth_server_id: &str,
) -> Result<Vec<crate::types::AuthorizationServerPolicy>> {
let url = format!(
"/api/v1/authorizationServers/{}/policies",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.get(&url, None).await
}
pub async fn list_all_policies(
&self,
auth_server_id: &str,
) -> Result<Vec<crate::types::AuthorizationServerPolicy>> {
let url = format!(
"/api/v1/authorizationServers/{}/policies",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client.get_all_pages(&url, None).await
}
pub async fn create_policy(
&self,
auth_server_id: &str,
body: &crate::types::AuthorizationServerPolicy,
) -> Result<crate::types::AuthorizationServerPolicy> {
let url = format!(
"/api/v1/authorizationServers/{}/policies",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn get_policy(
&self,
auth_server_id: &str,
policy_id: &str,
) -> Result<crate::types::AuthorizationServerPolicy> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
);
self.client.get(&url, None).await
}
pub async fn update_policy(
&self,
auth_server_id: &str,
policy_id: &str,
body: &crate::types::AuthorizationServerPolicy,
) -> Result<crate::types::AuthorizationServerPolicy> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
);
self.client
.put(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn delete_policy(&self, auth_server_id: &str, policy_id: &str) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
);
self.client.delete(&url, None).await
}
pub async fn activate_policy(&self, auth_server_id: &str, policy_id: &str) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/lifecycle/activate",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
);
self.client.post(&url, None).await
}
pub async fn deactivate_policy(&self, auth_server_id: &str, policy_id: &str) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/lifecycle/deactivate",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
);
self.client.post(&url, None).await
}
pub async fn list_policy_rules(
&self,
policy_id: &str,
auth_server_id: &str,
) -> Result<Vec<crate::types::AuthorizationServerPolicyRule>> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/rules",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
);
self.client.get(&url, None).await
}
pub async fn list_all_policy_rules(
&self,
policy_id: &str,
auth_server_id: &str,
) -> Result<Vec<crate::types::AuthorizationServerPolicyRule>> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/rules",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
);
self.client.get_all_pages(&url, None).await
}
pub async fn create_policy_rule(
&self,
policy_id: &str,
auth_server_id: &str,
body: &crate::types::AuthorizationServerPolicyRule,
) -> Result<crate::types::AuthorizationServerPolicyRule> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/rules",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
);
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn get_policy_rule(
&self,
policy_id: &str,
auth_server_id: &str,
rule_id: &str,
) -> Result<crate::types::AuthorizationServerPolicyRule> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/rules/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
crate::progenitor_support::encode_path(rule_id),
);
self.client.get(&url, None).await
}
pub async fn update_policy_rule(
&self,
policy_id: &str,
auth_server_id: &str,
rule_id: &str,
body: &crate::types::AuthorizationServerPolicyRule,
) -> Result<crate::types::AuthorizationServerPolicyRule> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/rules/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
crate::progenitor_support::encode_path(rule_id),
);
self.client
.put(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn delete_policy_rule(
&self,
policy_id: &str,
auth_server_id: &str,
rule_id: &str,
) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/rules/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
crate::progenitor_support::encode_path(rule_id),
);
self.client.delete(&url, None).await
}
pub async fn activate_policy_rule(
&self,
auth_server_id: &str,
policy_id: &str,
rule_id: &str,
) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/rules/{}/lifecycle/activate",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
crate::progenitor_support::encode_path(rule_id),
);
self.client.post(&url, None).await
}
pub async fn deactivate_policy_rule(
&self,
auth_server_id: &str,
policy_id: &str,
rule_id: &str,
) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/policies/{}/rules/{}/lifecycle/deactivate",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(policy_id),
crate::progenitor_support::encode_path(rule_id),
);
self.client.post(&url, None).await
}
pub async fn list_o_auth_2_scopes(
&self,
auth_server_id: &str,
q: &str,
filter: &str,
cursor: &str,
limit: i64,
) -> Result<Vec<crate::types::OAuth2Scope>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !cursor.is_empty() {
query_args.push(("cursor".to_string(), cursor.to_string()));
}
if !filter.is_empty() {
query_args.push(("filter".to_string(), filter.to_string()));
}
if limit > 0 {
query_args.push(("limit".to_string(), limit.to_string()));
}
if !q.is_empty() {
query_args.push(("q".to_string(), q.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!(
"/api/v1/authorizationServers/{}/scopes?{}",
crate::progenitor_support::encode_path(auth_server_id),
query_
);
self.client.get(&url, None).await
}
pub async fn list_all_o_auth_2_scopes(
&self,
auth_server_id: &str,
q: &str,
filter: &str,
cursor: &str,
) -> Result<Vec<crate::types::OAuth2Scope>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !cursor.is_empty() {
query_args.push(("cursor".to_string(), cursor.to_string()));
}
if !filter.is_empty() {
query_args.push(("filter".to_string(), filter.to_string()));
}
if !q.is_empty() {
query_args.push(("q".to_string(), q.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!(
"/api/v1/authorizationServers/{}/scopes?{}",
crate::progenitor_support::encode_path(auth_server_id),
query_
);
self.client.get_all_pages(&url, None).await
}
pub async fn create_o_auth_2_scope(
&self,
auth_server_id: &str,
body: &crate::types::OAuth2Scope,
) -> Result<crate::types::OAuth2Scope> {
let url = format!(
"/api/v1/authorizationServers/{}/scopes",
crate::progenitor_support::encode_path(auth_server_id),
);
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn get_o_auth_2_scope(
&self,
auth_server_id: &str,
scope_id: &str,
) -> Result<crate::types::OAuth2Scope> {
let url = format!(
"/api/v1/authorizationServers/{}/scopes/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(scope_id),
);
self.client.get(&url, None).await
}
pub async fn update_o_auth_2_scope(
&self,
auth_server_id: &str,
scope_id: &str,
body: &crate::types::OAuth2Scope,
) -> Result<crate::types::OAuth2Scope> {
let url = format!(
"/api/v1/authorizationServers/{}/scopes/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(scope_id),
);
self.client
.put(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn delete_o_auth_2_scope(&self, auth_server_id: &str, scope_id: &str) -> Result<()> {
let url = format!(
"/api/v1/authorizationServers/{}/scopes/{}",
crate::progenitor_support::encode_path(auth_server_id),
crate::progenitor_support::encode_path(scope_id),
);
self.client.delete(&url, None).await
}
}