diff --git a/src/endpoints/billing.rs b/src/endpoints/billing.rs index 0a8b5e1..af08ba2 100644 --- a/src/endpoints/billing.rs +++ b/src/endpoints/billing.rs @@ -72,6 +72,39 @@ impl From for AdapterError { } } +/// Errors for the [Get billing usage report for an organization](Billing::get_github_billing_usage_report_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum BillingGetGithubBillingUsageReportOrgError { + #[error("Bad Request")] + Status400(BasicError), + #[error("Forbidden")] + Status403(BasicError), + #[error("Internal Error")] + Status500(BasicError), + #[error("Service unavailable")] + Status503(PostCodespacesCreateForAuthenticatedUserResponse503), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +impl From for AdapterError { + fn from(err: BillingGetGithubBillingUsageReportOrgError) -> Self { + let (description, status_code) = match err { + BillingGetGithubBillingUsageReportOrgError::Status400(_) => (String::from("Bad Request"), 400), + BillingGetGithubBillingUsageReportOrgError::Status403(_) => (String::from("Forbidden"), 403), + BillingGetGithubBillingUsageReportOrgError::Status500(_) => (String::from("Internal Error"), 500), + BillingGetGithubBillingUsageReportOrgError::Status503(_) => (String::from("Service unavailable"), 503), + BillingGetGithubBillingUsageReportOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get GitHub Packages billing for an organization](Billing::get_github_packages_billing_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum BillingGetGithubPackagesBillingOrgError { @@ -157,6 +190,65 @@ impl From for AdapterError { } +/// Query parameters for the [Get billing usage report for an organization](Billing::get_github_billing_usage_report_org_async()) endpoint. +#[derive(Default, Serialize)] +pub struct BillingGetGithubBillingUsageReportOrgParams { + /// If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2024`. Default value is the current year. + year: Option, + /// If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. + month: Option, + /// If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. + day: Option, + /// If specified, only return results for a single hour. The value of `hour` is an integer between `0` and `23`. + hour: Option +} + +impl BillingGetGithubBillingUsageReportOrgParams { + pub fn new() -> Self { + Self::default() + } + + /// If specified, only return results for a single year. The value of `year` is an integer with four digits representing a year. For example, `2024`. Default value is the current year. + pub fn year(self, year: i32) -> Self { + Self { + year: Some(year), + month: self.month, + day: self.day, + hour: self.hour, + } + } + + /// If specified, only return results for a single month. The value of `month` is an integer between `1` and `12`. + pub fn month(self, month: i32) -> Self { + Self { + year: self.year, + month: Some(month), + day: self.day, + hour: self.hour, + } + } + + /// If specified, only return results for a single day. The value of `day` is an integer between `1` and `31`. + pub fn day(self, day: i32) -> Self { + Self { + year: self.year, + month: self.month, + day: Some(day), + hour: self.hour, + } + } + + /// If specified, only return results for a single hour. The value of `hour` is an integer between `0` and `23`. + pub fn hour(self, hour: i32) -> Self { + Self { + year: self.year, + month: self.month, + day: self.day, + hour: Some(hour), + } + } +} + impl<'api, C: Client> Billing<'api, C> where AdapterError: From<::Err> { /// --- @@ -329,6 +421,104 @@ impl<'api, C: Client> Billing<'api, C> where AdapterError: From<::E } } + /// --- + /// + /// # Get billing usage report for an organization + /// + /// Gets a report of the total usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account. + /// + /// **Note:** This endpoint is only available to organizations with access to the enhanced billing platform. For more information, see "[About the enhanced billing platform](https://docs.github.com/billing/using-the-new-billing-platform)." + /// + /// [GitHub API docs for get_github_billing_usage_report_org](https://docs.github.com/rest/billing/enhanced-billing#get-billing-usage-report-for-an-organization) + /// + /// --- + pub async fn get_github_billing_usage_report_org_async(&self, org: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/organizations/{}/settings/billing/usage", super::GITHUB_BASE_API_URL, org); + + if let Some(params) = query_params { + request_uri.push_str("?"); + request_uri.push_str(&serde_urlencoded::to_string(params.into())?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None::, + method: "GET", + headers: vec![] + }; + + let request = self.client.build(req)?; + + // -- + + let github_response = self.client.fetch_async(request).await?; + + // -- + + if github_response.is_success() { + Ok(github_response.to_json_async().await?) + } else { + match github_response.status_code() { + 400 => Err(BillingGetGithubBillingUsageReportOrgError::Status400(github_response.to_json_async().await?).into()), + 403 => Err(BillingGetGithubBillingUsageReportOrgError::Status403(github_response.to_json_async().await?).into()), + 500 => Err(BillingGetGithubBillingUsageReportOrgError::Status500(github_response.to_json_async().await?).into()), + 503 => Err(BillingGetGithubBillingUsageReportOrgError::Status503(github_response.to_json_async().await?).into()), + code => Err(BillingGetGithubBillingUsageReportOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Get billing usage report for an organization + /// + /// Gets a report of the total usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account. + /// + /// **Note:** This endpoint is only available to organizations with access to the enhanced billing platform. For more information, see "[About the enhanced billing platform](https://docs.github.com/billing/using-the-new-billing-platform)." + /// + /// [GitHub API docs for get_github_billing_usage_report_org](https://docs.github.com/rest/billing/enhanced-billing#get-billing-usage-report-for-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn get_github_billing_usage_report_org(&self, org: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/organizations/{}/settings/billing/usage", super::GITHUB_BASE_API_URL, org); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: BillingGetGithubBillingUsageReportOrgParams = params.into(); + request_uri.push_str(&serde_urlencoded::to_string(qp)?); + } + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = self.client.build(req)?; + + // -- + + let github_response = self.client.fetch(request)?; + + // -- + + if github_response.is_success() { + Ok(github_response.to_json()?) + } else { + match github_response.status_code() { + 400 => Err(BillingGetGithubBillingUsageReportOrgError::Status400(github_response.to_json()?).into()), + 403 => Err(BillingGetGithubBillingUsageReportOrgError::Status403(github_response.to_json()?).into()), + 500 => Err(BillingGetGithubBillingUsageReportOrgError::Status500(github_response.to_json()?).into()), + 503 => Err(BillingGetGithubBillingUsageReportOrgError::Status503(github_response.to_json()?).into()), + code => Err(BillingGetGithubBillingUsageReportOrgError::Generic { code }.into()), + } + } + } + /// --- /// /// # Get GitHub Packages billing for an organization diff --git a/src/endpoints/orgs.rs b/src/endpoints/orgs.rs index 2f97260..3eefb7f 100644 --- a/src/endpoints/orgs.rs +++ b/src/endpoints/orgs.rs @@ -2101,10 +2101,10 @@ impl From for AdapterError { /// Query parameters for the [Get route stats by actor](Orgs::get_route_stats_by_actor_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsGetRouteStatsByActorParams<'req> { - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. min_timestamp: &'req str, - /// The maximum timestamp to query for stats - max_timestamp: &'req str, + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + max_timestamp: Option<&'req str>, /// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" page: Option, /// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" @@ -2120,7 +2120,7 @@ impl<'req> OrgsGetRouteStatsByActorParams<'req> { Self::default() } - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn min_timestamp(self, min_timestamp: &'req str) -> Self { Self { min_timestamp: min_timestamp, @@ -2132,11 +2132,11 @@ impl<'req> OrgsGetRouteStatsByActorParams<'req> { } } - /// The maximum timestamp to query for stats + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn max_timestamp(self, max_timestamp: &'req str) -> Self { Self { min_timestamp: self.min_timestamp, - max_timestamp: max_timestamp, + max_timestamp: Some(max_timestamp), page: self.page, per_page: self.per_page, direction: self.direction, @@ -2205,10 +2205,10 @@ impl<'enc> From<&'enc PerPage> for OrgsGetRouteStatsByActorParams<'enc> { /// Query parameters for the [Get subject stats](Orgs::get_subject_stats_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsGetSubjectStatsParams<'req> { - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. min_timestamp: &'req str, - /// The maximum timestamp to query for stats - max_timestamp: &'req str, + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + max_timestamp: Option<&'req str>, /// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" page: Option, /// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" @@ -2224,7 +2224,7 @@ impl<'req> OrgsGetSubjectStatsParams<'req> { Self::default() } - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn min_timestamp(self, min_timestamp: &'req str) -> Self { Self { min_timestamp: min_timestamp, @@ -2236,11 +2236,11 @@ impl<'req> OrgsGetSubjectStatsParams<'req> { } } - /// The maximum timestamp to query for stats + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn max_timestamp(self, max_timestamp: &'req str) -> Self { Self { min_timestamp: self.min_timestamp, - max_timestamp: max_timestamp, + max_timestamp: Some(max_timestamp), page: self.page, per_page: self.per_page, direction: self.direction, @@ -2309,10 +2309,10 @@ impl<'enc> From<&'enc PerPage> for OrgsGetSubjectStatsParams<'enc> { /// Query parameters for the [Get summary stats](Orgs::get_summary_stats_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsGetSummaryStatsParams<'req> { - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. min_timestamp: &'req str, - /// The maximum timestamp to query for stats - max_timestamp: &'req str + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + max_timestamp: Option<&'req str> } impl<'req> OrgsGetSummaryStatsParams<'req> { @@ -2320,7 +2320,7 @@ impl<'req> OrgsGetSummaryStatsParams<'req> { Self::default() } - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn min_timestamp(self, min_timestamp: &'req str) -> Self { Self { min_timestamp: min_timestamp, @@ -2328,11 +2328,11 @@ impl<'req> OrgsGetSummaryStatsParams<'req> { } } - /// The maximum timestamp to query for stats + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn max_timestamp(self, max_timestamp: &'req str) -> Self { Self { min_timestamp: self.min_timestamp, - max_timestamp: max_timestamp, + max_timestamp: Some(max_timestamp), } } } @@ -2340,10 +2340,10 @@ impl<'req> OrgsGetSummaryStatsParams<'req> { /// Query parameters for the [Get summary stats by actor](Orgs::get_summary_stats_by_actor_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsGetSummaryStatsByActorParams<'req> { - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. min_timestamp: &'req str, - /// The maximum timestamp to query for stats - max_timestamp: &'req str + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + max_timestamp: Option<&'req str> } impl<'req> OrgsGetSummaryStatsByActorParams<'req> { @@ -2351,7 +2351,7 @@ impl<'req> OrgsGetSummaryStatsByActorParams<'req> { Self::default() } - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn min_timestamp(self, min_timestamp: &'req str) -> Self { Self { min_timestamp: min_timestamp, @@ -2359,11 +2359,11 @@ impl<'req> OrgsGetSummaryStatsByActorParams<'req> { } } - /// The maximum timestamp to query for stats + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn max_timestamp(self, max_timestamp: &'req str) -> Self { Self { min_timestamp: self.min_timestamp, - max_timestamp: max_timestamp, + max_timestamp: Some(max_timestamp), } } } @@ -2371,10 +2371,10 @@ impl<'req> OrgsGetSummaryStatsByActorParams<'req> { /// Query parameters for the [Get summary stats by user](Orgs::get_summary_stats_by_user_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsGetSummaryStatsByUserParams<'req> { - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. min_timestamp: &'req str, - /// The maximum timestamp to query for stats - max_timestamp: &'req str + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + max_timestamp: Option<&'req str> } impl<'req> OrgsGetSummaryStatsByUserParams<'req> { @@ -2382,7 +2382,7 @@ impl<'req> OrgsGetSummaryStatsByUserParams<'req> { Self::default() } - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn min_timestamp(self, min_timestamp: &'req str) -> Self { Self { min_timestamp: min_timestamp, @@ -2390,11 +2390,11 @@ impl<'req> OrgsGetSummaryStatsByUserParams<'req> { } } - /// The maximum timestamp to query for stats + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn max_timestamp(self, max_timestamp: &'req str) -> Self { Self { min_timestamp: self.min_timestamp, - max_timestamp: max_timestamp, + max_timestamp: Some(max_timestamp), } } } @@ -2402,10 +2402,10 @@ impl<'req> OrgsGetSummaryStatsByUserParams<'req> { /// Query parameters for the [Get time stats](Orgs::get_time_stats_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsGetTimeStatsParams<'req> { - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. min_timestamp: &'req str, - /// The maximum timestamp to query for stats - max_timestamp: &'req str, + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + max_timestamp: Option<&'req str>, /// The increment of time used to breakdown the query results (5m, 10m, 1h, etc.) timestamp_increment: &'req str } @@ -2415,7 +2415,7 @@ impl<'req> OrgsGetTimeStatsParams<'req> { Self::default() } - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn min_timestamp(self, min_timestamp: &'req str) -> Self { Self { min_timestamp: min_timestamp, @@ -2424,11 +2424,11 @@ impl<'req> OrgsGetTimeStatsParams<'req> { } } - /// The maximum timestamp to query for stats + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn max_timestamp(self, max_timestamp: &'req str) -> Self { Self { min_timestamp: self.min_timestamp, - max_timestamp: max_timestamp, + max_timestamp: Some(max_timestamp), timestamp_increment: self.timestamp_increment, } } @@ -2446,10 +2446,10 @@ impl<'req> OrgsGetTimeStatsParams<'req> { /// Query parameters for the [Get time stats by actor](Orgs::get_time_stats_by_actor_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsGetTimeStatsByActorParams<'req> { - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. min_timestamp: &'req str, - /// The maximum timestamp to query for stats - max_timestamp: &'req str, + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + max_timestamp: Option<&'req str>, /// The increment of time used to breakdown the query results (5m, 10m, 1h, etc.) timestamp_increment: &'req str } @@ -2459,7 +2459,7 @@ impl<'req> OrgsGetTimeStatsByActorParams<'req> { Self::default() } - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn min_timestamp(self, min_timestamp: &'req str) -> Self { Self { min_timestamp: min_timestamp, @@ -2468,11 +2468,11 @@ impl<'req> OrgsGetTimeStatsByActorParams<'req> { } } - /// The maximum timestamp to query for stats + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn max_timestamp(self, max_timestamp: &'req str) -> Self { Self { min_timestamp: self.min_timestamp, - max_timestamp: max_timestamp, + max_timestamp: Some(max_timestamp), timestamp_increment: self.timestamp_increment, } } @@ -2490,10 +2490,10 @@ impl<'req> OrgsGetTimeStatsByActorParams<'req> { /// Query parameters for the [Get time stats by user](Orgs::get_time_stats_by_user_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsGetTimeStatsByUserParams<'req> { - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. min_timestamp: &'req str, - /// The maximum timestamp to query for stats - max_timestamp: &'req str, + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + max_timestamp: Option<&'req str>, /// The increment of time used to breakdown the query results (5m, 10m, 1h, etc.) timestamp_increment: &'req str } @@ -2503,7 +2503,7 @@ impl<'req> OrgsGetTimeStatsByUserParams<'req> { Self::default() } - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn min_timestamp(self, min_timestamp: &'req str) -> Self { Self { min_timestamp: min_timestamp, @@ -2512,11 +2512,11 @@ impl<'req> OrgsGetTimeStatsByUserParams<'req> { } } - /// The maximum timestamp to query for stats + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn max_timestamp(self, max_timestamp: &'req str) -> Self { Self { min_timestamp: self.min_timestamp, - max_timestamp: max_timestamp, + max_timestamp: Some(max_timestamp), timestamp_increment: self.timestamp_increment, } } @@ -2534,10 +2534,10 @@ impl<'req> OrgsGetTimeStatsByUserParams<'req> { /// Query parameters for the [Get user stats](Orgs::get_user_stats_async()) endpoint. #[derive(Default, Serialize)] pub struct OrgsGetUserStatsParams<'req> { - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. min_timestamp: &'req str, - /// The maximum timestamp to query for stats - max_timestamp: &'req str, + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + max_timestamp: Option<&'req str>, /// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" page: Option, /// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" @@ -2553,7 +2553,7 @@ impl<'req> OrgsGetUserStatsParams<'req> { Self::default() } - /// The minimum timestamp to query for stats + /// The minimum timestamp to query for stats. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn min_timestamp(self, min_timestamp: &'req str) -> Self { Self { min_timestamp: min_timestamp, @@ -2565,11 +2565,11 @@ impl<'req> OrgsGetUserStatsParams<'req> { } } - /// The maximum timestamp to query for stats + /// The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. pub fn max_timestamp(self, max_timestamp: &'req str) -> Self { Self { min_timestamp: self.min_timestamp, - max_timestamp: max_timestamp, + max_timestamp: Some(max_timestamp), page: self.page, per_page: self.per_page, direction: self.direction, diff --git a/src/models.rs b/src/models.rs index 90719ac..4e8d2a5 100644 --- a/src/models.rs +++ b/src/models.rs @@ -2632,6 +2632,57 @@ pub struct BasicError { pub status: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct BillingUsageReport { + #[serde(rename = "usageItems")] + #[serde(skip_serializing_if="Option::is_none")] + pub usage_items: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct BillingusagereportUsageItems { + /// Date of the usage line item. + #[serde(skip_serializing_if="Option::is_none")] + pub date: Option, + /// Product name. + #[serde(skip_serializing_if="Option::is_none")] + pub product: Option, + /// SKU name. + #[serde(skip_serializing_if="Option::is_none")] + pub sku: Option, + /// Quantity of the usage line item. + #[serde(skip_serializing_if="Option::is_none")] + pub quantity: Option, + /// Unit type of the usage line item. + #[serde(rename = "unitType")] + #[serde(skip_serializing_if="Option::is_none")] + pub unit_type: Option, + /// Price per unit of the usage line item. + #[serde(rename = "pricePerUnit")] + #[serde(skip_serializing_if="Option::is_none")] + pub price_per_unit: Option, + /// Gross amount of the usage line item. + #[serde(rename = "grossAmount")] + #[serde(skip_serializing_if="Option::is_none")] + pub gross_amount: Option, + /// Discount amount of the usage line item. + #[serde(rename = "discountAmount")] + #[serde(skip_serializing_if="Option::is_none")] + pub discount_amount: Option, + /// Net amount of the usage line item. + #[serde(rename = "netAmount")] + #[serde(skip_serializing_if="Option::is_none")] + pub net_amount: Option, + /// Name of the organization. + #[serde(rename = "organizationName")] + #[serde(skip_serializing_if="Option::is_none")] + pub organization_name: Option, + /// Name of the repository. + #[serde(rename = "repositoryName")] + #[serde(skip_serializing_if="Option::is_none")] + pub repository_name: Option, +} + /// Blob #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct Blob { @@ -9073,7 +9124,7 @@ pub struct CopilotUsageMetricsDay { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct CopilotdotcomchatModels { - /// Name of the language used for Copilot code completion suggestions, for the given editor. + /// Name of the model used for Copilot code completion suggestions. If the default model is used will appear as 'default'. #[serde(skip_serializing_if="Option::is_none")] pub name: Option, /// Indicates whether a model is custom or default. @@ -9092,7 +9143,7 @@ pub struct CopilotdotcomchatModels { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct CopilotdotcompullrequestsModels { - /// Name of the language used for Copilot code completion suggestions, for the given editor. + /// Name of the model used for Copilot code completion suggestions. If the default model is used will appear as 'default'. #[serde(skip_serializing_if="Option::is_none")] pub name: Option, /// Indicates whether a model is custom or default. @@ -9138,7 +9189,7 @@ pub struct CopilotidechatEditors { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct CopilotidechatModels { - /// Name of the language used for Copilot code completion suggestions, for the given editor. + /// Name of the model used for Copilot code completion suggestions. If the default model is used will appear as 'default'. #[serde(skip_serializing_if="Option::is_none")] pub name: Option, /// Indicates whether a model is custom or default. @@ -9211,7 +9262,7 @@ pub struct CopilotidecodecompletionsLanguages1 { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct CopilotidecodecompletionsModels { - /// Name of the language used for Copilot code completion suggestions, for the given editor. + /// Name of the model used for Copilot code completion suggestions. If the default model is used will appear as 'default'. #[serde(skip_serializing_if="Option::is_none")] pub name: Option, /// Indicates whether a model is custom or default.