pub struct DatasetApi { /* private fields */ }
Expand description
A dataset API handler.
Implementations§
Source§impl DatasetApi
impl DatasetApi
Sourcepub async fn create(&self, dataset: Dataset) -> Result<Dataset, BQError>
pub async fn create(&self, dataset: Dataset) -> Result<Dataset, BQError>
Creates a new empty dataset.
§Argument
dataset
- The dataset to create
§Example
let (ref project_id, ref dataset_id, ref _table_id, ref sa_key) = env_vars();
let dataset_id = &format!("{}_dataset", dataset_id);
let client = Client::from_service_account_key_file(sa_key).await?;
client.dataset().create(Dataset::new(project_id, dataset_id)).await?;
Sourcepub async fn list(
&self,
project_id: &str,
options: ListOptions,
) -> Result<Datasets, BQError>
pub async fn list( &self, project_id: &str, options: ListOptions, ) -> Result<Datasets, BQError>
Lists all datasets in the specified project to which the user has been granted the READER dataset role.
§Arguments
project_id
- Project ID of the datasets to be listedoptions
- Options
§Example
let (ref project_id, ref dataset_id, ref _table_id, ref sa_key) = env_vars();
let dataset_id = &format!("{}_dataset", dataset_id);
let client = Client::from_service_account_key_file(sa_key).await?;
let datasets = client.dataset().list(project_id, ListOptions::default().all(true)).await?;
for dataset in datasets.datasets.iter() {
// Do some stuff
}
Sourcepub async fn delete(
&self,
project_id: &str,
dataset_id: &str,
delete_contents: bool,
) -> Result<(), BQError>
pub async fn delete( &self, project_id: &str, dataset_id: &str, delete_contents: bool, ) -> Result<(), BQError>
Deletes the dataset specified by the datasetId value. Before you can delete a dataset, you must delete all its tables, either manually or by specifying deleteContents. Immediately after deletion, you can create another dataset with the same name.
§Arguments
project_id
- Project ID of the dataset being deleteddataset_id
- Dataset ID of dataset being deleteddelete_contents
- If True, delete all the tables in the dataset. If False and the dataset contains tables, the request will fail. Default is False
§Example
let (ref project_id, ref dataset_id, ref _table_id, ref sa_key) = env_vars();
let dataset_id = &format!("{}_dataset", dataset_id);
let client = Client::from_service_account_key_file(sa_key).await?;
client.dataset().create(Dataset::new(project_id, dataset_id)).await?;
client.dataset().delete(project_id, dataset_id, true).await?;
Sourcepub async fn delete_if_exists(
&self,
project_id: &str,
dataset_id: &str,
delete_contents: bool,
) -> bool
pub async fn delete_if_exists( &self, project_id: &str, dataset_id: &str, delete_contents: bool, ) -> bool
Deletes the dataset specified by the datasetId value and returns true or returs false when the dataset doesn’t exist. Before you can delete a dataset, you must delete all its tables, either manually or by specifying deleteContents. Immediately after deletion, you can create another dataset with the same name.
§Arguments
project_id
- Project ID of the dataset being deleteddataset_id
- Dataset ID of dataset being deleteddelete_contents
- If True, delete all the tables in the dataset. If False and the dataset contains tables, the request will fail. Default is False
§Example
let (ref project_id, ref dataset_id, ref _table_id, ref sa_key) = env_vars();
let dataset_id = &format!("{}_dataset", dataset_id);
let client = Client::from_service_account_key_file(sa_key).await?;
client.dataset().delete_if_exists(project_id, dataset_id, true);
Sourcepub async fn get(
&self,
project_id: &str,
dataset_id: &str,
) -> Result<Dataset, BQError>
pub async fn get( &self, project_id: &str, dataset_id: &str, ) -> Result<Dataset, BQError>
Returns the dataset specified by datasetID.
§Arguments
project_id
- Project ID of the requested datasetdataset_id
- Dataset ID of the requested dataset
§Example
let (ref project_id, ref dataset_id, ref _table_id, ref sa_key) = env_vars();
let dataset_id = &format!("{}_dataset", dataset_id);
let client = Client::from_service_account_key_file(sa_key).await?;
client.dataset().create(Dataset::new(project_id, dataset_id)).await?;
let dataset = client.dataset().get(project_id, dataset_id).await?;
Sourcepub async fn patch(
&self,
project_id: &str,
dataset_id: &str,
dataset: Dataset,
) -> Result<Dataset, BQError>
pub async fn patch( &self, project_id: &str, dataset_id: &str, dataset: Dataset, ) -> Result<Dataset, BQError>
Updates information in an existing dataset. The update method replaces the entire dataset resource, whereas the patch method only replaces fields that are provided in the submitted dataset resource. This method supports patch semantics.
§Arguments
- dataset - The request body contains an instance of Dataset.
Sourcepub async fn update(
&self,
project_id: &str,
dataset_id: &str,
dataset: Dataset,
) -> Result<Dataset, BQError>
pub async fn update( &self, project_id: &str, dataset_id: &str, dataset: Dataset, ) -> Result<Dataset, BQError>
Updates information in an existing dataset. The update method replaces the entire dataset resource, whereas the patch method only replaces fields that are provided in the submitted dataset resource.
§Arguments
- dataset - The request body contains an instance of Dataset.
pub async fn information_schema_schemata( &self, project_id: &str, region: &str, ) -> Result<Vec<Schemata>, BQError>
Trait Implementations§
Source§impl Clone for DatasetApi
impl Clone for DatasetApi
Source§fn clone(&self) -> DatasetApi
fn clone(&self) -> DatasetApi
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for DatasetApi
impl !RefUnwindSafe for DatasetApi
impl Send for DatasetApi
impl Sync for DatasetApi
impl Unpin for DatasetApi
impl !UnwindSafe for DatasetApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request