1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
use super::ResponseValue;
use crate::{
AuthorizationContext, PrivySignedApiError, generate_authorization_signatures,
generated::types::{Policy, UpdatePolicyBody, UpdatePolicyPolicyId},
subclients::PoliciesClient,
};
impl PoliciesClient {
/// Update a policy
///
/// # Errors
///
/// Can fail either if the authorization signature could not be generated,
/// or if the api call fails whether than be due to network issues, auth problems,
/// or the Privy API returning an error.
pub async fn update<'a>(
&'a self,
policy_id: &'a UpdatePolicyPolicyId,
ctx: &'a AuthorizationContext,
body: &'a UpdatePolicyBody,
) -> Result<ResponseValue<Policy>, PrivySignedApiError> {
let sig = generate_authorization_signatures(
ctx,
&self.app_id,
crate::Method::PATCH,
format!("{}/v1/policies/{}", self.base_url, policy_id.as_str()),
body,
None,
)
.await?;
Ok(self._update(policy_id, Some(&sig), body).await?)
}
/// Delete a policy
///
/// # Errors
///
/// Can fail either if the authorization signature could not be generated,
/// or if the api call fails whether than be due to network issues, auth problems,
/// or the Privy API returning an error.
pub async fn delete<'a>(
&'a self,
policy_id: &'a crate::generated::types::DeletePolicyPolicyId,
ctx: &'a AuthorizationContext,
) -> Result<ResponseValue<crate::generated::types::DeletePolicyResponse>, PrivySignedApiError>
{
let sig = generate_authorization_signatures(
ctx,
&self.app_id,
crate::Method::DELETE,
format!("{}/v1/policies/{}", self.base_url, policy_id.as_str()),
&serde_json::json!({}),
None,
)
.await?;
Ok(self._delete(policy_id, Some(&sig)).await?)
}
/// Create a rule for a policy
///
/// # Errors
///
/// Can fail either if the authorization signature could not be generated,
/// or if the api call fails whether than be due to network issues, auth problems,
/// or the Privy API returning an error.
pub async fn create_rule<'a>(
&'a self,
policy_id: &'a crate::generated::types::CreateRulePolicyId,
ctx: &'a AuthorizationContext,
body: &'a crate::generated::types::PolicyRuleRequestBody,
) -> Result<ResponseValue<crate::generated::types::PolicyRuleResponse>, PrivySignedApiError>
{
let sig = generate_authorization_signatures(
ctx,
&self.app_id,
crate::Method::POST,
format!("{}/v1/policies/{}/rules", self.base_url, policy_id.as_str()),
body,
None,
)
.await?;
Ok(self._create_rule(policy_id, Some(&sig), body).await?)
}
/// Update a rule for a policy
///
/// # Errors
///
/// Can fail either if the authorization signature could not be generated,
/// or if the api call fails whether than be due to network issues, auth problems,
/// or the Privy API returning an error.
pub async fn update_rule<'a>(
&'a self,
policy_id: &'a crate::generated::types::UpdateRulePolicyId,
rule_id: &'a crate::generated::types::UpdateRuleRuleId,
ctx: &'a AuthorizationContext,
body: &'a crate::generated::types::PolicyRuleRequestBody,
) -> Result<ResponseValue<crate::generated::types::UpdateRuleResponse>, PrivySignedApiError>
{
let sig = generate_authorization_signatures(
ctx,
&self.app_id,
crate::Method::PATCH,
format!(
"{}/v1/policies/{}/rules/{}",
self.base_url,
policy_id.as_str(),
rule_id.as_str()
),
body,
None,
)
.await?;
Ok(self
._update_rule(policy_id, rule_id, Some(&sig), body)
.await?)
}
/// Delete a rule for a policy
///
/// # Errors
///
/// Can fail either if the authorization signature could not be generated,
/// or if the api call fails whether than be due to network issues, auth problems,
/// or the Privy API returning an error.
pub async fn delete_rule<'a>(
&'a self,
policy_id: &'a crate::generated::types::DeleteRulePolicyId,
rule_id: &'a crate::generated::types::DeleteRuleRuleId,
ctx: &'a AuthorizationContext,
) -> Result<ResponseValue<crate::generated::types::DeleteRuleResponse>, PrivySignedApiError>
{
let sig = generate_authorization_signatures(
ctx,
&self.app_id,
crate::Method::DELETE,
format!(
"{}/v1/policies/{}/rules/{}",
self.base_url,
policy_id.as_str(),
rule_id.as_str()
),
&serde_json::json!({}),
None,
)
.await?;
Ok(self._delete_rule(policy_id, rule_id, Some(&sig)).await?)
}
}