Struct gcp_bigquery_client::dataset::DatasetApi
source · [−]pub struct DatasetApi { /* private fields */ }
Expand description
A dataset API handler.
Implementations
sourceimpl 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
sourceimpl Clone for DatasetApi
impl Clone for DatasetApi
sourcefn clone(&self) -> DatasetApi
fn clone(&self) -> DatasetApi
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for DatasetApi
impl Send for DatasetApi
impl Sync for DatasetApi
impl Unpin for DatasetApi
impl !UnwindSafe for DatasetApi
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more