1 use crate::url_builder::{build_project_deployment, build_project_deployment_index};
2 use anyhow::Result;
3 use reqwest::Client;
4 use smbcloud_model::{error_codes::ErrorResponse, project::Deployment};
5 use smbcloud_networking::{constants::SMB_USER_AGENT, environment::Environment, network::request};
6
7 pub async fn get_deployments(
8 env: Environment,
9 access_token: String,
10 project_id: i32,
11 ) -> Result<Vec<Deployment>, ErrorResponse> {
12 let builder = Client::new()
13 .get(build_project_deployment_index(env, project_id.to_string()))
14 .header("Authorization", access_token)
15 .header("User-agent", SMB_USER_AGENT);
16 request(builder).await
17 }
18
19 pub async fn get_deployment(
20 env: Environment,
21 access_token: String,
22 project_id: i32,
23 deployment_id: i32,
24 ) -> Result<Deployment, ErrorResponse> {
25 let builder = Client::new()
26 .get(build_project_deployment(
27 env,
28 project_id.to_string(),
29 deployment_id.to_string(),
30 ))
31 .header("Authorization", access_token)
32 .header("User-agent", SMB_USER_AGENT);
33 request(builder).await
34 }