Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tabledata.list return type #67

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/model/table_data_list_response.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use serde::{Deserialize, Serialize};

use crate::model::table_row::TableRow;

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TableDataListResponse {
/// The resource type of the response.
#[serde(skip_serializing_if = "Option::is_none")]
pub kind: Option<String>,

/// Etag to the response.
#[serde(skip_serializing_if = "Option::is_none")]
pub etag: Option<String>,

/// Total rows of the entire table. In order to show default value "0", we have to present it as string.
#[serde(skip_serializing_if = "Option::is_none")]
pub total_rows: Option<String>,

/// When this field is non-empty, it indicates that additional results are available.
/// To request the next page of data, set the pageToken field of your next tabledata.list
/// call to the string returned in this field.
#[serde(skip_serializing_if = "Option::is_none")]
pub page_token: Option<String>,

/// Repeated rows as result.
#[serde(skip_serializing_if = "Option::is_none")]
pub rows: Option<Vec<TableRow>>,
}
3 changes: 2 additions & 1 deletion src/tabledata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::error::BQError;
use crate::model::data_format_options::DataFormatOptions;
use crate::model::table_data_insert_all_request::TableDataInsertAllRequest;
use crate::model::table_data_insert_all_response::TableDataInsertAllResponse;
use crate::model::table_data_list_response::TableDataListResponse;
use crate::{process_response, urlencode, BIG_QUERY_V2_URL};
use reqwest::Client;

Expand Down Expand Up @@ -79,7 +80,7 @@ impl TableDataApi {
dataset_id: &str,
table_id: &str,
parameters: ListQueryParameters,
) -> Result<TableDataInsertAllResponse, BQError> {
) -> Result<TableDataListResponse, BQError> {
let req_url = format!(
"{base_url}/projects/{project_id}/datasets/{dataset_id}/tables/{table_id}/data",
base_url = self.base_url,
Expand Down