openapi_github/apis/
copilot_api.rs

1/*
2 * GitHub's official OpenAPI spec + Octokit extension
3 *
4 * OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
5 *
6 * The version of the OpenAPI document: 16.6.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`copilot_slash_add_copilot_seats_for_teams`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CopilotSlashAddCopilotSeatsForTeamsError {
22    Status401(models::BasicError),
23    Status403(models::BasicError),
24    Status404(models::BasicError),
25    Status422(),
26    Status500(models::BasicError),
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`copilot_slash_add_copilot_seats_for_users`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum CopilotSlashAddCopilotSeatsForUsersError {
34    Status401(models::BasicError),
35    Status403(models::BasicError),
36    Status404(models::BasicError),
37    Status422(),
38    Status500(models::BasicError),
39    UnknownValue(serde_json::Value),
40}
41
42/// struct for typed errors of method [`copilot_slash_cancel_copilot_seat_assignment_for_teams`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum CopilotSlashCancelCopilotSeatAssignmentForTeamsError {
46    Status401(models::BasicError),
47    Status403(models::BasicError),
48    Status404(models::BasicError),
49    Status422(),
50    Status500(models::BasicError),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`copilot_slash_cancel_copilot_seat_assignment_for_users`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum CopilotSlashCancelCopilotSeatAssignmentForUsersError {
58    Status401(models::BasicError),
59    Status403(models::BasicError),
60    Status404(models::BasicError),
61    Status422(),
62    Status500(models::BasicError),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`copilot_slash_get_copilot_organization_details`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum CopilotSlashGetCopilotOrganizationDetailsError {
70    Status401(models::BasicError),
71    Status403(models::BasicError),
72    Status404(models::BasicError),
73    Status422(),
74    Status500(models::BasicError),
75    UnknownValue(serde_json::Value),
76}
77
78/// struct for typed errors of method [`copilot_slash_get_copilot_seat_details_for_user`]
79#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum CopilotSlashGetCopilotSeatDetailsForUserError {
82    Status401(models::BasicError),
83    Status403(models::BasicError),
84    Status404(models::BasicError),
85    Status422(),
86    Status500(models::BasicError),
87    UnknownValue(serde_json::Value),
88}
89
90/// struct for typed errors of method [`copilot_slash_list_copilot_seats`]
91#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum CopilotSlashListCopilotSeatsError {
94    Status401(models::BasicError),
95    Status403(models::BasicError),
96    Status404(models::BasicError),
97    Status500(models::BasicError),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`copilot_slash_usage_metrics_for_enterprise`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum CopilotSlashUsageMetricsForEnterpriseError {
105    Status401(models::BasicError),
106    Status403(models::BasicError),
107    Status404(models::BasicError),
108    Status500(models::BasicError),
109    UnknownValue(serde_json::Value),
110}
111
112/// struct for typed errors of method [`copilot_slash_usage_metrics_for_org`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum CopilotSlashUsageMetricsForOrgError {
116    Status401(models::BasicError),
117    Status403(models::BasicError),
118    Status404(models::BasicError),
119    Status500(models::BasicError),
120    UnknownValue(serde_json::Value),
121}
122
123/// struct for typed errors of method [`copilot_slash_usage_metrics_for_team`]
124#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum CopilotSlashUsageMetricsForTeamError {
127    Status401(models::BasicError),
128    Status403(models::BasicError),
129    Status404(models::BasicError),
130    Status500(models::BasicError),
131    UnknownValue(serde_json::Value),
132}
133
134
135/// **Note**: This endpoint is in beta and is subject to change.  Purchases a GitHub Copilot seat for all users within each specified team. The organization will be billed accordingly. For more information about Copilot pricing, see \"[Pricing for GitHub Copilot](https://docs.github.com/billing/managing-billing-for-github-copilot/about-billing-for-github-copilot#about-billing-for-github-copilot)\".  Only organization owners can configure GitHub Copilot in their organization.  In order for an admin to use this endpoint, the organization must have a Copilot Business or Enterprise subscription and a configured suggestion matching policy. For more information about setting up a Copilot subscription, see \"[Setting up a Copilot subscription for your organization](https://docs.github.com/billing/managing-billing-for-github-copilot/managing-your-github-copilot-subscription-for-your-organization-or-enterprise)\". For more information about setting a suggestion matching policy, see \"[Configuring suggestion matching policies for GitHub Copilot in your organization](https://docs.github.com/copilot/managing-copilot/managing-policies-for-github-copilot-in-your-organization#configuring-suggestion-matching-policies-for-github-copilot-in-your-organization)\".  OAuth app tokens and personal access tokens (classic) need the `manage_billing:copilot` scope to use this endpoint.
136pub async fn copilot_slash_add_copilot_seats_for_teams(configuration: &configuration::Configuration, org: &str, copilot_add_copilot_seats_for_teams_request: models::CopilotAddCopilotSeatsForTeamsRequest) -> Result<models::CopilotAddCopilotSeatsForTeams201Response, Error<CopilotSlashAddCopilotSeatsForTeamsError>> {
137    let local_var_configuration = configuration;
138
139    let local_var_client = &local_var_configuration.client;
140
141    let local_var_uri_str = format!("{}/orgs/{org}/copilot/billing/selected_teams", local_var_configuration.base_path, org=crate::apis::urlencode(org));
142    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
143
144    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
145        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
146    }
147    local_var_req_builder = local_var_req_builder.json(&copilot_add_copilot_seats_for_teams_request);
148
149    let local_var_req = local_var_req_builder.build()?;
150    let local_var_resp = local_var_client.execute(local_var_req).await?;
151
152    let local_var_status = local_var_resp.status();
153    let local_var_content = local_var_resp.text().await?;
154
155    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
156        serde_json::from_str(&local_var_content).map_err(Error::from)
157    } else {
158        let local_var_entity: Option<CopilotSlashAddCopilotSeatsForTeamsError> = serde_json::from_str(&local_var_content).ok();
159        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
160        Err(Error::ResponseError(local_var_error))
161    }
162}
163
164/// **Note**: This endpoint is in beta and is subject to change.  Purchases a GitHub Copilot seat for each user specified. The organization will be billed accordingly. For more information about Copilot pricing, see \"[Pricing for GitHub Copilot](https://docs.github.com/billing/managing-billing-for-github-copilot/about-billing-for-github-copilot#about-billing-for-github-copilot)\".  Only organization owners can configure GitHub Copilot in their organization.  In order for an admin to use this endpoint, the organization must have a Copilot Business or Enterprise subscription and a configured suggestion matching policy. For more information about setting up a Copilot subscription, see \"[Setting up a Copilot subscription for your organization](https://docs.github.com/billing/managing-billing-for-github-copilot/managing-your-github-copilot-subscription-for-your-organization-or-enterprise)\". For more information about setting a suggestion matching policy, see \"[Configuring suggestion matching policies for GitHub Copilot in your organization](https://docs.github.com/copilot/managing-copilot/managing-policies-for-github-copilot-in-your-organization#configuring-suggestion-matching-policies-for-github-copilot-in-your-organization)\".  OAuth app tokens and personal access tokens (classic) need the `manage_billing:copilot` scope to use this endpoint.
165pub async fn copilot_slash_add_copilot_seats_for_users(configuration: &configuration::Configuration, org: &str, copilot_add_copilot_seats_for_users_request: models::CopilotAddCopilotSeatsForUsersRequest) -> Result<models::CopilotAddCopilotSeatsForTeams201Response, Error<CopilotSlashAddCopilotSeatsForUsersError>> {
166    let local_var_configuration = configuration;
167
168    let local_var_client = &local_var_configuration.client;
169
170    let local_var_uri_str = format!("{}/orgs/{org}/copilot/billing/selected_users", local_var_configuration.base_path, org=crate::apis::urlencode(org));
171    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
172
173    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
174        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
175    }
176    local_var_req_builder = local_var_req_builder.json(&copilot_add_copilot_seats_for_users_request);
177
178    let local_var_req = local_var_req_builder.build()?;
179    let local_var_resp = local_var_client.execute(local_var_req).await?;
180
181    let local_var_status = local_var_resp.status();
182    let local_var_content = local_var_resp.text().await?;
183
184    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
185        serde_json::from_str(&local_var_content).map_err(Error::from)
186    } else {
187        let local_var_entity: Option<CopilotSlashAddCopilotSeatsForUsersError> = serde_json::from_str(&local_var_content).ok();
188        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
189        Err(Error::ResponseError(local_var_error))
190    }
191}
192
193/// **Note**: This endpoint is in beta and is subject to change.  Cancels the Copilot seat assignment for all members of each team specified. This will cause the members of the specified team(s) to lose access to GitHub Copilot at the end of the current billing cycle, and the organization will not be billed further for those users.  For more information about Copilot pricing, see \"[Pricing for GitHub Copilot](https://docs.github.com/billing/managing-billing-for-github-copilot/about-billing-for-github-copilot#about-billing-for-github-copilot)\".  For more information about disabling access to Copilot Business or Enterprise, see \"[Revoking access to GitHub Copilot for specific users in your organization](https://docs.github.com/copilot/managing-copilot/managing-access-for-copilot-in-your-organization#revoking-access-to-github-copilot-for-specific-users-in-your-organization)\".  Only organization owners can configure GitHub Copilot in their organization.  OAuth app tokens and personal access tokens (classic) need the `manage_billing:copilot` scope to use this endpoint.
194pub async fn copilot_slash_cancel_copilot_seat_assignment_for_teams(configuration: &configuration::Configuration, org: &str, copilot_cancel_copilot_seat_assignment_for_teams_request: models::CopilotCancelCopilotSeatAssignmentForTeamsRequest) -> Result<models::CopilotCancelCopilotSeatAssignmentForTeams200Response, Error<CopilotSlashCancelCopilotSeatAssignmentForTeamsError>> {
195    let local_var_configuration = configuration;
196
197    let local_var_client = &local_var_configuration.client;
198
199    let local_var_uri_str = format!("{}/orgs/{org}/copilot/billing/selected_teams", local_var_configuration.base_path, org=crate::apis::urlencode(org));
200    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
201
202    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
203        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
204    }
205    local_var_req_builder = local_var_req_builder.json(&copilot_cancel_copilot_seat_assignment_for_teams_request);
206
207    let local_var_req = local_var_req_builder.build()?;
208    let local_var_resp = local_var_client.execute(local_var_req).await?;
209
210    let local_var_status = local_var_resp.status();
211    let local_var_content = local_var_resp.text().await?;
212
213    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
214        serde_json::from_str(&local_var_content).map_err(Error::from)
215    } else {
216        let local_var_entity: Option<CopilotSlashCancelCopilotSeatAssignmentForTeamsError> = serde_json::from_str(&local_var_content).ok();
217        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
218        Err(Error::ResponseError(local_var_error))
219    }
220}
221
222/// **Note**: This endpoint is in beta and is subject to change.  Cancels the Copilot seat assignment for each user specified. This will cause the specified users to lose access to GitHub Copilot at the end of the current billing cycle, and the organization will not be billed further for those users.  For more information about Copilot pricing, see \"[Pricing for GitHub Copilot](https://docs.github.com/billing/managing-billing-for-github-copilot/about-billing-for-github-copilot#about-billing-for-github-copilot)\".  For more information about disabling access to Copilot Business or Enterprise, see \"[Revoking access to GitHub Copilot for specific users in your organization](https://docs.github.com/copilot/managing-copilot/managing-access-for-copilot-in-your-organization#revoking-access-to-github-copilot-for-specific-users-in-your-organization)\".  Only organization owners can configure GitHub Copilot in their organization.  OAuth app tokens and personal access tokens (classic) need the `manage_billing:copilot` scope to use this endpoint.
223pub async fn copilot_slash_cancel_copilot_seat_assignment_for_users(configuration: &configuration::Configuration, org: &str, copilot_cancel_copilot_seat_assignment_for_users_request: models::CopilotCancelCopilotSeatAssignmentForUsersRequest) -> Result<models::CopilotCancelCopilotSeatAssignmentForTeams200Response, Error<CopilotSlashCancelCopilotSeatAssignmentForUsersError>> {
224    let local_var_configuration = configuration;
225
226    let local_var_client = &local_var_configuration.client;
227
228    let local_var_uri_str = format!("{}/orgs/{org}/copilot/billing/selected_users", local_var_configuration.base_path, org=crate::apis::urlencode(org));
229    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
230
231    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
232        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
233    }
234    local_var_req_builder = local_var_req_builder.json(&copilot_cancel_copilot_seat_assignment_for_users_request);
235
236    let local_var_req = local_var_req_builder.build()?;
237    let local_var_resp = local_var_client.execute(local_var_req).await?;
238
239    let local_var_status = local_var_resp.status();
240    let local_var_content = local_var_resp.text().await?;
241
242    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
243        serde_json::from_str(&local_var_content).map_err(Error::from)
244    } else {
245        let local_var_entity: Option<CopilotSlashCancelCopilotSeatAssignmentForUsersError> = serde_json::from_str(&local_var_content).ok();
246        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
247        Err(Error::ResponseError(local_var_error))
248    }
249}
250
251/// **Note**: This endpoint is in beta and is subject to change.  Gets information about an organization's Copilot subscription, including seat breakdown and code matching policies. To configure these settings, go to your organization's settings on GitHub.com. For more information, see \"[Managing policies for Copilot in your organization](https://docs.github.com/copilot/managing-copilot/managing-policies-for-copilot-business-in-your-organization)\".  Only organization owners can configure and view details about the organization's Copilot Business subscription.  OAuth app tokens and personal access tokens (classic) need the `manage_billing:copilot` scope to use this endpoint.
252pub async fn copilot_slash_get_copilot_organization_details(configuration: &configuration::Configuration, org: &str) -> Result<models::CopilotOrganizationDetails, Error<CopilotSlashGetCopilotOrganizationDetailsError>> {
253    let local_var_configuration = configuration;
254
255    let local_var_client = &local_var_configuration.client;
256
257    let local_var_uri_str = format!("{}/orgs/{org}/copilot/billing", local_var_configuration.base_path, org=crate::apis::urlencode(org));
258    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
259
260    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
261        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
262    }
263
264    let local_var_req = local_var_req_builder.build()?;
265    let local_var_resp = local_var_client.execute(local_var_req).await?;
266
267    let local_var_status = local_var_resp.status();
268    let local_var_content = local_var_resp.text().await?;
269
270    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
271        serde_json::from_str(&local_var_content).map_err(Error::from)
272    } else {
273        let local_var_entity: Option<CopilotSlashGetCopilotOrganizationDetailsError> = serde_json::from_str(&local_var_content).ok();
274        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
275        Err(Error::ResponseError(local_var_error))
276    }
277}
278
279/// **Note**: This endpoint is in beta and is subject to change.  Gets the GitHub Copilot seat assignment details for a member of an organization who currently has access to GitHub Copilot.  Organization owners can view GitHub Copilot seat assignment details for members in their organization.  OAuth app tokens and personal access tokens (classic) need the `manage_billing:copilot` scope to use this endpoint.
280pub async fn copilot_slash_get_copilot_seat_details_for_user(configuration: &configuration::Configuration, org: &str, username: &str) -> Result<models::CopilotSeatDetails, Error<CopilotSlashGetCopilotSeatDetailsForUserError>> {
281    let local_var_configuration = configuration;
282
283    let local_var_client = &local_var_configuration.client;
284
285    let local_var_uri_str = format!("{}/orgs/{org}/members/{username}/copilot", local_var_configuration.base_path, org=crate::apis::urlencode(org), username=crate::apis::urlencode(username));
286    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
287
288    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
289        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
290    }
291
292    let local_var_req = local_var_req_builder.build()?;
293    let local_var_resp = local_var_client.execute(local_var_req).await?;
294
295    let local_var_status = local_var_resp.status();
296    let local_var_content = local_var_resp.text().await?;
297
298    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
299        serde_json::from_str(&local_var_content).map_err(Error::from)
300    } else {
301        let local_var_entity: Option<CopilotSlashGetCopilotSeatDetailsForUserError> = serde_json::from_str(&local_var_content).ok();
302        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
303        Err(Error::ResponseError(local_var_error))
304    }
305}
306
307/// **Note**: This endpoint is in beta and is subject to change.  Lists all Copilot seat assignments for an organization that are currently being billed (either active or pending cancellation at the start of the next billing cycle).  Only organization owners can configure and view details about the organization's Copilot Business or Enterprise subscription.  OAuth app tokens and personal access tokens (classic) need the `manage_billing:copilot` scope to use this endpoint.
308pub async fn copilot_slash_list_copilot_seats(configuration: &configuration::Configuration, org: &str, page: Option<i32>, per_page: Option<i32>) -> Result<models::CopilotListCopilotSeats200Response, Error<CopilotSlashListCopilotSeatsError>> {
309    let local_var_configuration = configuration;
310
311    let local_var_client = &local_var_configuration.client;
312
313    let local_var_uri_str = format!("{}/orgs/{org}/copilot/billing/seats", local_var_configuration.base_path, org=crate::apis::urlencode(org));
314    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
315
316    if let Some(ref local_var_str) = page {
317        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
318    }
319    if let Some(ref local_var_str) = per_page {
320        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
321    }
322    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
323        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
324    }
325
326    let local_var_req = local_var_req_builder.build()?;
327    let local_var_resp = local_var_client.execute(local_var_req).await?;
328
329    let local_var_status = local_var_resp.status();
330    let local_var_content = local_var_resp.text().await?;
331
332    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
333        serde_json::from_str(&local_var_content).map_err(Error::from)
334    } else {
335        let local_var_entity: Option<CopilotSlashListCopilotSeatsError> = serde_json::from_str(&local_var_content).ok();
336        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
337        Err(Error::ResponseError(local_var_error))
338    }
339}
340
341/// **Note**: This endpoint is in beta and is subject to change.  You can use this endpoint to see a daily breakdown of aggregated usage metrics for Copilot completions and Copilot Chat in the IDE for all users across organizations with access to Copilot within your enterprise, with a further breakdown of suggestions, acceptances, and number of active users by editor and language for each day. See the response schema tab for detailed metrics definitions.  The response contains metrics for the prior 28 days. Usage metrics are processed once per day for the previous day, and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics, they must have telemetry enabled in their IDE.  Only the owners and billing managers of enterprises with a Copilot Business or Enterprise subscription can view Copilot usage metrics for the enterprise.  OAuth app tokens and personal access tokens (classic) need the `copilot`, `manage_billing:copilot`, `admin:enterprise`, or `manage_billing:enterprise` scope to use this endpoint.
342pub async fn copilot_slash_usage_metrics_for_enterprise(configuration: &configuration::Configuration, enterprise: &str, since: Option<&str>, until: Option<&str>, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::CopilotUsageMetrics>, Error<CopilotSlashUsageMetricsForEnterpriseError>> {
343    let local_var_configuration = configuration;
344
345    let local_var_client = &local_var_configuration.client;
346
347    let local_var_uri_str = format!("{}/enterprises/{enterprise}/copilot/usage", local_var_configuration.base_path, enterprise=crate::apis::urlencode(enterprise));
348    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
349
350    if let Some(ref local_var_str) = since {
351        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
352    }
353    if let Some(ref local_var_str) = until {
354        local_var_req_builder = local_var_req_builder.query(&[("until", &local_var_str.to_string())]);
355    }
356    if let Some(ref local_var_str) = page {
357        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
358    }
359    if let Some(ref local_var_str) = per_page {
360        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
361    }
362    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
363        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
364    }
365
366    let local_var_req = local_var_req_builder.build()?;
367    let local_var_resp = local_var_client.execute(local_var_req).await?;
368
369    let local_var_status = local_var_resp.status();
370    let local_var_content = local_var_resp.text().await?;
371
372    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
373        serde_json::from_str(&local_var_content).map_err(Error::from)
374    } else {
375        let local_var_entity: Option<CopilotSlashUsageMetricsForEnterpriseError> = serde_json::from_str(&local_var_content).ok();
376        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
377        Err(Error::ResponseError(local_var_error))
378    }
379}
380
381/// **Note**: This endpoint is in beta and is subject to change.  You can use this endpoint to see a daily breakdown of aggregated usage metrics for Copilot completions and Copilot Chat in the IDE across an organization, with a further breakdown of suggestions, acceptances, and number of active users by editor and language for each day. See the response schema tab for detailed metrics definitions.  The response contains metrics for the prior 28 days. Usage metrics are processed once per day for the previous day, and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics, they must have telemetry enabled in their IDE.  Copilot Business or Copilot Enterprise organization owners, and owners and billing managers of their parent enterprises, can view Copilot usage metrics.  OAuth app tokens and personal access tokens (classic) need the `copilot`, `manage_billing:copilot`, `admin:org`, `admin:enterprise`, or `manage_billing:enterprise` scope to use this endpoint.
382pub async fn copilot_slash_usage_metrics_for_org(configuration: &configuration::Configuration, org: &str, since: Option<&str>, until: Option<&str>, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::CopilotUsageMetrics>, Error<CopilotSlashUsageMetricsForOrgError>> {
383    let local_var_configuration = configuration;
384
385    let local_var_client = &local_var_configuration.client;
386
387    let local_var_uri_str = format!("{}/orgs/{org}/copilot/usage", local_var_configuration.base_path, org=crate::apis::urlencode(org));
388    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
389
390    if let Some(ref local_var_str) = since {
391        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
392    }
393    if let Some(ref local_var_str) = until {
394        local_var_req_builder = local_var_req_builder.query(&[("until", &local_var_str.to_string())]);
395    }
396    if let Some(ref local_var_str) = page {
397        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
398    }
399    if let Some(ref local_var_str) = per_page {
400        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
401    }
402    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
403        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
404    }
405
406    let local_var_req = local_var_req_builder.build()?;
407    let local_var_resp = local_var_client.execute(local_var_req).await?;
408
409    let local_var_status = local_var_resp.status();
410    let local_var_content = local_var_resp.text().await?;
411
412    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
413        serde_json::from_str(&local_var_content).map_err(Error::from)
414    } else {
415        let local_var_entity: Option<CopilotSlashUsageMetricsForOrgError> = serde_json::from_str(&local_var_content).ok();
416        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
417        Err(Error::ResponseError(local_var_error))
418    }
419}
420
421/// **Note**: This endpoint is in beta and is subject to change.  You can use this endpoint to see a daily breakdown of aggregated usage metrics for Copilot completions and Copilot Chat in the IDE for users within a team, with a further breakdown of suggestions, acceptances, and number of active users by editor and language for each day. See the response schema tab for detailed metrics definitions.  The response contains metrics for the prior 28 days. Usage metrics are processed once per day for the previous day, and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics, they must have telemetry enabled in their IDE.  **Note**: This endpoint will only return results for a given day if the team had five or more members on that day.  Copilot Business or Copilot Enterprise organization owners for the organization that contains this team, and owners and billing managers of their parent enterprises, can view Copilot usage metrics for a team.  OAuth app tokens and personal access tokens (classic) need the `copilot`, `manage_billing:copilot`, `admin:org`, `admin:enterprise`, or `manage_billing:enterprise` scope to use this endpoint.
422pub async fn copilot_slash_usage_metrics_for_team(configuration: &configuration::Configuration, org: &str, team_slug: &str, since: Option<&str>, until: Option<&str>, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::CopilotUsageMetrics>, Error<CopilotSlashUsageMetricsForTeamError>> {
423    let local_var_configuration = configuration;
424
425    let local_var_client = &local_var_configuration.client;
426
427    let local_var_uri_str = format!("{}/orgs/{org}/team/{team_slug}/copilot/usage", local_var_configuration.base_path, org=crate::apis::urlencode(org), team_slug=crate::apis::urlencode(team_slug));
428    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
429
430    if let Some(ref local_var_str) = since {
431        local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
432    }
433    if let Some(ref local_var_str) = until {
434        local_var_req_builder = local_var_req_builder.query(&[("until", &local_var_str.to_string())]);
435    }
436    if let Some(ref local_var_str) = page {
437        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
438    }
439    if let Some(ref local_var_str) = per_page {
440        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
441    }
442    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
443        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
444    }
445
446    let local_var_req = local_var_req_builder.build()?;
447    let local_var_resp = local_var_client.execute(local_var_req).await?;
448
449    let local_var_status = local_var_resp.status();
450    let local_var_content = local_var_resp.text().await?;
451
452    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
453        serde_json::from_str(&local_var_content).map_err(Error::from)
454    } else {
455        let local_var_entity: Option<CopilotSlashUsageMetricsForTeamError> = serde_json::from_str(&local_var_content).ok();
456        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
457        Err(Error::ResponseError(local_var_error))
458    }
459}
460