claude/smbcloud-github-app-k9641p
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | use { |
| 2 | crate::url_builder::{ |
| 3 | build_deploy_repo_github_connection_url, build_github_installation_repositories_url, |
| 4 | build_github_installations_url, |
| 5 | }, |
| 6 | reqwest::Client, |
| 7 | smbcloud_model::{ |
| 8 | error_codes::ErrorResponse, |
| 9 | github::{ |
| 10 | GithubConnection, GithubConnectionCreate, GithubConnectionStatus, GithubInstallation, |
| 11 | GithubRepository, |
| 12 | }, |
| 13 | }, |
| 14 | smbcloud_network::{environment::Environment, network::request}, |
| 15 | smbcloud_networking::{constants::SMB_USER_AGENT, smb_client::SmbClient}, |
| 16 | }; |
| 17 | |
| 18 | pub async fn get_github_installations( |
| 19 | env: Environment, |
| 20 | client: (&SmbClient, &str), |
| 21 | access_token: String, |
| 22 | ) -> Result<Vec<GithubInstallation>, ErrorResponse> { |
| 23 | let builder = Client::new() |
| 24 | .get(build_github_installations_url(env, client)) |
| 25 | .header("Authorization", access_token) |
| 26 | .header("User-agent", SMB_USER_AGENT); |
| 27 | request(builder).await |
| 28 | } |
| 29 | |
| 30 | pub async fn get_github_installation_repositories( |
| 31 | env: Environment, |
| 32 | client: (&SmbClient, &str), |
| 33 | access_token: String, |
| 34 | installation_id: i64, |
| 35 | ) -> Result<Vec<GithubRepository>, ErrorResponse> { |
| 36 | let builder = Client::new() |
| 37 | .get(build_github_installation_repositories_url( |
| 38 | env, |
| 39 | client, |
| 40 | installation_id, |
| 41 | )) |
| 42 | .header("Authorization", access_token) |
| 43 | .header("User-agent", SMB_USER_AGENT); |
| 44 | request(builder).await |
| 45 | } |
| 46 | |
| 47 | pub async fn get_github_connection( |
| 48 | env: Environment, |
| 49 | client: (&SmbClient, &str), |
| 50 | access_token: String, |
| 51 | deploy_repo_id: i64, |
| 52 | ) -> Result<GithubConnectionStatus, ErrorResponse> { |
| 53 | let builder = Client::new() |
| 54 | .get(build_deploy_repo_github_connection_url( |
| 55 | env, |
| 56 | client, |
| 57 | deploy_repo_id, |
| 58 | )) |
| 59 | .header("Authorization", access_token) |
| 60 | .header("User-agent", SMB_USER_AGENT); |
| 61 | request(builder).await |
| 62 | } |
| 63 | |
| 64 | pub async fn create_github_connection( |
| 65 | env: Environment, |
| 66 | client: (&SmbClient, &str), |
| 67 | access_token: String, |
| 68 | deploy_repo_id: i64, |
| 69 | payload: GithubConnectionCreate, |
| 70 | ) -> Result<GithubConnection, ErrorResponse> { |
| 71 | let builder = Client::new() |
| 72 | .post(build_deploy_repo_github_connection_url( |
| 73 | env, |
| 74 | client, |
| 75 | deploy_repo_id, |
| 76 | )) |
| 77 | .json(&payload) |
| 78 | .header("Authorization", access_token) |
| 79 | .header("User-agent", SMB_USER_AGENT); |
| 80 | request(builder).await |
| 81 | } |
| 82 | |
| 83 | pub async fn delete_github_connection( |
| 84 | env: Environment, |
| 85 | client: (&SmbClient, &str), |
| 86 | access_token: String, |
| 87 | deploy_repo_id: i64, |
| 88 | ) -> Result<(), ErrorResponse> { |
| 89 | let builder = Client::new() |
| 90 | .delete(build_deploy_repo_github_connection_url( |
| 91 | env, |
| 92 | client, |
| 93 | deploy_repo_id, |
| 94 | )) |
| 95 | .header("Authorization", access_token) |
| 96 | .header("User-agent", SMB_USER_AGENT); |
| 97 | request(builder).await |
| 98 | } |