Skip to main content

google_maps_mapsplatformdatasets_v1/
client.rs

1// Copyright 2026 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Maps Platform Datasets API.
22///
23/// # Example
24/// ```
25/// # use google_maps_mapsplatformdatasets_v1::client::MapsPlatformDatasets;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28///    parent: &str,
29/// ) -> anyhow::Result<()> {
30///     let client = MapsPlatformDatasets::builder().build().await?;
31///     let mut list = client.list_datasets()
32///         .set_parent(parent)
33///         .by_item();
34///     while let Some(item) = list.next().await.transpose()? {
35///         println!("{:?}", item);
36///     }
37///     Ok(())
38/// }
39/// ```
40///
41/// # Service Description
42///
43/// Service definition for the Maps Platform Datasets API.
44///
45/// # Configuration
46///
47/// To configure `MapsPlatformDatasets` use the `with_*` methods in the type returned
48/// by [builder()][MapsPlatformDatasets::builder]. The default configuration should
49/// work for most applications. Common configuration changes include
50///
51/// * [with_endpoint()]: by default this client uses the global default endpoint
52///   (`https://mapsplatformdatasets.googleapis.com`). Applications using regional
53///   endpoints or running in restricted networks (e.g. a network configured
54///   with [Private Google Access with VPC Service Controls]) may want to
55///   override this default.
56/// * [with_credentials()]: by default this client uses
57///   [Application Default Credentials]. Applications using custom
58///   authentication may need to override this default.
59///
60/// [with_endpoint()]: super::builder::maps_platform_datasets::ClientBuilder::with_endpoint
61/// [with_credentials()]: super::builder::maps_platform_datasets::ClientBuilder::with_credentials
62/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
63/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
64///
65/// # Pooling and Cloning
66///
67/// `MapsPlatformDatasets` holds a connection pool internally, it is advised to
68/// create one and reuse it. You do not need to wrap `MapsPlatformDatasets` in
69/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
70/// already uses an `Arc` internally.
71#[derive(Clone, Debug)]
72pub struct MapsPlatformDatasets {
73    inner: std::sync::Arc<dyn super::stub::dynamic::MapsPlatformDatasets>,
74}
75
76impl MapsPlatformDatasets {
77    /// Returns a builder for [MapsPlatformDatasets].
78    ///
79    /// ```
80    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
81    /// # use google_maps_mapsplatformdatasets_v1::client::MapsPlatformDatasets;
82    /// let client = MapsPlatformDatasets::builder().build().await?;
83    /// # Ok(()) }
84    /// ```
85    pub fn builder() -> super::builder::maps_platform_datasets::ClientBuilder {
86        crate::new_client_builder(super::builder::maps_platform_datasets::client::Factory)
87    }
88
89    /// Creates a new client from the provided stub.
90    ///
91    /// The most common case for calling this function is in tests mocking the
92    /// client's behavior.
93    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
94    where
95        T: super::stub::MapsPlatformDatasets + 'static,
96    {
97        Self { inner: stub.into() }
98    }
99
100    pub(crate) async fn new(
101        config: gaxi::options::ClientConfig,
102    ) -> crate::ClientBuilderResult<Self> {
103        let inner = Self::build_inner(config).await?;
104        Ok(Self { inner })
105    }
106
107    async fn build_inner(
108        conf: gaxi::options::ClientConfig,
109    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::MapsPlatformDatasets>>
110    {
111        if gaxi::options::tracing_enabled(&conf) {
112            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
113        }
114        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
115    }
116
117    async fn build_transport(
118        conf: gaxi::options::ClientConfig,
119    ) -> crate::ClientBuilderResult<impl super::stub::MapsPlatformDatasets> {
120        super::transport::MapsPlatformDatasets::new(conf).await
121    }
122
123    async fn build_with_tracing(
124        conf: gaxi::options::ClientConfig,
125    ) -> crate::ClientBuilderResult<impl super::stub::MapsPlatformDatasets> {
126        Self::build_transport(conf)
127            .await
128            .map(super::tracing::MapsPlatformDatasets::new)
129    }
130
131    /// Creates a new dataset for the specified project.
132    ///
133    /// # Example
134    /// ```
135    /// # use google_maps_mapsplatformdatasets_v1::client::MapsPlatformDatasets;
136    /// use google_maps_mapsplatformdatasets_v1::model::Dataset;
137    /// use google_maps_mapsplatformdatasets_v1::Result;
138    /// async fn sample(
139    ///    client: &MapsPlatformDatasets, parent: &str
140    /// ) -> Result<()> {
141    ///     let response = client.create_dataset()
142    ///         .set_parent(parent)
143    ///         .set_dataset(
144    ///             Dataset::new()/* set fields */
145    ///         )
146    ///         .send().await?;
147    ///     println!("response {:?}", response);
148    ///     Ok(())
149    /// }
150    /// ```
151    pub fn create_dataset(&self) -> super::builder::maps_platform_datasets::CreateDataset {
152        super::builder::maps_platform_datasets::CreateDataset::new(self.inner.clone())
153    }
154
155    /// Updates the metadata for the dataset.
156    ///
157    /// # Example
158    /// ```
159    /// # use google_maps_mapsplatformdatasets_v1::client::MapsPlatformDatasets;
160    /// # extern crate wkt as google_cloud_wkt;
161    /// use google_cloud_wkt::FieldMask;
162    /// use google_maps_mapsplatformdatasets_v1::model::Dataset;
163    /// use google_maps_mapsplatformdatasets_v1::Result;
164    /// async fn sample(
165    ///    client: &MapsPlatformDatasets, project_id: &str, dataset_id: &str
166    /// ) -> Result<()> {
167    ///     let response = client.update_dataset_metadata()
168    ///         .set_dataset(
169    ///             Dataset::new().set_name(format!("projects/{project_id}/datasets/{dataset_id}"))/* set fields */
170    ///         )
171    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
172    ///         .send().await?;
173    ///     println!("response {:?}", response);
174    ///     Ok(())
175    /// }
176    /// ```
177    pub fn update_dataset_metadata(
178        &self,
179    ) -> super::builder::maps_platform_datasets::UpdateDatasetMetadata {
180        super::builder::maps_platform_datasets::UpdateDatasetMetadata::new(self.inner.clone())
181    }
182
183    /// Gets the dataset.
184    ///
185    /// # Example
186    /// ```
187    /// # use google_maps_mapsplatformdatasets_v1::client::MapsPlatformDatasets;
188    /// use google_maps_mapsplatformdatasets_v1::Result;
189    /// async fn sample(
190    ///    client: &MapsPlatformDatasets, project_id: &str, dataset_id: &str
191    /// ) -> Result<()> {
192    ///     let response = client.get_dataset()
193    ///         .set_name(format!("projects/{project_id}/datasets/{dataset_id}"))
194    ///         .send().await?;
195    ///     println!("response {:?}", response);
196    ///     Ok(())
197    /// }
198    /// ```
199    pub fn get_dataset(&self) -> super::builder::maps_platform_datasets::GetDataset {
200        super::builder::maps_platform_datasets::GetDataset::new(self.inner.clone())
201    }
202
203    /// Gets all the errors of a dataset.
204    ///
205    /// # Example
206    /// ```
207    /// # use google_maps_mapsplatformdatasets_v1::client::MapsPlatformDatasets;
208    /// use google_cloud_gax::paginator::ItemPaginator as _;
209    /// use google_maps_mapsplatformdatasets_v1::Result;
210    /// async fn sample(
211    ///    client: &MapsPlatformDatasets
212    /// ) -> Result<()> {
213    ///     let mut list = client.fetch_dataset_errors()
214    ///         /* set fields */
215    ///         .by_item();
216    ///     while let Some(item) = list.next().await.transpose()? {
217    ///         println!("{:?}", item);
218    ///     }
219    ///     Ok(())
220    /// }
221    /// ```
222    pub fn fetch_dataset_errors(
223        &self,
224    ) -> super::builder::maps_platform_datasets::FetchDatasetErrors {
225        super::builder::maps_platform_datasets::FetchDatasetErrors::new(self.inner.clone())
226    }
227
228    /// Lists all the datasets for the specified project.
229    ///
230    /// # Example
231    /// ```
232    /// # use google_maps_mapsplatformdatasets_v1::client::MapsPlatformDatasets;
233    /// use google_cloud_gax::paginator::ItemPaginator as _;
234    /// use google_maps_mapsplatformdatasets_v1::Result;
235    /// async fn sample(
236    ///    client: &MapsPlatformDatasets, parent: &str
237    /// ) -> Result<()> {
238    ///     let mut list = client.list_datasets()
239    ///         .set_parent(parent)
240    ///         .by_item();
241    ///     while let Some(item) = list.next().await.transpose()? {
242    ///         println!("{:?}", item);
243    ///     }
244    ///     Ok(())
245    /// }
246    /// ```
247    pub fn list_datasets(&self) -> super::builder::maps_platform_datasets::ListDatasets {
248        super::builder::maps_platform_datasets::ListDatasets::new(self.inner.clone())
249    }
250
251    /// Deletes the specified dataset.
252    ///
253    /// # Example
254    /// ```
255    /// # use google_maps_mapsplatformdatasets_v1::client::MapsPlatformDatasets;
256    /// use google_maps_mapsplatformdatasets_v1::Result;
257    /// async fn sample(
258    ///    client: &MapsPlatformDatasets, project_id: &str, dataset_id: &str
259    /// ) -> Result<()> {
260    ///     client.delete_dataset()
261    ///         .set_name(format!("projects/{project_id}/datasets/{dataset_id}"))
262    ///         .send().await?;
263    ///     Ok(())
264    /// }
265    /// ```
266    pub fn delete_dataset(&self) -> super::builder::maps_platform_datasets::DeleteDataset {
267        super::builder::maps_platform_datasets::DeleteDataset::new(self.inner.clone())
268    }
269}