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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
use anyhow::Result; use crate::Client; pub struct Interactions { client: Client, } impl Interactions { #[doc(hidden)] pub fn new(client: Client) -> Self { Interactions { client } } /** * Get interaction restrictions for an organization. * * This function performs a `GET` to the `/orgs/{org}/interaction-limits` endpoint. * * Shows which type of GitHub user can interact with this organization and when the restriction expires. If there is no restrictions, you will see an empty response. * * FROM: <https://docs.github.com/rest/reference/interactions#get-interaction-restrictions-for-an-organization> * * **Parameters:** * * * `org: &str` */ pub async fn get_restrictions_for_org( &self, org: &str, ) -> Result<crate::types::InteractionLimits> { let url = format!( "/orgs/{}/interaction-limits", crate::progenitor_support::encode_path(&org.to_string()), ); self.client.get(&url, None).await } /** * Set interaction restrictions for an organization. * * This function performs a `PUT` to the `/orgs/{org}/interaction-limits` endpoint. * * Temporarily restricts interactions to a certain type of GitHub user in any public repository in the given organization. You must be an organization owner to set these restrictions. Setting the interaction limit at the organization level will overwrite any interaction limits that are set for individual repositories owned by the organization. * * FROM: <https://docs.github.com/rest/reference/interactions#set-interaction-restrictions-for-an-organization> * * **Parameters:** * * * `org: &str` */ pub async fn set_restrictions_for_org( &self, org: &str, body: &crate::types::InteractionLimit, ) -> Result<crate::types::InteractionLimits> { let url = format!( "/orgs/{}/interaction-limits", crate::progenitor_support::encode_path(&org.to_string()), ); self.client .put( &url, Some(reqwest::Body::from(serde_json::to_vec(body).unwrap())), ) .await } /** * Remove interaction restrictions for an organization. * * This function performs a `DELETE` to the `/orgs/{org}/interaction-limits` endpoint. * * Removes all interaction restrictions from public repositories in the given organization. You must be an organization owner to remove restrictions. * * FROM: <https://docs.github.com/rest/reference/interactions#remove-interaction-restrictions-for-an-organization> * * **Parameters:** * * * `org: &str` */ pub async fn remove_restrictions_for_org(&self, org: &str) -> Result<()> { let url = format!( "/orgs/{}/interaction-limits", crate::progenitor_support::encode_path(&org.to_string()), ); self.client.delete(&url, None).await } /** * Get interaction restrictions for a repository. * * This function performs a `GET` to the `/repos/{owner}/{repo}/interaction-limits` endpoint. * * Shows which type of GitHub user can interact with this repository and when the restriction expires. If there are no restrictions, you will see an empty response. * * FROM: <https://docs.github.com/rest/reference/interactions#get-interaction-restrictions-for-a-repository> * * **Parameters:** * * * `owner: &str` * * `repo: &str` */ pub async fn get_restrictions_for_repo( &self, owner: &str, repo: &str, ) -> Result<crate::types::InteractionLimits> { let url = format!( "/repos/{}/{}/interaction-limits", crate::progenitor_support::encode_path(&owner.to_string()), crate::progenitor_support::encode_path(&repo.to_string()), ); self.client.get(&url, None).await } /** * Set interaction restrictions for a repository. * * This function performs a `PUT` to the `/repos/{owner}/{repo}/interaction-limits` endpoint. * * Temporarily restricts interactions to a certain type of GitHub user within the given repository. You must have owner or admin access to set these restrictions. If an interaction limit is set for the user or organization that owns this repository, you will receive a `409 Conflict` response and will not be able to use this endpoint to change the interaction limit for a single repository. * * FROM: <https://docs.github.com/rest/reference/interactions#set-interaction-restrictions-for-a-repository> * * **Parameters:** * * * `owner: &str` * * `repo: &str` */ pub async fn set_restrictions_for_repo( &self, owner: &str, repo: &str, body: &crate::types::InteractionLimit, ) -> Result<crate::types::InteractionLimits> { let url = format!( "/repos/{}/{}/interaction-limits", crate::progenitor_support::encode_path(&owner.to_string()), crate::progenitor_support::encode_path(&repo.to_string()), ); self.client .put( &url, Some(reqwest::Body::from(serde_json::to_vec(body).unwrap())), ) .await } /** * Remove interaction restrictions for a repository. * * This function performs a `DELETE` to the `/repos/{owner}/{repo}/interaction-limits` endpoint. * * Removes all interaction restrictions from the given repository. You must have owner or admin access to remove restrictions. If the interaction limit is set for the user or organization that owns this repository, you will receive a `409 Conflict` response and will not be able to use this endpoint to change the interaction limit for a single repository. * * FROM: <https://docs.github.com/rest/reference/interactions#remove-interaction-restrictions-for-a-repository> * * **Parameters:** * * * `owner: &str` * * `repo: &str` */ pub async fn remove_restrictions_for_repo(&self, owner: &str, repo: &str) -> Result<()> { let url = format!( "/repos/{}/{}/interaction-limits", crate::progenitor_support::encode_path(&owner.to_string()), crate::progenitor_support::encode_path(&repo.to_string()), ); self.client.delete(&url, None).await } /** * Get interaction restrictions for your public repositories. * * This function performs a `GET` to the `/user/interaction-limits` endpoint. * * Shows which type of GitHub user can interact with your public repositories and when the restriction expires. * * FROM: <https://docs.github.com/rest/reference/interactions#get-interaction-restrictions-for-your-public-repositories> */ pub async fn get_restrictions_for_authenticated_user( &self, ) -> Result<crate::types::InteractionLimits> { let url = "/user/interaction-limits".to_string(); self.client.get(&url, None).await } /** * Set interaction restrictions for your public repositories. * * This function performs a `PUT` to the `/user/interaction-limits` endpoint. * * Temporarily restricts which type of GitHub user can interact with your public repositories. Setting the interaction limit at the user level will overwrite any interaction limits that are set for individual repositories owned by the user. * * FROM: <https://docs.github.com/rest/reference/interactions#set-interaction-restrictions-for-your-public-repositories> */ pub async fn set_restrictions_for_authenticated_user( &self, body: &crate::types::InteractionLimit, ) -> Result<crate::types::InteractionLimits> { let url = "/user/interaction-limits".to_string(); self.client .put( &url, Some(reqwest::Body::from(serde_json::to_vec(body).unwrap())), ) .await } /** * Remove interaction restrictions from your public repositories. * * This function performs a `DELETE` to the `/user/interaction-limits` endpoint. * * Removes any interaction restrictions from your public repositories. * * FROM: <https://docs.github.com/rest/reference/interactions#remove-interaction-restrictions-from-your-public-repositories> */ pub async fn remove_restrictions_for_authenticated_user(&self) -> Result<()> { let url = "/user/interaction-limits".to_string(); self.client.delete(&url, None).await } }