lago_types/requests/
api_log.rs

1use crate::models::PaginationParams;
2
3use crate::filters::{api_log::ApiLogFilters, common::ListFilters};
4
5/// Request parameters for listing API logs.
6///
7/// This struct combines pagination parameters and API log-specific filters
8/// to build a comprehensive request for retrieving API log lists.
9#[derive(Debug, Clone)]
10pub struct ListApiLogsRequest {
11    pub pagination: PaginationParams,
12    pub filters: ApiLogFilters,
13}
14
15impl ListApiLogsRequest {
16    /// Creates a new empty list API logs request.
17    ///
18    /// # Returns
19    /// A new `ListApiLogsRequest` instance with default pagination and no filters.
20    pub fn new() -> Self {
21        Self {
22            pagination: PaginationParams::default(),
23            filters: ApiLogFilters::default(),
24        }
25    }
26
27    /// Sets the pagination parameters for the request.
28    ///
29    /// # Arguments
30    /// * `pagination` - The pagination parameters to use
31    ///
32    /// # Returns
33    /// The modified request instance for method chaining.
34    pub fn with_pagination(mut self, pagination: PaginationParams) -> Self {
35        self.pagination = pagination;
36        self
37    }
38
39    /// Sets the API log filters for the request.
40    ///
41    /// # Arguments
42    /// * `filters` - The API log filters to apply
43    ///
44    /// # Returns
45    /// The modified request instance for method chaining.
46    pub fn with_filters(mut self, filters: ApiLogFilters) -> Self {
47        self.filters = filters;
48        self
49    }
50
51    /// Converts the request parameters into HTTP query parameters.
52    ///
53    /// # Returns
54    /// A vector of query parameter tuples containing both pagination and filter criteria.
55    pub fn to_query_params(&self) -> Vec<(&str, String)> {
56        let mut params = self.pagination.to_query_params();
57        params.extend(self.filters.to_query_params());
58        params
59    }
60}
61
62impl Default for ListApiLogsRequest {
63    fn default() -> Self {
64        Self::new()
65    }
66}
67
68/// Request parameters for retrieving a specific API log.
69///
70/// This struct contains the identifier needed to fetch a single API log
71/// from the API.
72#[derive(Debug, Clone)]
73pub struct GetApiLogRequest {
74    pub request_id: String,
75}
76
77impl GetApiLogRequest {
78    /// Creates a new get API log request.
79    ///
80    /// # Arguments
81    /// * `request_id` - The unique identifier of the API log to retrieve
82    ///
83    /// # Returns
84    /// A new `GetApiLogRequest` instance with the specified request ID.
85    pub fn new(request_id: String) -> Self {
86        Self { request_id }
87    }
88}