google_spectrum1_explorer/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11// ########
12// HUB ###
13// ######
14
15/// Central instance to access all Spectrum related resource activities
16///
17/// # Examples
18///
19/// Instantiate a new hub
20///
21/// ```test_harness,no_run
22/// extern crate hyper;
23/// extern crate hyper_rustls;
24/// extern crate google_spectrum1_explorer as spectrum1_explorer;
25/// use spectrum1_explorer::api::PawsGetSpectrumBatchRequest;
26/// use spectrum1_explorer::{Result, Error};
27/// # async fn dox() {
28/// use spectrum1_explorer::{Spectrum, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29///
30/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
31/// // `client_secret`, among other things.
32/// let secret: yup_oauth2::ApplicationSecret = Default::default();
33/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
34/// // unless you replace `None` with the desired Flow.
35/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
36/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
37/// // retrieve them from storage.
38/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
39/// .with_native_roots()
40/// .unwrap()
41/// .https_only()
42/// .enable_http2()
43/// .build();
44///
45/// let executor = hyper_util::rt::TokioExecutor::new();
46/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
47/// secret,
48/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
49/// yup_oauth2::client::CustomHyperClientBuilder::from(
50/// hyper_util::client::legacy::Client::builder(executor).build(connector),
51/// ),
52/// ).build().await.unwrap();
53///
54/// let client = hyper_util::client::legacy::Client::builder(
55/// hyper_util::rt::TokioExecutor::new()
56/// )
57/// .build(
58/// hyper_rustls::HttpsConnectorBuilder::new()
59/// .with_native_roots()
60/// .unwrap()
61/// .https_or_http()
62/// .enable_http2()
63/// .build()
64/// );
65/// let mut hub = Spectrum::new(client, auth);
66/// // As the method needs a request, you would usually fill it with the desired information
67/// // into the respective structure. Some of the parts shown here might not be applicable !
68/// // Values shown here are possibly random and not representative !
69/// let mut req = PawsGetSpectrumBatchRequest::default();
70///
71/// // You can configure optional parameters by calling the respective setters at will, and
72/// // execute the final call using `doit()`.
73/// // Values shown here are possibly random and not representative !
74/// let result = hub.paws().get_spectrum_batch(req)
75/// .doit().await;
76///
77/// match result {
78/// Err(e) => match e {
79/// // The Error enum provides details about what exactly happened.
80/// // You can also just use its `Debug`, `Display` or `Error` traits
81/// Error::HttpError(_)
82/// |Error::Io(_)
83/// |Error::MissingAPIKey
84/// |Error::MissingToken(_)
85/// |Error::Cancelled
86/// |Error::UploadSizeLimitExceeded(_, _)
87/// |Error::Failure(_)
88/// |Error::BadRequest(_)
89/// |Error::FieldClash(_)
90/// |Error::JsonDecodeError(_, _) => println!("{}", e),
91/// },
92/// Ok(res) => println!("Success: {:?}", res),
93/// }
94/// # }
95/// ```
96#[derive(Clone)]
97pub struct Spectrum<C> {
98 pub client: common::Client<C>,
99 pub auth: Box<dyn common::GetToken>,
100 _user_agent: String,
101 _base_url: String,
102 _root_url: String,
103}
104
105impl<C> common::Hub for Spectrum<C> {}
106
107impl<'a, C> Spectrum<C> {
108 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Spectrum<C> {
109 Spectrum {
110 client,
111 auth: Box::new(auth),
112 _user_agent: "google-api-rust-client/7.0.0".to_string(),
113 _base_url: "https://www.googleapis.com/spectrum/v1explorer/paws/".to_string(),
114 _root_url: "https://www.googleapis.com/".to_string(),
115 }
116 }
117
118 pub fn paws(&'a self) -> PawMethods<'a, C> {
119 PawMethods { hub: self }
120 }
121
122 /// Set the user-agent header field to use in all requests to the server.
123 /// It defaults to `google-api-rust-client/7.0.0`.
124 ///
125 /// Returns the previously set user-agent.
126 pub fn user_agent(&mut self, agent_name: String) -> String {
127 std::mem::replace(&mut self._user_agent, agent_name)
128 }
129
130 /// Set the base url to use in all requests to the server.
131 /// It defaults to `https://www.googleapis.com/spectrum/v1explorer/paws/`.
132 ///
133 /// Returns the previously set base url.
134 pub fn base_url(&mut self, new_base_url: String) -> String {
135 std::mem::replace(&mut self._base_url, new_base_url)
136 }
137
138 /// Set the root url to use in all requests to the server.
139 /// It defaults to `https://www.googleapis.com/`.
140 ///
141 /// Returns the previously set root url.
142 pub fn root_url(&mut self, new_root_url: String) -> String {
143 std::mem::replace(&mut self._root_url, new_root_url)
144 }
145}
146
147// ############
148// SCHEMAS ###
149// ##########
150/// Antenna characteristics provide additional information, such as the antenna height, antenna type, etc. Whether antenna characteristics must be provided in a request depends on the device type and regulatory domain.
151///
152/// This type is not used in any activity, and only used as *part* of another schema.
153///
154#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
155#[serde_with::serde_as]
156#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
157pub struct AntennaCharacteristics {
158 /// The antenna height in meters. Whether the antenna height is required depends on the device type and the regulatory domain. Note that the height may be negative.
159 pub height: Option<f64>,
160 /// If the height is required, then the height type (AGL for above ground level or AMSL for above mean sea level) is also required. The default is AGL.
161 #[serde(rename = "heightType")]
162 pub height_type: Option<String>,
163 /// The height uncertainty in meters. Whether this is required depends on the regulatory domain.
164 #[serde(rename = "heightUncertainty")]
165 pub height_uncertainty: Option<f64>,
166}
167
168impl common::Part for AntennaCharacteristics {}
169
170/// This message contains the name and URI of a database.
171///
172/// This type is not used in any activity, and only used as *part* of another schema.
173///
174#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
175#[serde_with::serde_as]
176#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
177pub struct DatabaseSpec {
178 /// The display name for a database.
179 pub name: Option<String>,
180 /// The corresponding URI of the database.
181 pub uri: Option<String>,
182}
183
184impl common::Part for DatabaseSpec {}
185
186/// This message is provided by the database to notify devices of an upcoming change to the database URI.
187///
188/// This type is not used in any activity, and only used as *part* of another schema.
189///
190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
191#[serde_with::serde_as]
192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
193pub struct DbUpdateSpec {
194 /// A required list of one or more databases. A device should update its preconfigured list of databases to replace (only) the database that provided the response with the specified entries.
195 pub databases: Option<Vec<DatabaseSpec>>,
196}
197
198impl common::Part for DbUpdateSpec {}
199
200/// Device capabilities provide additional information that may be used by a device to provide additional information to the database that may help it to determine available spectrum. If the database does not support device capabilities it will ignore the parameter altogether.
201///
202/// This type is not used in any activity, and only used as *part* of another schema.
203///
204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
205#[serde_with::serde_as]
206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
207pub struct DeviceCapabilities {
208 /// An optional list of frequency ranges supported by the device. Each element must contain start and stop frequencies in which the device can operate. Channel identifiers are optional. When specified, the database should not return available spectrum that falls outside these ranges or channel IDs.
209 #[serde(rename = "frequencyRanges")]
210 pub frequency_ranges: Option<Vec<FrequencyRange>>,
211}
212
213impl common::Part for DeviceCapabilities {}
214
215/// The device descriptor contains parameters that identify the specific device, such as its manufacturer serial number, regulatory-specific identifier (e.g., FCC ID), and any other device characteristics required by regulatory domains.
216///
217/// This type is not used in any activity, and only used as *part* of another schema.
218///
219#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
220#[serde_with::serde_as]
221#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
222pub struct DeviceDescriptor {
223 /// Specifies the ETSI white space device category. Valid values are the strings master and slave. This field is case-insensitive. Consult the ETSI documentation for details about the device types.
224 #[serde(rename = "etsiEnDeviceCategory")]
225 pub etsi_en_device_category: Option<String>,
226 /// Specifies the ETSI white space device emissions class. The values are represented by numeric strings, such as 1, 2, etc. Consult the ETSI documentation for details about the device types.
227 #[serde(rename = "etsiEnDeviceEmissionsClass")]
228 pub etsi_en_device_emissions_class: Option<String>,
229 /// Specifies the ETSI white space device type. Valid values are single-letter strings, such as A, B, etc. Consult the ETSI documentation for details about the device types.
230 #[serde(rename = "etsiEnDeviceType")]
231 pub etsi_en_device_type: Option<String>,
232 /// Specifies the ETSI white space device technology identifier. The string value must not exceed 64 characters in length. Consult the ETSI documentation for details about the device types.
233 #[serde(rename = "etsiEnTechnologyId")]
234 pub etsi_en_technology_id: Option<String>,
235 /// Specifies the device's FCC certification identifier. The value is an identifier string whose length should not exceed 32 characters. Note that, in practice, a valid FCC ID may be limited to 19 characters.
236 #[serde(rename = "fccId")]
237 pub fcc_id: Option<String>,
238 /// Specifies the TV Band White Space device type, as defined by the FCC. Valid values are FIXED, MODE_1, MODE_2.
239 #[serde(rename = "fccTvbdDeviceType")]
240 pub fcc_tvbd_device_type: Option<String>,
241 /// The manufacturer's ID may be required by the regulatory domain. This should represent the name of the device manufacturer, should be consistent across all devices from the same manufacturer, and should be distinct from that of other manufacturers. The string value must not exceed 64 characters in length.
242 #[serde(rename = "manufacturerId")]
243 pub manufacturer_id: Option<String>,
244 /// The device's model ID may be required by the regulatory domain. The string value must not exceed 64 characters in length.
245 #[serde(rename = "modelId")]
246 pub model_id: Option<String>,
247 /// The list of identifiers for rulesets supported by the device. A database may require that the device provide this list before servicing the device requests. If the database does not support any of the rulesets specified in the list, the database may refuse to service the device requests. If present, the list must contain at least one entry.
248 ///
249 /// For information about the valid requests, see section 9.2 of the PAWS specification. Currently, FccTvBandWhiteSpace-2010 is the only supported ruleset.
250 #[serde(rename = "rulesetIds")]
251 pub ruleset_ids: Option<Vec<String>>,
252 /// The manufacturer's device serial number; required by the applicable regulatory domain. The length of the value must not exceed 64 characters.
253 #[serde(rename = "serialNumber")]
254 pub serial_number: Option<String>,
255}
256
257impl common::Part for DeviceDescriptor {}
258
259/// This parameter contains device-owner information required as part of device registration. The regulatory domains may require additional parameters.
260///
261/// All contact information must be expressed using the structure defined by the vCard format specification. Only the contact fields of vCard are supported:
262/// - fn: Full name of an individual
263/// - org: Name of the organization
264/// - adr: Address fields
265/// - tel: Telephone numbers
266/// - email: Email addresses
267///
268/// Note that the vCard specification defines maximum lengths for each field.
269///
270/// This type is not used in any activity, and only used as *part* of another schema.
271///
272#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
273#[serde_with::serde_as]
274#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
275pub struct DeviceOwner {
276 /// The vCard contact information for the device operator is optional, but may be required by specific regulatory domains.
277 pub operator: Option<Vcard>,
278 /// The vCard contact information for the individual or business that owns the device is required.
279 pub owner: Option<Vcard>,
280}
281
282impl common::Part for DeviceOwner {}
283
284/// The device validity element describes whether a particular device is valid to operate in the regulatory domain.
285///
286/// This type is not used in any activity, and only used as *part* of another schema.
287///
288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
289#[serde_with::serde_as]
290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
291pub struct DeviceValidity {
292 /// The descriptor of the device for which the validity check was requested. It will always be present.
293 #[serde(rename = "deviceDesc")]
294 pub device_desc: Option<DeviceDescriptor>,
295 /// The validity status: true if the device is valid for operation, false otherwise. It will always be present.
296 #[serde(rename = "isValid")]
297 pub is_valid: Option<bool>,
298 /// If the device identifier is not valid, the database may include a reason. The reason may be in any language. The length of the value should not exceed 128 characters.
299 pub reason: Option<String>,
300}
301
302impl common::Part for DeviceValidity {}
303
304/// The start and stop times of an event. This is used to indicate the time period for which a spectrum profile is valid.
305///
306/// Both times are expressed using the format, YYYY-MM-DDThh:mm:ssZ, as defined in RFC3339. The times must be expressed using UTC.
307///
308/// This type is not used in any activity, and only used as *part* of another schema.
309///
310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
311#[serde_with::serde_as]
312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
313pub struct EventTime {
314 /// The inclusive start of the event. It will be present.
315 #[serde(rename = "startTime")]
316 pub start_time: Option<String>,
317 /// The exclusive end of the event. It will be present.
318 #[serde(rename = "stopTime")]
319 pub stop_time: Option<String>,
320}
321
322impl common::Part for EventTime {}
323
324/// A specific range of frequencies together with the associated maximum power level and channel identifier.
325///
326/// This type is not used in any activity, and only used as *part* of another schema.
327///
328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
329#[serde_with::serde_as]
330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
331pub struct FrequencyRange {
332 /// The database may include a channel identifier, when applicable. When it is included, the device should treat it as informative. The length of the identifier should not exceed 16 characters.
333 #[serde(rename = "channelId")]
334 pub channel_id: Option<String>,
335 /// The maximum total power level (EIRP)—computed over the corresponding operating bandwidth—that is permitted within the frequency range. Depending on the context in which the frequency-range element appears, this value may be required. For example, it is required in the available-spectrum response, available-spectrum-batch response, and spectrum-use notification message, but it should not be present (it is not applicable) when the frequency range appears inside a device-capabilities message.
336 #[serde(rename = "maxPowerDBm")]
337 pub max_power_d_bm: Option<f64>,
338 /// The required inclusive start of the frequency range (in Hertz).
339 #[serde(rename = "startHz")]
340 pub start_hz: Option<f64>,
341 /// The required exclusive end of the frequency range (in Hertz).
342 #[serde(rename = "stopHz")]
343 pub stop_hz: Option<f64>,
344}
345
346impl common::Part for FrequencyRange {}
347
348/// This parameter is used to specify the geolocation of the device.
349///
350/// This type is not used in any activity, and only used as *part* of another schema.
351///
352#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
353#[serde_with::serde_as]
354#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
355pub struct GeoLocation {
356 /// The location confidence level, as an integer percentage, may be required, depending on the regulatory domain. When the parameter is optional and not provided, its value is assumed to be 95. Valid values range from 0 to 99, since, in practice, 100-percent confidence is not achievable. The confidence value is meaningful only when geolocation refers to a point with uncertainty.
357 pub confidence: Option<i32>,
358 /// If present, indicates that the geolocation represents a point. Paradoxically, a point is parameterized using an ellipse, where the center represents the location of the point and the distances along the major and minor axes represent the uncertainty. The uncertainty values may be required, depending on the regulatory domain.
359 pub point: Option<GeoLocationEllipse>,
360 /// If present, indicates that the geolocation represents a region. Database support for regions is optional.
361 pub region: Option<GeoLocationPolygon>,
362}
363
364impl common::Part for GeoLocation {}
365
366/// A "point" with uncertainty is represented using the Ellipse shape.
367///
368/// This type is not used in any activity, and only used as *part* of another schema.
369///
370#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
371#[serde_with::serde_as]
372#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
373pub struct GeoLocationEllipse {
374 /// A required geo-spatial point representing the center of the ellipse.
375 pub center: Option<GeoLocationPoint>,
376 /// A floating-point number that expresses the orientation of the ellipse, representing the rotation, in degrees, of the semi-major axis from North towards the East. For example, when the uncertainty is greatest along the North-South direction, orientation is 0 degrees; conversely, if the uncertainty is greatest along the East-West direction, orientation is 90 degrees. When orientation is not present, the orientation is assumed to be 0.
377 pub orientation: Option<f64>,
378 /// A floating-point number that expresses the location uncertainty along the major axis of the ellipse. May be required by the regulatory domain. When the uncertainty is optional, the default value is 0.
379 #[serde(rename = "semiMajorAxis")]
380 pub semi_major_axis: Option<f64>,
381 /// A floating-point number that expresses the location uncertainty along the minor axis of the ellipse. May be required by the regulatory domain. When the uncertainty is optional, the default value is 0.
382 #[serde(rename = "semiMinorAxis")]
383 pub semi_minor_axis: Option<f64>,
384}
385
386impl common::Part for GeoLocationEllipse {}
387
388/// A single geolocation on the globe.
389///
390/// This type is not used in any activity, and only used as *part* of another schema.
391///
392#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
393#[serde_with::serde_as]
394#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
395pub struct GeoLocationPoint {
396 /// A required floating-point number that expresses the latitude in degrees using the WGS84 datum. For details on this encoding, see the National Imagery and Mapping Agency's Technical Report TR8350.2.
397 pub latitude: Option<f64>,
398 /// A required floating-point number that expresses the longitude in degrees using the WGS84 datum. For details on this encoding, see the National Imagery and Mapping Agency's Technical Report TR8350.2.
399 pub longitude: Option<f64>,
400}
401
402impl common::Part for GeoLocationPoint {}
403
404/// A region is represented using the polygonal shape.
405///
406/// This type is not used in any activity, and only used as *part* of another schema.
407///
408#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
409#[serde_with::serde_as]
410#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
411pub struct GeoLocationPolygon {
412 /// When the geolocation describes a region, the exterior field refers to a list of latitude/longitude points that represent the vertices of a polygon. The first and last points must be the same. Thus, a minimum of four points is required. The following polygon restrictions from RFC5491 apply:
413 /// - A connecting line shall not cross another connecting line of the same polygon.
414 /// - The vertices must be defined in a counterclockwise order.
415 /// - The edges of a polygon are defined by the shortest path between two points in space (not a geodesic curve). Consequently, the length between two adjacent vertices should be restricted to a maximum of 130 km.
416 /// - All vertices are assumed to be at the same altitude.
417 /// - Polygon shapes should be restricted to a maximum of 15 vertices (16 points that include the repeated vertex).
418 pub exterior: Option<Vec<GeoLocationPoint>>,
419}
420
421impl common::Part for GeoLocationPolygon {}
422
423/// The schedule of spectrum profiles available at a particular geolocation.
424///
425/// This type is not used in any activity, and only used as *part* of another schema.
426///
427#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
428#[serde_with::serde_as]
429#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
430pub struct GeoSpectrumSchedule {
431 /// The geolocation identifies the location at which the spectrum schedule applies. It will always be present.
432 pub location: Option<GeoLocation>,
433 /// A list of available spectrum profiles and associated times. It will always be present, and at least one schedule must be included (though it may be empty if there is no available spectrum). More than one schedule may be included to represent future changes to the available spectrum.
434 #[serde(rename = "spectrumSchedules")]
435 pub spectrum_schedules: Option<Vec<SpectrumSchedule>>,
436}
437
438impl common::Part for GeoSpectrumSchedule {}
439
440/// The request message for a batch available spectrum query protocol.
441///
442/// # Activities
443///
444/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
445/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
446///
447/// * [get spectrum batch paws](PawGetSpectrumBatchCall) (request)
448#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
449#[serde_with::serde_as]
450#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
451pub struct PawsGetSpectrumBatchRequest {
452 /// Depending on device type and regulatory domain, antenna characteristics may be required.
453 pub antenna: Option<AntennaCharacteristics>,
454 /// The master device may include its device capabilities to limit the available-spectrum batch response to the spectrum that is compatible with its capabilities. The database should not return spectrum that is incompatible with the specified capabilities.
455 pub capabilities: Option<DeviceCapabilities>,
456 /// When the available spectrum request is made on behalf of a specific device (a master or slave device), device descriptor information for the device on whose behalf the request is made is required (in such cases, the requestType parameter must be empty). When a requestType value is specified, device descriptor information may be optional or required according to the rules of the applicable regulatory domain.
457 #[serde(rename = "deviceDesc")]
458 pub device_desc: Option<DeviceDescriptor>,
459 /// A geolocation list is required. This allows a device to specify its current location plus additional anticipated locations when allowed by the regulatory domain. At least one location must be included. Geolocation must be given as the location of the radiation center of the device's antenna. If a location specifies a region, rather than a point, the database may return an UNIMPLEMENTED error if it does not support query by region.
460 ///
461 /// There is no upper limit on the number of locations included in a available spectrum batch request, but the database may restrict the number of locations it supports by returning a response with fewer locations than specified in the batch request. Note that geolocations must be those of the master device (a device with geolocation capability that makes an available spectrum batch request), whether the master device is making the request on its own behalf or on behalf of a slave device (one without geolocation capability).
462 pub locations: Option<Vec<GeoLocation>>,
463 /// When an available spectrum batch request is made by the master device (a device with geolocation capability) on behalf of a slave device (a device without geolocation capability), the rules of the applicable regulatory domain may require the master device to provide its own device descriptor information (in addition to device descriptor information for the slave device in a separate parameter).
464 #[serde(rename = "masterDeviceDesc")]
465 pub master_device_desc: Option<DeviceDescriptor>,
466 /// Depending on device type and regulatory domain, device owner information may be included in an available spectrum batch request. This allows the device to register and get spectrum-availability information in a single request.
467 pub owner: Option<DeviceOwner>,
468 /// The request type parameter is an optional parameter that can be used to modify an available spectrum batch request, but its use depends on applicable regulatory rules. For example, It may be used to request generic slave device parameters without having to specify the device descriptor for a specific device. When the requestType parameter is missing, the request is for a specific device (master or slave), and the device descriptor parameter for the device on whose behalf the batch request is made is required.
469 #[serde(rename = "requestType")]
470 pub request_type: Option<String>,
471 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
472 ///
473 /// Required field.
474 #[serde(rename = "type")]
475 pub type_: Option<String>,
476 /// The PAWS version. Must be exactly 1.0.
477 ///
478 /// Required field.
479 pub version: Option<String>,
480}
481
482impl common::RequestValue for PawsGetSpectrumBatchRequest {}
483
484/// The response message for the batch available spectrum query contains a schedule of available spectrum for the device at multiple locations.
485///
486/// # Activities
487///
488/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
489/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
490///
491/// * [get spectrum batch paws](PawGetSpectrumBatchCall) (response)
492#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
493#[serde_with::serde_as]
494#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
495pub struct PawsGetSpectrumBatchResponse {
496 /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs.
497 #[serde(rename = "databaseChange")]
498 pub database_change: Option<DbUpdateSpec>,
499 /// The database must return in its available spectrum response the device descriptor information it received in the master device's available spectrum batch request.
500 #[serde(rename = "deviceDesc")]
501 pub device_desc: Option<DeviceDescriptor>,
502 /// The available spectrum batch response must contain a geo-spectrum schedule list, The list may be empty if spectrum is not available. The database may return more than one geo-spectrum schedule to represent future changes to the available spectrum. How far in advance a schedule may be provided depends upon the applicable regulatory domain. The database may return available spectrum for fewer geolocations than requested. The device must not make assumptions about the order of the entries in the list, and must use the geolocation value in each geo-spectrum schedule entry to match available spectrum to a location.
503 #[serde(rename = "geoSpectrumSchedules")]
504 pub geo_spectrum_schedules: Option<Vec<GeoSpectrumSchedule>>,
505 /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsGetSpectrumBatchResponse".
506 pub kind: Option<String>,
507 /// The database may return a constraint on the allowed maximum contiguous bandwidth (in Hertz). A regulatory domain may require the database to return this parameter. When this parameter is present in the response, the device must apply this constraint to its spectrum-selection logic to ensure that no single block of spectrum has bandwidth that exceeds this value.
508 #[serde(rename = "maxContiguousBwHz")]
509 pub max_contiguous_bw_hz: Option<f64>,
510 /// The database may return a constraint on the allowed maximum total bandwidth (in Hertz), which does not need to be contiguous. A regulatory domain may require the database to return this parameter. When this parameter is present in the available spectrum batch response, the device must apply this constraint to its spectrum-selection logic to ensure that total bandwidth does not exceed this value.
511 #[serde(rename = "maxTotalBwHz")]
512 pub max_total_bw_hz: Option<f64>,
513 /// For regulatory domains that require a spectrum-usage report from devices, the database must return true for this parameter if the geo-spectrum schedules list is not empty; otherwise, the database should either return false or omit this parameter. If this parameter is present and its value is true, the device must send a spectrum use notify message to the database; otherwise, the device should not send the notification.
514 #[serde(rename = "needsSpectrumReport")]
515 pub needs_spectrum_report: Option<bool>,
516 /// The database should return ruleset information, which identifies the applicable regulatory authority and ruleset for the available spectrum batch response. If included, the device must use the corresponding ruleset to interpret the response. Values provided in the returned ruleset information, such as maxLocationChange, take precedence over any conflicting values provided in the ruleset information returned in a prior initialization response sent by the database to the device.
517 #[serde(rename = "rulesetInfo")]
518 pub ruleset_info: Option<RulesetInfo>,
519 /// The database includes a timestamp of the form, YYYY-MM-DDThh:mm:ssZ (Internet timestamp format per RFC3339), in its available spectrum batch response. The timestamp should be used by the device as a reference for the start and stop times specified in the response spectrum schedules.
520 pub timestamp: Option<String>,
521 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
522 ///
523 /// Required field.
524 #[serde(rename = "type")]
525 pub type_: Option<String>,
526 /// The PAWS version. Must be exactly 1.0.
527 ///
528 /// Required field.
529 pub version: Option<String>,
530}
531
532impl common::ResponseResult for PawsGetSpectrumBatchResponse {}
533
534/// The request message for the available spectrum query protocol which must include the device’s geolocation.
535///
536/// # Activities
537///
538/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
539/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
540///
541/// * [get spectrum paws](PawGetSpectrumCall) (request)
542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
543#[serde_with::serde_as]
544#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
545pub struct PawsGetSpectrumRequest {
546 /// Depending on device type and regulatory domain, the characteristics of the antenna may be required.
547 pub antenna: Option<AntennaCharacteristics>,
548 /// The master device may include its device capabilities to limit the available-spectrum response to the spectrum that is compatible with its capabilities. The database should not return spectrum that is incompatible with the specified capabilities.
549 pub capabilities: Option<DeviceCapabilities>,
550 /// When the available spectrum request is made on behalf of a specific device (a master or slave device), device descriptor information for that device is required (in such cases, the requestType parameter must be empty). When a requestType value is specified, device descriptor information may be optional or required according to the rules of the applicable regulatory domain.
551 #[serde(rename = "deviceDesc")]
552 pub device_desc: Option<DeviceDescriptor>,
553 /// The geolocation of the master device (a device with geolocation capability that makes an available spectrum request) is required whether the master device is making the request on its own behalf or on behalf of a slave device (one without geolocation capability). The location must be the location of the radiation center of the master device's antenna. To support mobile devices, a regulatory domain may allow the anticipated position of the master device to be given instead. If the location specifies a region, rather than a point, the database may return an UNIMPLEMENTED error code if it does not support query by region.
554 pub location: Option<GeoLocation>,
555 /// When an available spectrum request is made by the master device (a device with geolocation capability) on behalf of a slave device (a device without geolocation capability), the rules of the applicable regulatory domain may require the master device to provide its own device descriptor information (in addition to device descriptor information for the slave device, which is provided in a separate parameter).
556 #[serde(rename = "masterDeviceDesc")]
557 pub master_device_desc: Option<DeviceDescriptor>,
558 /// Depending on device type and regulatory domain, device owner information may be included in an available spectrum request. This allows the device to register and get spectrum-availability information in a single request.
559 pub owner: Option<DeviceOwner>,
560 /// The request type parameter is an optional parameter that can be used to modify an available spectrum request, but its use depends on applicable regulatory rules. It may be used, for example, to request generic slave device parameters without having to specify the device descriptor for a specific device. When the requestType parameter is missing, the request is for a specific device (master or slave), and the deviceDesc parameter for the device on whose behalf the request is made is required.
561 #[serde(rename = "requestType")]
562 pub request_type: Option<String>,
563 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
564 ///
565 /// Required field.
566 #[serde(rename = "type")]
567 pub type_: Option<String>,
568 /// The PAWS version. Must be exactly 1.0.
569 ///
570 /// Required field.
571 pub version: Option<String>,
572}
573
574impl common::RequestValue for PawsGetSpectrumRequest {}
575
576/// The response message for the available spectrum query which contains a schedule of available spectrum for the device.
577///
578/// # Activities
579///
580/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
581/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
582///
583/// * [get spectrum paws](PawGetSpectrumCall) (response)
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct PawsGetSpectrumResponse {
588 /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs.
589 #[serde(rename = "databaseChange")]
590 pub database_change: Option<DbUpdateSpec>,
591 /// The database must return, in its available spectrum response, the device descriptor information it received in the master device's available spectrum request.
592 #[serde(rename = "deviceDesc")]
593 pub device_desc: Option<DeviceDescriptor>,
594 /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsGetSpectrumResponse".
595 pub kind: Option<String>,
596 /// The database may return a constraint on the allowed maximum contiguous bandwidth (in Hertz). A regulatory domain may require the database to return this parameter. When this parameter is present in the response, the device must apply this constraint to its spectrum-selection logic to ensure that no single block of spectrum has bandwidth that exceeds this value.
597 #[serde(rename = "maxContiguousBwHz")]
598 pub max_contiguous_bw_hz: Option<f64>,
599 /// The database may return a constraint on the allowed maximum total bandwidth (in Hertz), which need not be contiguous. A regulatory domain may require the database to return this parameter. When this parameter is present in the available spectrum response, the device must apply this constraint to its spectrum-selection logic to ensure that total bandwidth does not exceed this value.
600 #[serde(rename = "maxTotalBwHz")]
601 pub max_total_bw_hz: Option<f64>,
602 /// For regulatory domains that require a spectrum-usage report from devices, the database must return true for this parameter if the spectrum schedule list is not empty; otherwise, the database will either return false or omit this parameter. If this parameter is present and its value is true, the device must send a spectrum use notify message to the database; otherwise, the device must not send the notification.
603 #[serde(rename = "needsSpectrumReport")]
604 pub needs_spectrum_report: Option<bool>,
605 /// The database should return ruleset information, which identifies the applicable regulatory authority and ruleset for the available spectrum response. If included, the device must use the corresponding ruleset to interpret the response. Values provided in the returned ruleset information, such as maxLocationChange, take precedence over any conflicting values provided in the ruleset information returned in a prior initialization response sent by the database to the device.
606 #[serde(rename = "rulesetInfo")]
607 pub ruleset_info: Option<RulesetInfo>,
608 /// The available spectrum response must contain a spectrum schedule list. The list may be empty if spectrum is not available. The database may return more than one spectrum schedule to represent future changes to the available spectrum. How far in advance a schedule may be provided depends on the applicable regulatory domain.
609 #[serde(rename = "spectrumSchedules")]
610 pub spectrum_schedules: Option<Vec<SpectrumSchedule>>,
611 /// The database includes a timestamp of the form YYYY-MM-DDThh:mm:ssZ (Internet timestamp format per RFC3339) in its available spectrum response. The timestamp should be used by the device as a reference for the start and stop times specified in the response spectrum schedules.
612 pub timestamp: Option<String>,
613 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
614 ///
615 /// Required field.
616 #[serde(rename = "type")]
617 pub type_: Option<String>,
618 /// The PAWS version. Must be exactly 1.0.
619 ///
620 /// Required field.
621 pub version: Option<String>,
622}
623
624impl common::ResponseResult for PawsGetSpectrumResponse {}
625
626/// The initialization request message allows the master device to initiate exchange of capabilities with the database.
627///
628/// # Activities
629///
630/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
631/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
632///
633/// * [init paws](PawInitCall) (request)
634#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
635#[serde_with::serde_as]
636#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
637pub struct PawsInitRequest {
638 /// The DeviceDescriptor parameter is required. If the database does not support the device or any of the rulesets specified in the device descriptor, it must return an UNSUPPORTED error code in the error response.
639 #[serde(rename = "deviceDesc")]
640 pub device_desc: Option<DeviceDescriptor>,
641 /// A device's geolocation is required.
642 pub location: Option<GeoLocation>,
643 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
644 ///
645 /// Required field.
646 #[serde(rename = "type")]
647 pub type_: Option<String>,
648 /// The PAWS version. Must be exactly 1.0.
649 ///
650 /// Required field.
651 pub version: Option<String>,
652}
653
654impl common::RequestValue for PawsInitRequest {}
655
656/// The initialization response message communicates database parameters to the requesting device.
657///
658/// # Activities
659///
660/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
661/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
662///
663/// * [init paws](PawInitCall) (response)
664#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
665#[serde_with::serde_as]
666#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
667pub struct PawsInitResponse {
668 /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs.
669 #[serde(rename = "databaseChange")]
670 pub database_change: Option<DbUpdateSpec>,
671 /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsInitResponse".
672 pub kind: Option<String>,
673 /// The rulesetInfo parameter must be included in the response. This parameter specifies the regulatory domain and parameters applicable to that domain. The database must include the authority field, which defines the regulatory domain for the location specified in the INIT_REQ message.
674 #[serde(rename = "rulesetInfo")]
675 pub ruleset_info: Option<RulesetInfo>,
676 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
677 ///
678 /// Required field.
679 #[serde(rename = "type")]
680 pub type_: Option<String>,
681 /// The PAWS version. Must be exactly 1.0.
682 ///
683 /// Required field.
684 pub version: Option<String>,
685}
686
687impl common::ResponseResult for PawsInitResponse {}
688
689/// The spectrum-use notification message which must contain the geolocation of the Device and parameters required by the regulatory domain.
690///
691/// # Activities
692///
693/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
694/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
695///
696/// * [notify spectrum use paws](PawNotifySpectrumUseCall) (request)
697#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
698#[serde_with::serde_as]
699#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
700pub struct PawsNotifySpectrumUseRequest {
701 /// Device descriptor information is required in the spectrum-use notification message.
702 #[serde(rename = "deviceDesc")]
703 pub device_desc: Option<DeviceDescriptor>,
704 /// The geolocation of the master device (the device that is sending the spectrum-use notification) to the database is required in the spectrum-use notification message.
705 pub location: Option<GeoLocation>,
706 /// A spectrum list is required in the spectrum-use notification. The list specifies the spectrum that the device expects to use, which includes frequency ranges and maximum power levels. The list may be empty if the device decides not to use any of spectrum. For consistency, the psdBandwidthHz value should match that from one of the spectrum elements in the corresponding available spectrum response previously sent to the device by the database. Note that maximum power levels in the spectrum element must be expressed as power spectral density over the specified psdBandwidthHz value. The actual bandwidth to be used (as computed from the start and stop frequencies) may be different from the psdBandwidthHz value. As an example, when regulatory rules express maximum power spectral density in terms of maximum power over any 100 kHz band, then the psdBandwidthHz value should be set to 100 kHz, even though the actual bandwidth used can be 20 kHz.
707 pub spectra: Option<Vec<SpectrumMessage>>,
708 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
709 ///
710 /// Required field.
711 #[serde(rename = "type")]
712 pub type_: Option<String>,
713 /// The PAWS version. Must be exactly 1.0.
714 ///
715 /// Required field.
716 pub version: Option<String>,
717}
718
719impl common::RequestValue for PawsNotifySpectrumUseRequest {}
720
721/// An empty response to the notification.
722///
723/// # Activities
724///
725/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
726/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
727///
728/// * [notify spectrum use paws](PawNotifySpectrumUseCall) (response)
729#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
730#[serde_with::serde_as]
731#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
732pub struct PawsNotifySpectrumUseResponse {
733 /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsNotifySpectrumUseResponse".
734 pub kind: Option<String>,
735 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
736 ///
737 /// Required field.
738 #[serde(rename = "type")]
739 pub type_: Option<String>,
740 /// The PAWS version. Must be exactly 1.0.
741 ///
742 /// Required field.
743 pub version: Option<String>,
744}
745
746impl common::ResponseResult for PawsNotifySpectrumUseResponse {}
747
748/// The registration request message contains the required registration parameters.
749///
750/// # Activities
751///
752/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
753/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
754///
755/// * [register paws](PawRegisterCall) (request)
756#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
757#[serde_with::serde_as]
758#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
759pub struct PawsRegisterRequest {
760 /// Antenna characteristics, including its height and height type.
761 pub antenna: Option<AntennaCharacteristics>,
762 /// A DeviceDescriptor is required.
763 #[serde(rename = "deviceDesc")]
764 pub device_desc: Option<DeviceDescriptor>,
765 /// Device owner information is required.
766 #[serde(rename = "deviceOwner")]
767 pub device_owner: Option<DeviceOwner>,
768 /// A device's geolocation is required.
769 pub location: Option<GeoLocation>,
770 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
771 ///
772 /// Required field.
773 #[serde(rename = "type")]
774 pub type_: Option<String>,
775 /// The PAWS version. Must be exactly 1.0.
776 ///
777 /// Required field.
778 pub version: Option<String>,
779}
780
781impl common::RequestValue for PawsRegisterRequest {}
782
783/// The registration response message simply acknowledges receipt of the request and is otherwise empty.
784///
785/// # Activities
786///
787/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
788/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
789///
790/// * [register paws](PawRegisterCall) (response)
791#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
792#[serde_with::serde_as]
793#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
794pub struct PawsRegisterResponse {
795 /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs.
796 #[serde(rename = "databaseChange")]
797 pub database_change: Option<DbUpdateSpec>,
798 /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsRegisterResponse".
799 pub kind: Option<String>,
800 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
801 ///
802 /// Required field.
803 #[serde(rename = "type")]
804 pub type_: Option<String>,
805 /// The PAWS version. Must be exactly 1.0.
806 ///
807 /// Required field.
808 pub version: Option<String>,
809}
810
811impl common::ResponseResult for PawsRegisterResponse {}
812
813/// The device validation request message.
814///
815/// # Activities
816///
817/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
818/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
819///
820/// * [verify device paws](PawVerifyDeviceCall) (request)
821#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
822#[serde_with::serde_as]
823#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
824pub struct PawsVerifyDeviceRequest {
825 /// A list of device descriptors, which specifies the slave devices to be validated, is required.
826 #[serde(rename = "deviceDescs")]
827 pub device_descs: Option<Vec<DeviceDescriptor>>,
828 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
829 ///
830 /// Required field.
831 #[serde(rename = "type")]
832 pub type_: Option<String>,
833 /// The PAWS version. Must be exactly 1.0.
834 ///
835 /// Required field.
836 pub version: Option<String>,
837}
838
839impl common::RequestValue for PawsVerifyDeviceRequest {}
840
841/// The device validation response message.
842///
843/// # Activities
844///
845/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
846/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
847///
848/// * [verify device paws](PawVerifyDeviceCall) (response)
849#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
850#[serde_with::serde_as]
851#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
852pub struct PawsVerifyDeviceResponse {
853 /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs.
854 #[serde(rename = "databaseChange")]
855 pub database_change: Option<DbUpdateSpec>,
856 /// A device validities list is required in the device validation response to report whether each slave device listed in a previous device validation request is valid. The number of entries must match the number of device descriptors listed in the previous device validation request.
857 #[serde(rename = "deviceValidities")]
858 pub device_validities: Option<Vec<DeviceValidity>>,
859 /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsVerifyDeviceResponse".
860 pub kind: Option<String>,
861 /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...).
862 ///
863 /// Required field.
864 #[serde(rename = "type")]
865 pub type_: Option<String>,
866 /// The PAWS version. Must be exactly 1.0.
867 ///
868 /// Required field.
869 pub version: Option<String>,
870}
871
872impl common::ResponseResult for PawsVerifyDeviceResponse {}
873
874/// This contains parameters for the ruleset of a regulatory domain that is communicated using the initialization and available-spectrum processes.
875///
876/// This type is not used in any activity, and only used as *part* of another schema.
877///
878#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
879#[serde_with::serde_as]
880#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
881pub struct RulesetInfo {
882 /// The regulatory domain to which the ruleset belongs is required. It must be a 2-letter country code. The device should use this to determine additional device behavior required by the associated regulatory domain.
883 pub authority: Option<String>,
884 /// The maximum location change in meters is required in the initialization response, but optional otherwise. When the device changes location by more than this specified distance, it must contact the database to get the available spectrum for the new location. If the device is using spectrum that is no longer available, it must immediately cease use of the spectrum under rules for database-managed spectrum. If this value is provided within the context of an available-spectrum response, it takes precedence over the value within the initialization response.
885 #[serde(rename = "maxLocationChange")]
886 pub max_location_change: Option<f64>,
887 /// The maximum duration, in seconds, between requests for available spectrum. It is required in the initialization response, but optional otherwise. The device must contact the database to get available spectrum no less frequently than this duration. If the new spectrum information indicates that the device is using spectrum that is no longer available, it must immediately cease use of those frequencies under rules for database-managed spectrum. If this value is provided within the context of an available-spectrum response, it takes precedence over the value within the initialization response.
888 #[serde(rename = "maxPollingSecs")]
889 pub max_polling_secs: Option<i32>,
890 /// The identifiers of the rulesets supported for the device's location. The database should include at least one applicable ruleset in the initialization response. The device may use the ruleset identifiers to determine parameters to include in subsequent requests. Within the context of the available-spectrum responses, the database should include the identifier of the ruleset that it used to determine the available-spectrum response. If included, the device must use the specified ruleset to interpret the response. If the device does not support the indicated ruleset, it must not operate in the spectrum governed by the ruleset.
891 #[serde(rename = "rulesetIds")]
892 pub ruleset_ids: Option<Vec<String>>,
893}
894
895impl common::Part for RulesetInfo {}
896
897/// Available spectrum can be logically characterized by a list of frequency ranges and permissible power levels for each range.
898///
899/// This type is not used in any activity, and only used as *part* of another schema.
900///
901#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
902#[serde_with::serde_as]
903#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
904pub struct SpectrumMessage {
905 /// The bandwidth (in Hertz) for which permissible power levels are specified. For example, FCC regulation would require only one spectrum specification at 6MHz bandwidth, but Ofcom regulation would require two specifications, at 0.1MHz and 8MHz. This parameter may be empty if there is no available spectrum. It will be present otherwise.
906 pub bandwidth: Option<f64>,
907 /// The list of frequency ranges and permissible power levels. The list may be empty if there is no available spectrum, otherwise it will be present.
908 #[serde(rename = "frequencyRanges")]
909 pub frequency_ranges: Option<Vec<FrequencyRange>>,
910}
911
912impl common::Part for SpectrumMessage {}
913
914/// The spectrum schedule element combines an event time with spectrum profile to define a time period in which the profile is valid.
915///
916/// This type is not used in any activity, and only used as *part* of another schema.
917///
918#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
919#[serde_with::serde_as]
920#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
921pub struct SpectrumSchedule {
922 /// The event time expresses when the spectrum profile is valid. It will always be present.
923 #[serde(rename = "eventTime")]
924 pub event_time: Option<EventTime>,
925 /// A list of spectrum messages representing the usable profile. It will always be present, but may be empty when there is no available spectrum.
926 pub spectra: Option<Vec<SpectrumMessage>>,
927}
928
929impl common::Part for SpectrumSchedule {}
930
931/// A vCard-in-JSON message that contains only the fields needed for PAWS:
932/// - fn: Full name of an individual
933/// - org: Name of the organization
934/// - adr: Address fields
935/// - tel: Telephone numbers
936/// - email: Email addresses
937///
938/// This type is not used in any activity, and only used as *part* of another schema.
939///
940#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
941#[serde_with::serde_as]
942#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
943pub struct Vcard {
944 /// The street address of the entity.
945 pub adr: Option<VcardAddress>,
946 /// An email address that can be used to reach the contact.
947 pub email: Option<VcardTypedText>,
948 /// The full name of the contact person. For example: John A. Smith.
949 #[serde(rename = "fn")]
950 pub fn_: Option<String>,
951 /// The organization associated with the registering entity.
952 pub org: Option<VcardTypedText>,
953 /// A telephone number that can be used to call the contact.
954 pub tel: Option<VcardTelephone>,
955}
956
957impl common::Part for Vcard {}
958
959/// The structure used to represent a street address.
960///
961/// This type is not used in any activity, and only used as *part* of another schema.
962///
963#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
964#[serde_with::serde_as]
965#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
966pub struct VcardAddress {
967 /// The postal code associated with the address. For example: 94423.
968 pub code: Option<String>,
969 /// The country name. For example: US.
970 pub country: Option<String>,
971 /// The city or local equivalent portion of the address. For example: San Jose.
972 pub locality: Option<String>,
973 /// An optional post office box number.
974 pub pobox: Option<String>,
975 /// The state or local equivalent portion of the address. For example: CA.
976 pub region: Option<String>,
977 /// The street number and name. For example: 123 Any St.
978 pub street: Option<String>,
979}
980
981impl common::Part for VcardAddress {}
982
983/// The structure used to represent a telephone number.
984///
985/// This type is not used in any activity, and only used as *part* of another schema.
986///
987#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
988#[serde_with::serde_as]
989#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
990pub struct VcardTelephone {
991 /// A nested telephone URI of the form: tel:+1-123-456-7890.
992 pub uri: Option<String>,
993}
994
995impl common::Part for VcardTelephone {}
996
997/// The structure used to represent an organization and an email address.
998///
999/// This type is not used in any activity, and only used as *part* of another schema.
1000///
1001#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1002#[serde_with::serde_as]
1003#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1004pub struct VcardTypedText {
1005 /// The text string associated with this item. For example, for an org field: ACME, inc. For an email field: smith@example.com.
1006 pub text: Option<String>,
1007}
1008
1009impl common::Part for VcardTypedText {}
1010
1011// ###################
1012// MethodBuilders ###
1013// #################
1014
1015/// A builder providing access to all methods supported on *paw* resources.
1016/// It is not used directly, but through the [`Spectrum`] hub.
1017///
1018/// # Example
1019///
1020/// Instantiate a resource builder
1021///
1022/// ```test_harness,no_run
1023/// extern crate hyper;
1024/// extern crate hyper_rustls;
1025/// extern crate google_spectrum1_explorer as spectrum1_explorer;
1026///
1027/// # async fn dox() {
1028/// use spectrum1_explorer::{Spectrum, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1029///
1030/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1031/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1032/// .with_native_roots()
1033/// .unwrap()
1034/// .https_only()
1035/// .enable_http2()
1036/// .build();
1037///
1038/// let executor = hyper_util::rt::TokioExecutor::new();
1039/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1040/// secret,
1041/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1042/// yup_oauth2::client::CustomHyperClientBuilder::from(
1043/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1044/// ),
1045/// ).build().await.unwrap();
1046///
1047/// let client = hyper_util::client::legacy::Client::builder(
1048/// hyper_util::rt::TokioExecutor::new()
1049/// )
1050/// .build(
1051/// hyper_rustls::HttpsConnectorBuilder::new()
1052/// .with_native_roots()
1053/// .unwrap()
1054/// .https_or_http()
1055/// .enable_http2()
1056/// .build()
1057/// );
1058/// let mut hub = Spectrum::new(client, auth);
1059/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1060/// // like `get_spectrum(...)`, `get_spectrum_batch(...)`, `init(...)`, `notify_spectrum_use(...)`, `register(...)` and `verify_device(...)`
1061/// // to build up your call.
1062/// let rb = hub.paws();
1063/// # }
1064/// ```
1065pub struct PawMethods<'a, C>
1066where
1067 C: 'a,
1068{
1069 hub: &'a Spectrum<C>,
1070}
1071
1072impl<'a, C> common::MethodsBuilder for PawMethods<'a, C> {}
1073
1074impl<'a, C> PawMethods<'a, C> {
1075 /// Create a builder to help you perform the following task:
1076 ///
1077 /// Requests information about the available spectrum for a device at a location. Requests from a fixed-mode device must include owner information so the device can be registered with the database.
1078 ///
1079 /// # Arguments
1080 ///
1081 /// * `request` - No description provided.
1082 pub fn get_spectrum(&self, request: PawsGetSpectrumRequest) -> PawGetSpectrumCall<'a, C> {
1083 PawGetSpectrumCall {
1084 hub: self.hub,
1085 _request: request,
1086 _delegate: Default::default(),
1087 _additional_params: Default::default(),
1088 }
1089 }
1090
1091 /// Create a builder to help you perform the following task:
1092 ///
1093 /// The Google Spectrum Database does not support batch requests, so this method always yields an UNIMPLEMENTED error.
1094 ///
1095 /// # Arguments
1096 ///
1097 /// * `request` - No description provided.
1098 pub fn get_spectrum_batch(
1099 &self,
1100 request: PawsGetSpectrumBatchRequest,
1101 ) -> PawGetSpectrumBatchCall<'a, C> {
1102 PawGetSpectrumBatchCall {
1103 hub: self.hub,
1104 _request: request,
1105 _delegate: Default::default(),
1106 _additional_params: Default::default(),
1107 }
1108 }
1109
1110 /// Create a builder to help you perform the following task:
1111 ///
1112 /// Initializes the connection between a white space device and the database.
1113 ///
1114 /// # Arguments
1115 ///
1116 /// * `request` - No description provided.
1117 pub fn init(&self, request: PawsInitRequest) -> PawInitCall<'a, C> {
1118 PawInitCall {
1119 hub: self.hub,
1120 _request: request,
1121 _delegate: Default::default(),
1122 _additional_params: Default::default(),
1123 }
1124 }
1125
1126 /// Create a builder to help you perform the following task:
1127 ///
1128 /// Notifies the database that the device has selected certain frequency ranges for transmission. Only to be invoked when required by the regulator. The Google Spectrum Database does not operate in domains that require notification, so this always yields an UNIMPLEMENTED error.
1129 ///
1130 /// # Arguments
1131 ///
1132 /// * `request` - No description provided.
1133 pub fn notify_spectrum_use(
1134 &self,
1135 request: PawsNotifySpectrumUseRequest,
1136 ) -> PawNotifySpectrumUseCall<'a, C> {
1137 PawNotifySpectrumUseCall {
1138 hub: self.hub,
1139 _request: request,
1140 _delegate: Default::default(),
1141 _additional_params: Default::default(),
1142 }
1143 }
1144
1145 /// Create a builder to help you perform the following task:
1146 ///
1147 /// The Google Spectrum Database implements registration in the getSpectrum method. As such this always returns an UNIMPLEMENTED error.
1148 ///
1149 /// # Arguments
1150 ///
1151 /// * `request` - No description provided.
1152 pub fn register(&self, request: PawsRegisterRequest) -> PawRegisterCall<'a, C> {
1153 PawRegisterCall {
1154 hub: self.hub,
1155 _request: request,
1156 _delegate: Default::default(),
1157 _additional_params: Default::default(),
1158 }
1159 }
1160
1161 /// Create a builder to help you perform the following task:
1162 ///
1163 /// Validates a device for white space use in accordance with regulatory rules. The Google Spectrum Database does not support master/slave configurations, so this always yields an UNIMPLEMENTED error.
1164 ///
1165 /// # Arguments
1166 ///
1167 /// * `request` - No description provided.
1168 pub fn verify_device(&self, request: PawsVerifyDeviceRequest) -> PawVerifyDeviceCall<'a, C> {
1169 PawVerifyDeviceCall {
1170 hub: self.hub,
1171 _request: request,
1172 _delegate: Default::default(),
1173 _additional_params: Default::default(),
1174 }
1175 }
1176}
1177
1178// ###################
1179// CallBuilders ###
1180// #################
1181
1182/// Requests information about the available spectrum for a device at a location. Requests from a fixed-mode device must include owner information so the device can be registered with the database.
1183///
1184/// A builder for the *getSpectrum* method supported by a *paw* resource.
1185/// It is not used directly, but through a [`PawMethods`] instance.
1186///
1187/// # Example
1188///
1189/// Instantiate a resource method builder
1190///
1191/// ```test_harness,no_run
1192/// # extern crate hyper;
1193/// # extern crate hyper_rustls;
1194/// # extern crate google_spectrum1_explorer as spectrum1_explorer;
1195/// use spectrum1_explorer::api::PawsGetSpectrumRequest;
1196/// # async fn dox() {
1197/// # use spectrum1_explorer::{Spectrum, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1198///
1199/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1200/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1201/// # .with_native_roots()
1202/// # .unwrap()
1203/// # .https_only()
1204/// # .enable_http2()
1205/// # .build();
1206///
1207/// # let executor = hyper_util::rt::TokioExecutor::new();
1208/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1209/// # secret,
1210/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1211/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1212/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1213/// # ),
1214/// # ).build().await.unwrap();
1215///
1216/// # let client = hyper_util::client::legacy::Client::builder(
1217/// # hyper_util::rt::TokioExecutor::new()
1218/// # )
1219/// # .build(
1220/// # hyper_rustls::HttpsConnectorBuilder::new()
1221/// # .with_native_roots()
1222/// # .unwrap()
1223/// # .https_or_http()
1224/// # .enable_http2()
1225/// # .build()
1226/// # );
1227/// # let mut hub = Spectrum::new(client, auth);
1228/// // As the method needs a request, you would usually fill it with the desired information
1229/// // into the respective structure. Some of the parts shown here might not be applicable !
1230/// // Values shown here are possibly random and not representative !
1231/// let mut req = PawsGetSpectrumRequest::default();
1232///
1233/// // You can configure optional parameters by calling the respective setters at will, and
1234/// // execute the final call using `doit()`.
1235/// // Values shown here are possibly random and not representative !
1236/// let result = hub.paws().get_spectrum(req)
1237/// .doit().await;
1238/// # }
1239/// ```
1240pub struct PawGetSpectrumCall<'a, C>
1241where
1242 C: 'a,
1243{
1244 hub: &'a Spectrum<C>,
1245 _request: PawsGetSpectrumRequest,
1246 _delegate: Option<&'a mut dyn common::Delegate>,
1247 _additional_params: HashMap<String, String>,
1248}
1249
1250impl<'a, C> common::CallBuilder for PawGetSpectrumCall<'a, C> {}
1251
1252impl<'a, C> PawGetSpectrumCall<'a, C>
1253where
1254 C: common::Connector,
1255{
1256 /// Perform the operation you have build so far.
1257 pub async fn doit(mut self) -> common::Result<(common::Response, PawsGetSpectrumResponse)> {
1258 use std::borrow::Cow;
1259 use std::io::{Read, Seek};
1260
1261 use common::{url::Params, ToParts};
1262 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1263
1264 let mut dd = common::DefaultDelegate;
1265 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1266 dlg.begin(common::MethodInfo {
1267 id: "spectrum.paws.getSpectrum",
1268 http_method: hyper::Method::POST,
1269 });
1270
1271 for &field in ["alt"].iter() {
1272 if self._additional_params.contains_key(field) {
1273 dlg.finished(false);
1274 return Err(common::Error::FieldClash(field));
1275 }
1276 }
1277
1278 let mut params = Params::with_capacity(3 + self._additional_params.len());
1279
1280 params.extend(self._additional_params.iter());
1281
1282 params.push("alt", "json");
1283 let mut url = self.hub._base_url.clone() + "getSpectrum";
1284
1285 match dlg.api_key() {
1286 Some(value) => params.push("key", value),
1287 None => {
1288 dlg.finished(false);
1289 return Err(common::Error::MissingAPIKey);
1290 }
1291 }
1292
1293 let url = params.parse_with_url(&url);
1294
1295 let mut json_mime_type = mime::APPLICATION_JSON;
1296 let mut request_value_reader = {
1297 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1298 common::remove_json_null_values(&mut value);
1299 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1300 serde_json::to_writer(&mut dst, &value).unwrap();
1301 dst
1302 };
1303 let request_size = request_value_reader
1304 .seek(std::io::SeekFrom::End(0))
1305 .unwrap();
1306 request_value_reader
1307 .seek(std::io::SeekFrom::Start(0))
1308 .unwrap();
1309
1310 loop {
1311 request_value_reader
1312 .seek(std::io::SeekFrom::Start(0))
1313 .unwrap();
1314 let mut req_result = {
1315 let client = &self.hub.client;
1316 dlg.pre_request();
1317 let mut req_builder = hyper::Request::builder()
1318 .method(hyper::Method::POST)
1319 .uri(url.as_str())
1320 .header(USER_AGENT, self.hub._user_agent.clone());
1321
1322 let request = req_builder
1323 .header(CONTENT_TYPE, json_mime_type.to_string())
1324 .header(CONTENT_LENGTH, request_size as u64)
1325 .body(common::to_body(
1326 request_value_reader.get_ref().clone().into(),
1327 ));
1328
1329 client.request(request.unwrap()).await
1330 };
1331
1332 match req_result {
1333 Err(err) => {
1334 if let common::Retry::After(d) = dlg.http_error(&err) {
1335 sleep(d).await;
1336 continue;
1337 }
1338 dlg.finished(false);
1339 return Err(common::Error::HttpError(err));
1340 }
1341 Ok(res) => {
1342 let (mut parts, body) = res.into_parts();
1343 let mut body = common::Body::new(body);
1344 if !parts.status.is_success() {
1345 let bytes = common::to_bytes(body).await.unwrap_or_default();
1346 let error = serde_json::from_str(&common::to_string(&bytes));
1347 let response = common::to_response(parts, bytes.into());
1348
1349 if let common::Retry::After(d) =
1350 dlg.http_failure(&response, error.as_ref().ok())
1351 {
1352 sleep(d).await;
1353 continue;
1354 }
1355
1356 dlg.finished(false);
1357
1358 return Err(match error {
1359 Ok(value) => common::Error::BadRequest(value),
1360 _ => common::Error::Failure(response),
1361 });
1362 }
1363 let response = {
1364 let bytes = common::to_bytes(body).await.unwrap_or_default();
1365 let encoded = common::to_string(&bytes);
1366 match serde_json::from_str(&encoded) {
1367 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1368 Err(error) => {
1369 dlg.response_json_decode_error(&encoded, &error);
1370 return Err(common::Error::JsonDecodeError(
1371 encoded.to_string(),
1372 error,
1373 ));
1374 }
1375 }
1376 };
1377
1378 dlg.finished(true);
1379 return Ok(response);
1380 }
1381 }
1382 }
1383 }
1384
1385 ///
1386 /// Sets the *request* property to the given value.
1387 ///
1388 /// Even though the property as already been set when instantiating this call,
1389 /// we provide this method for API completeness.
1390 pub fn request(mut self, new_value: PawsGetSpectrumRequest) -> PawGetSpectrumCall<'a, C> {
1391 self._request = new_value;
1392 self
1393 }
1394 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1395 /// while executing the actual API request.
1396 ///
1397 /// ````text
1398 /// It should be used to handle progress information, and to implement a certain level of resilience.
1399 /// ````
1400 ///
1401 /// Sets the *delegate* property to the given value.
1402 pub fn delegate(
1403 mut self,
1404 new_value: &'a mut dyn common::Delegate,
1405 ) -> PawGetSpectrumCall<'a, C> {
1406 self._delegate = Some(new_value);
1407 self
1408 }
1409
1410 /// Set any additional parameter of the query string used in the request.
1411 /// It should be used to set parameters which are not yet available through their own
1412 /// setters.
1413 ///
1414 /// Please note that this method must not be used to set any of the known parameters
1415 /// which have their own setter method. If done anyway, the request will fail.
1416 ///
1417 /// # Additional Parameters
1418 ///
1419 /// * *alt* (query-string) - Data format for the response.
1420 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1421 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1422 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1423 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1424 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
1425 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1426 pub fn param<T>(mut self, name: T, value: T) -> PawGetSpectrumCall<'a, C>
1427 where
1428 T: AsRef<str>,
1429 {
1430 self._additional_params
1431 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1432 self
1433 }
1434}
1435
1436/// The Google Spectrum Database does not support batch requests, so this method always yields an UNIMPLEMENTED error.
1437///
1438/// A builder for the *getSpectrumBatch* method supported by a *paw* resource.
1439/// It is not used directly, but through a [`PawMethods`] instance.
1440///
1441/// # Example
1442///
1443/// Instantiate a resource method builder
1444///
1445/// ```test_harness,no_run
1446/// # extern crate hyper;
1447/// # extern crate hyper_rustls;
1448/// # extern crate google_spectrum1_explorer as spectrum1_explorer;
1449/// use spectrum1_explorer::api::PawsGetSpectrumBatchRequest;
1450/// # async fn dox() {
1451/// # use spectrum1_explorer::{Spectrum, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1452///
1453/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1454/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1455/// # .with_native_roots()
1456/// # .unwrap()
1457/// # .https_only()
1458/// # .enable_http2()
1459/// # .build();
1460///
1461/// # let executor = hyper_util::rt::TokioExecutor::new();
1462/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1463/// # secret,
1464/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1465/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1466/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1467/// # ),
1468/// # ).build().await.unwrap();
1469///
1470/// # let client = hyper_util::client::legacy::Client::builder(
1471/// # hyper_util::rt::TokioExecutor::new()
1472/// # )
1473/// # .build(
1474/// # hyper_rustls::HttpsConnectorBuilder::new()
1475/// # .with_native_roots()
1476/// # .unwrap()
1477/// # .https_or_http()
1478/// # .enable_http2()
1479/// # .build()
1480/// # );
1481/// # let mut hub = Spectrum::new(client, auth);
1482/// // As the method needs a request, you would usually fill it with the desired information
1483/// // into the respective structure. Some of the parts shown here might not be applicable !
1484/// // Values shown here are possibly random and not representative !
1485/// let mut req = PawsGetSpectrumBatchRequest::default();
1486///
1487/// // You can configure optional parameters by calling the respective setters at will, and
1488/// // execute the final call using `doit()`.
1489/// // Values shown here are possibly random and not representative !
1490/// let result = hub.paws().get_spectrum_batch(req)
1491/// .doit().await;
1492/// # }
1493/// ```
1494pub struct PawGetSpectrumBatchCall<'a, C>
1495where
1496 C: 'a,
1497{
1498 hub: &'a Spectrum<C>,
1499 _request: PawsGetSpectrumBatchRequest,
1500 _delegate: Option<&'a mut dyn common::Delegate>,
1501 _additional_params: HashMap<String, String>,
1502}
1503
1504impl<'a, C> common::CallBuilder for PawGetSpectrumBatchCall<'a, C> {}
1505
1506impl<'a, C> PawGetSpectrumBatchCall<'a, C>
1507where
1508 C: common::Connector,
1509{
1510 /// Perform the operation you have build so far.
1511 pub async fn doit(
1512 mut self,
1513 ) -> common::Result<(common::Response, PawsGetSpectrumBatchResponse)> {
1514 use std::borrow::Cow;
1515 use std::io::{Read, Seek};
1516
1517 use common::{url::Params, ToParts};
1518 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1519
1520 let mut dd = common::DefaultDelegate;
1521 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1522 dlg.begin(common::MethodInfo {
1523 id: "spectrum.paws.getSpectrumBatch",
1524 http_method: hyper::Method::POST,
1525 });
1526
1527 for &field in ["alt"].iter() {
1528 if self._additional_params.contains_key(field) {
1529 dlg.finished(false);
1530 return Err(common::Error::FieldClash(field));
1531 }
1532 }
1533
1534 let mut params = Params::with_capacity(3 + self._additional_params.len());
1535
1536 params.extend(self._additional_params.iter());
1537
1538 params.push("alt", "json");
1539 let mut url = self.hub._base_url.clone() + "getSpectrumBatch";
1540
1541 match dlg.api_key() {
1542 Some(value) => params.push("key", value),
1543 None => {
1544 dlg.finished(false);
1545 return Err(common::Error::MissingAPIKey);
1546 }
1547 }
1548
1549 let url = params.parse_with_url(&url);
1550
1551 let mut json_mime_type = mime::APPLICATION_JSON;
1552 let mut request_value_reader = {
1553 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1554 common::remove_json_null_values(&mut value);
1555 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1556 serde_json::to_writer(&mut dst, &value).unwrap();
1557 dst
1558 };
1559 let request_size = request_value_reader
1560 .seek(std::io::SeekFrom::End(0))
1561 .unwrap();
1562 request_value_reader
1563 .seek(std::io::SeekFrom::Start(0))
1564 .unwrap();
1565
1566 loop {
1567 request_value_reader
1568 .seek(std::io::SeekFrom::Start(0))
1569 .unwrap();
1570 let mut req_result = {
1571 let client = &self.hub.client;
1572 dlg.pre_request();
1573 let mut req_builder = hyper::Request::builder()
1574 .method(hyper::Method::POST)
1575 .uri(url.as_str())
1576 .header(USER_AGENT, self.hub._user_agent.clone());
1577
1578 let request = req_builder
1579 .header(CONTENT_TYPE, json_mime_type.to_string())
1580 .header(CONTENT_LENGTH, request_size as u64)
1581 .body(common::to_body(
1582 request_value_reader.get_ref().clone().into(),
1583 ));
1584
1585 client.request(request.unwrap()).await
1586 };
1587
1588 match req_result {
1589 Err(err) => {
1590 if let common::Retry::After(d) = dlg.http_error(&err) {
1591 sleep(d).await;
1592 continue;
1593 }
1594 dlg.finished(false);
1595 return Err(common::Error::HttpError(err));
1596 }
1597 Ok(res) => {
1598 let (mut parts, body) = res.into_parts();
1599 let mut body = common::Body::new(body);
1600 if !parts.status.is_success() {
1601 let bytes = common::to_bytes(body).await.unwrap_or_default();
1602 let error = serde_json::from_str(&common::to_string(&bytes));
1603 let response = common::to_response(parts, bytes.into());
1604
1605 if let common::Retry::After(d) =
1606 dlg.http_failure(&response, error.as_ref().ok())
1607 {
1608 sleep(d).await;
1609 continue;
1610 }
1611
1612 dlg.finished(false);
1613
1614 return Err(match error {
1615 Ok(value) => common::Error::BadRequest(value),
1616 _ => common::Error::Failure(response),
1617 });
1618 }
1619 let response = {
1620 let bytes = common::to_bytes(body).await.unwrap_or_default();
1621 let encoded = common::to_string(&bytes);
1622 match serde_json::from_str(&encoded) {
1623 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1624 Err(error) => {
1625 dlg.response_json_decode_error(&encoded, &error);
1626 return Err(common::Error::JsonDecodeError(
1627 encoded.to_string(),
1628 error,
1629 ));
1630 }
1631 }
1632 };
1633
1634 dlg.finished(true);
1635 return Ok(response);
1636 }
1637 }
1638 }
1639 }
1640
1641 ///
1642 /// Sets the *request* property to the given value.
1643 ///
1644 /// Even though the property as already been set when instantiating this call,
1645 /// we provide this method for API completeness.
1646 pub fn request(
1647 mut self,
1648 new_value: PawsGetSpectrumBatchRequest,
1649 ) -> PawGetSpectrumBatchCall<'a, C> {
1650 self._request = new_value;
1651 self
1652 }
1653 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1654 /// while executing the actual API request.
1655 ///
1656 /// ````text
1657 /// It should be used to handle progress information, and to implement a certain level of resilience.
1658 /// ````
1659 ///
1660 /// Sets the *delegate* property to the given value.
1661 pub fn delegate(
1662 mut self,
1663 new_value: &'a mut dyn common::Delegate,
1664 ) -> PawGetSpectrumBatchCall<'a, C> {
1665 self._delegate = Some(new_value);
1666 self
1667 }
1668
1669 /// Set any additional parameter of the query string used in the request.
1670 /// It should be used to set parameters which are not yet available through their own
1671 /// setters.
1672 ///
1673 /// Please note that this method must not be used to set any of the known parameters
1674 /// which have their own setter method. If done anyway, the request will fail.
1675 ///
1676 /// # Additional Parameters
1677 ///
1678 /// * *alt* (query-string) - Data format for the response.
1679 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1680 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1681 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1682 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1683 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
1684 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1685 pub fn param<T>(mut self, name: T, value: T) -> PawGetSpectrumBatchCall<'a, C>
1686 where
1687 T: AsRef<str>,
1688 {
1689 self._additional_params
1690 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1691 self
1692 }
1693}
1694
1695/// Initializes the connection between a white space device and the database.
1696///
1697/// A builder for the *init* method supported by a *paw* resource.
1698/// It is not used directly, but through a [`PawMethods`] instance.
1699///
1700/// # Example
1701///
1702/// Instantiate a resource method builder
1703///
1704/// ```test_harness,no_run
1705/// # extern crate hyper;
1706/// # extern crate hyper_rustls;
1707/// # extern crate google_spectrum1_explorer as spectrum1_explorer;
1708/// use spectrum1_explorer::api::PawsInitRequest;
1709/// # async fn dox() {
1710/// # use spectrum1_explorer::{Spectrum, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1711///
1712/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1713/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1714/// # .with_native_roots()
1715/// # .unwrap()
1716/// # .https_only()
1717/// # .enable_http2()
1718/// # .build();
1719///
1720/// # let executor = hyper_util::rt::TokioExecutor::new();
1721/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1722/// # secret,
1723/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1724/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1725/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1726/// # ),
1727/// # ).build().await.unwrap();
1728///
1729/// # let client = hyper_util::client::legacy::Client::builder(
1730/// # hyper_util::rt::TokioExecutor::new()
1731/// # )
1732/// # .build(
1733/// # hyper_rustls::HttpsConnectorBuilder::new()
1734/// # .with_native_roots()
1735/// # .unwrap()
1736/// # .https_or_http()
1737/// # .enable_http2()
1738/// # .build()
1739/// # );
1740/// # let mut hub = Spectrum::new(client, auth);
1741/// // As the method needs a request, you would usually fill it with the desired information
1742/// // into the respective structure. Some of the parts shown here might not be applicable !
1743/// // Values shown here are possibly random and not representative !
1744/// let mut req = PawsInitRequest::default();
1745///
1746/// // You can configure optional parameters by calling the respective setters at will, and
1747/// // execute the final call using `doit()`.
1748/// // Values shown here are possibly random and not representative !
1749/// let result = hub.paws().init(req)
1750/// .doit().await;
1751/// # }
1752/// ```
1753pub struct PawInitCall<'a, C>
1754where
1755 C: 'a,
1756{
1757 hub: &'a Spectrum<C>,
1758 _request: PawsInitRequest,
1759 _delegate: Option<&'a mut dyn common::Delegate>,
1760 _additional_params: HashMap<String, String>,
1761}
1762
1763impl<'a, C> common::CallBuilder for PawInitCall<'a, C> {}
1764
1765impl<'a, C> PawInitCall<'a, C>
1766where
1767 C: common::Connector,
1768{
1769 /// Perform the operation you have build so far.
1770 pub async fn doit(mut self) -> common::Result<(common::Response, PawsInitResponse)> {
1771 use std::borrow::Cow;
1772 use std::io::{Read, Seek};
1773
1774 use common::{url::Params, ToParts};
1775 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1776
1777 let mut dd = common::DefaultDelegate;
1778 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1779 dlg.begin(common::MethodInfo {
1780 id: "spectrum.paws.init",
1781 http_method: hyper::Method::POST,
1782 });
1783
1784 for &field in ["alt"].iter() {
1785 if self._additional_params.contains_key(field) {
1786 dlg.finished(false);
1787 return Err(common::Error::FieldClash(field));
1788 }
1789 }
1790
1791 let mut params = Params::with_capacity(3 + self._additional_params.len());
1792
1793 params.extend(self._additional_params.iter());
1794
1795 params.push("alt", "json");
1796 let mut url = self.hub._base_url.clone() + "init";
1797
1798 match dlg.api_key() {
1799 Some(value) => params.push("key", value),
1800 None => {
1801 dlg.finished(false);
1802 return Err(common::Error::MissingAPIKey);
1803 }
1804 }
1805
1806 let url = params.parse_with_url(&url);
1807
1808 let mut json_mime_type = mime::APPLICATION_JSON;
1809 let mut request_value_reader = {
1810 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1811 common::remove_json_null_values(&mut value);
1812 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1813 serde_json::to_writer(&mut dst, &value).unwrap();
1814 dst
1815 };
1816 let request_size = request_value_reader
1817 .seek(std::io::SeekFrom::End(0))
1818 .unwrap();
1819 request_value_reader
1820 .seek(std::io::SeekFrom::Start(0))
1821 .unwrap();
1822
1823 loop {
1824 request_value_reader
1825 .seek(std::io::SeekFrom::Start(0))
1826 .unwrap();
1827 let mut req_result = {
1828 let client = &self.hub.client;
1829 dlg.pre_request();
1830 let mut req_builder = hyper::Request::builder()
1831 .method(hyper::Method::POST)
1832 .uri(url.as_str())
1833 .header(USER_AGENT, self.hub._user_agent.clone());
1834
1835 let request = req_builder
1836 .header(CONTENT_TYPE, json_mime_type.to_string())
1837 .header(CONTENT_LENGTH, request_size as u64)
1838 .body(common::to_body(
1839 request_value_reader.get_ref().clone().into(),
1840 ));
1841
1842 client.request(request.unwrap()).await
1843 };
1844
1845 match req_result {
1846 Err(err) => {
1847 if let common::Retry::After(d) = dlg.http_error(&err) {
1848 sleep(d).await;
1849 continue;
1850 }
1851 dlg.finished(false);
1852 return Err(common::Error::HttpError(err));
1853 }
1854 Ok(res) => {
1855 let (mut parts, body) = res.into_parts();
1856 let mut body = common::Body::new(body);
1857 if !parts.status.is_success() {
1858 let bytes = common::to_bytes(body).await.unwrap_or_default();
1859 let error = serde_json::from_str(&common::to_string(&bytes));
1860 let response = common::to_response(parts, bytes.into());
1861
1862 if let common::Retry::After(d) =
1863 dlg.http_failure(&response, error.as_ref().ok())
1864 {
1865 sleep(d).await;
1866 continue;
1867 }
1868
1869 dlg.finished(false);
1870
1871 return Err(match error {
1872 Ok(value) => common::Error::BadRequest(value),
1873 _ => common::Error::Failure(response),
1874 });
1875 }
1876 let response = {
1877 let bytes = common::to_bytes(body).await.unwrap_or_default();
1878 let encoded = common::to_string(&bytes);
1879 match serde_json::from_str(&encoded) {
1880 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1881 Err(error) => {
1882 dlg.response_json_decode_error(&encoded, &error);
1883 return Err(common::Error::JsonDecodeError(
1884 encoded.to_string(),
1885 error,
1886 ));
1887 }
1888 }
1889 };
1890
1891 dlg.finished(true);
1892 return Ok(response);
1893 }
1894 }
1895 }
1896 }
1897
1898 ///
1899 /// Sets the *request* property to the given value.
1900 ///
1901 /// Even though the property as already been set when instantiating this call,
1902 /// we provide this method for API completeness.
1903 pub fn request(mut self, new_value: PawsInitRequest) -> PawInitCall<'a, C> {
1904 self._request = new_value;
1905 self
1906 }
1907 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1908 /// while executing the actual API request.
1909 ///
1910 /// ````text
1911 /// It should be used to handle progress information, and to implement a certain level of resilience.
1912 /// ````
1913 ///
1914 /// Sets the *delegate* property to the given value.
1915 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PawInitCall<'a, C> {
1916 self._delegate = Some(new_value);
1917 self
1918 }
1919
1920 /// Set any additional parameter of the query string used in the request.
1921 /// It should be used to set parameters which are not yet available through their own
1922 /// setters.
1923 ///
1924 /// Please note that this method must not be used to set any of the known parameters
1925 /// which have their own setter method. If done anyway, the request will fail.
1926 ///
1927 /// # Additional Parameters
1928 ///
1929 /// * *alt* (query-string) - Data format for the response.
1930 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1931 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1932 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1933 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1934 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
1935 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1936 pub fn param<T>(mut self, name: T, value: T) -> PawInitCall<'a, C>
1937 where
1938 T: AsRef<str>,
1939 {
1940 self._additional_params
1941 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1942 self
1943 }
1944}
1945
1946/// Notifies the database that the device has selected certain frequency ranges for transmission. Only to be invoked when required by the regulator. The Google Spectrum Database does not operate in domains that require notification, so this always yields an UNIMPLEMENTED error.
1947///
1948/// A builder for the *notifySpectrumUse* method supported by a *paw* resource.
1949/// It is not used directly, but through a [`PawMethods`] instance.
1950///
1951/// # Example
1952///
1953/// Instantiate a resource method builder
1954///
1955/// ```test_harness,no_run
1956/// # extern crate hyper;
1957/// # extern crate hyper_rustls;
1958/// # extern crate google_spectrum1_explorer as spectrum1_explorer;
1959/// use spectrum1_explorer::api::PawsNotifySpectrumUseRequest;
1960/// # async fn dox() {
1961/// # use spectrum1_explorer::{Spectrum, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1962///
1963/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1964/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1965/// # .with_native_roots()
1966/// # .unwrap()
1967/// # .https_only()
1968/// # .enable_http2()
1969/// # .build();
1970///
1971/// # let executor = hyper_util::rt::TokioExecutor::new();
1972/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1973/// # secret,
1974/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1975/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1976/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1977/// # ),
1978/// # ).build().await.unwrap();
1979///
1980/// # let client = hyper_util::client::legacy::Client::builder(
1981/// # hyper_util::rt::TokioExecutor::new()
1982/// # )
1983/// # .build(
1984/// # hyper_rustls::HttpsConnectorBuilder::new()
1985/// # .with_native_roots()
1986/// # .unwrap()
1987/// # .https_or_http()
1988/// # .enable_http2()
1989/// # .build()
1990/// # );
1991/// # let mut hub = Spectrum::new(client, auth);
1992/// // As the method needs a request, you would usually fill it with the desired information
1993/// // into the respective structure. Some of the parts shown here might not be applicable !
1994/// // Values shown here are possibly random and not representative !
1995/// let mut req = PawsNotifySpectrumUseRequest::default();
1996///
1997/// // You can configure optional parameters by calling the respective setters at will, and
1998/// // execute the final call using `doit()`.
1999/// // Values shown here are possibly random and not representative !
2000/// let result = hub.paws().notify_spectrum_use(req)
2001/// .doit().await;
2002/// # }
2003/// ```
2004pub struct PawNotifySpectrumUseCall<'a, C>
2005where
2006 C: 'a,
2007{
2008 hub: &'a Spectrum<C>,
2009 _request: PawsNotifySpectrumUseRequest,
2010 _delegate: Option<&'a mut dyn common::Delegate>,
2011 _additional_params: HashMap<String, String>,
2012}
2013
2014impl<'a, C> common::CallBuilder for PawNotifySpectrumUseCall<'a, C> {}
2015
2016impl<'a, C> PawNotifySpectrumUseCall<'a, C>
2017where
2018 C: common::Connector,
2019{
2020 /// Perform the operation you have build so far.
2021 pub async fn doit(
2022 mut self,
2023 ) -> common::Result<(common::Response, PawsNotifySpectrumUseResponse)> {
2024 use std::borrow::Cow;
2025 use std::io::{Read, Seek};
2026
2027 use common::{url::Params, ToParts};
2028 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2029
2030 let mut dd = common::DefaultDelegate;
2031 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2032 dlg.begin(common::MethodInfo {
2033 id: "spectrum.paws.notifySpectrumUse",
2034 http_method: hyper::Method::POST,
2035 });
2036
2037 for &field in ["alt"].iter() {
2038 if self._additional_params.contains_key(field) {
2039 dlg.finished(false);
2040 return Err(common::Error::FieldClash(field));
2041 }
2042 }
2043
2044 let mut params = Params::with_capacity(3 + self._additional_params.len());
2045
2046 params.extend(self._additional_params.iter());
2047
2048 params.push("alt", "json");
2049 let mut url = self.hub._base_url.clone() + "notifySpectrumUse";
2050
2051 match dlg.api_key() {
2052 Some(value) => params.push("key", value),
2053 None => {
2054 dlg.finished(false);
2055 return Err(common::Error::MissingAPIKey);
2056 }
2057 }
2058
2059 let url = params.parse_with_url(&url);
2060
2061 let mut json_mime_type = mime::APPLICATION_JSON;
2062 let mut request_value_reader = {
2063 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2064 common::remove_json_null_values(&mut value);
2065 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2066 serde_json::to_writer(&mut dst, &value).unwrap();
2067 dst
2068 };
2069 let request_size = request_value_reader
2070 .seek(std::io::SeekFrom::End(0))
2071 .unwrap();
2072 request_value_reader
2073 .seek(std::io::SeekFrom::Start(0))
2074 .unwrap();
2075
2076 loop {
2077 request_value_reader
2078 .seek(std::io::SeekFrom::Start(0))
2079 .unwrap();
2080 let mut req_result = {
2081 let client = &self.hub.client;
2082 dlg.pre_request();
2083 let mut req_builder = hyper::Request::builder()
2084 .method(hyper::Method::POST)
2085 .uri(url.as_str())
2086 .header(USER_AGENT, self.hub._user_agent.clone());
2087
2088 let request = req_builder
2089 .header(CONTENT_TYPE, json_mime_type.to_string())
2090 .header(CONTENT_LENGTH, request_size as u64)
2091 .body(common::to_body(
2092 request_value_reader.get_ref().clone().into(),
2093 ));
2094
2095 client.request(request.unwrap()).await
2096 };
2097
2098 match req_result {
2099 Err(err) => {
2100 if let common::Retry::After(d) = dlg.http_error(&err) {
2101 sleep(d).await;
2102 continue;
2103 }
2104 dlg.finished(false);
2105 return Err(common::Error::HttpError(err));
2106 }
2107 Ok(res) => {
2108 let (mut parts, body) = res.into_parts();
2109 let mut body = common::Body::new(body);
2110 if !parts.status.is_success() {
2111 let bytes = common::to_bytes(body).await.unwrap_or_default();
2112 let error = serde_json::from_str(&common::to_string(&bytes));
2113 let response = common::to_response(parts, bytes.into());
2114
2115 if let common::Retry::After(d) =
2116 dlg.http_failure(&response, error.as_ref().ok())
2117 {
2118 sleep(d).await;
2119 continue;
2120 }
2121
2122 dlg.finished(false);
2123
2124 return Err(match error {
2125 Ok(value) => common::Error::BadRequest(value),
2126 _ => common::Error::Failure(response),
2127 });
2128 }
2129 let response = {
2130 let bytes = common::to_bytes(body).await.unwrap_or_default();
2131 let encoded = common::to_string(&bytes);
2132 match serde_json::from_str(&encoded) {
2133 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2134 Err(error) => {
2135 dlg.response_json_decode_error(&encoded, &error);
2136 return Err(common::Error::JsonDecodeError(
2137 encoded.to_string(),
2138 error,
2139 ));
2140 }
2141 }
2142 };
2143
2144 dlg.finished(true);
2145 return Ok(response);
2146 }
2147 }
2148 }
2149 }
2150
2151 ///
2152 /// Sets the *request* property to the given value.
2153 ///
2154 /// Even though the property as already been set when instantiating this call,
2155 /// we provide this method for API completeness.
2156 pub fn request(
2157 mut self,
2158 new_value: PawsNotifySpectrumUseRequest,
2159 ) -> PawNotifySpectrumUseCall<'a, C> {
2160 self._request = new_value;
2161 self
2162 }
2163 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2164 /// while executing the actual API request.
2165 ///
2166 /// ````text
2167 /// It should be used to handle progress information, and to implement a certain level of resilience.
2168 /// ````
2169 ///
2170 /// Sets the *delegate* property to the given value.
2171 pub fn delegate(
2172 mut self,
2173 new_value: &'a mut dyn common::Delegate,
2174 ) -> PawNotifySpectrumUseCall<'a, C> {
2175 self._delegate = Some(new_value);
2176 self
2177 }
2178
2179 /// Set any additional parameter of the query string used in the request.
2180 /// It should be used to set parameters which are not yet available through their own
2181 /// setters.
2182 ///
2183 /// Please note that this method must not be used to set any of the known parameters
2184 /// which have their own setter method. If done anyway, the request will fail.
2185 ///
2186 /// # Additional Parameters
2187 ///
2188 /// * *alt* (query-string) - Data format for the response.
2189 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2190 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2191 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2192 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2193 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
2194 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2195 pub fn param<T>(mut self, name: T, value: T) -> PawNotifySpectrumUseCall<'a, C>
2196 where
2197 T: AsRef<str>,
2198 {
2199 self._additional_params
2200 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2201 self
2202 }
2203}
2204
2205/// The Google Spectrum Database implements registration in the getSpectrum method. As such this always returns an UNIMPLEMENTED error.
2206///
2207/// A builder for the *register* method supported by a *paw* resource.
2208/// It is not used directly, but through a [`PawMethods`] instance.
2209///
2210/// # Example
2211///
2212/// Instantiate a resource method builder
2213///
2214/// ```test_harness,no_run
2215/// # extern crate hyper;
2216/// # extern crate hyper_rustls;
2217/// # extern crate google_spectrum1_explorer as spectrum1_explorer;
2218/// use spectrum1_explorer::api::PawsRegisterRequest;
2219/// # async fn dox() {
2220/// # use spectrum1_explorer::{Spectrum, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2221///
2222/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2223/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2224/// # .with_native_roots()
2225/// # .unwrap()
2226/// # .https_only()
2227/// # .enable_http2()
2228/// # .build();
2229///
2230/// # let executor = hyper_util::rt::TokioExecutor::new();
2231/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2232/// # secret,
2233/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2234/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2235/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2236/// # ),
2237/// # ).build().await.unwrap();
2238///
2239/// # let client = hyper_util::client::legacy::Client::builder(
2240/// # hyper_util::rt::TokioExecutor::new()
2241/// # )
2242/// # .build(
2243/// # hyper_rustls::HttpsConnectorBuilder::new()
2244/// # .with_native_roots()
2245/// # .unwrap()
2246/// # .https_or_http()
2247/// # .enable_http2()
2248/// # .build()
2249/// # );
2250/// # let mut hub = Spectrum::new(client, auth);
2251/// // As the method needs a request, you would usually fill it with the desired information
2252/// // into the respective structure. Some of the parts shown here might not be applicable !
2253/// // Values shown here are possibly random and not representative !
2254/// let mut req = PawsRegisterRequest::default();
2255///
2256/// // You can configure optional parameters by calling the respective setters at will, and
2257/// // execute the final call using `doit()`.
2258/// // Values shown here are possibly random and not representative !
2259/// let result = hub.paws().register(req)
2260/// .doit().await;
2261/// # }
2262/// ```
2263pub struct PawRegisterCall<'a, C>
2264where
2265 C: 'a,
2266{
2267 hub: &'a Spectrum<C>,
2268 _request: PawsRegisterRequest,
2269 _delegate: Option<&'a mut dyn common::Delegate>,
2270 _additional_params: HashMap<String, String>,
2271}
2272
2273impl<'a, C> common::CallBuilder for PawRegisterCall<'a, C> {}
2274
2275impl<'a, C> PawRegisterCall<'a, C>
2276where
2277 C: common::Connector,
2278{
2279 /// Perform the operation you have build so far.
2280 pub async fn doit(mut self) -> common::Result<(common::Response, PawsRegisterResponse)> {
2281 use std::borrow::Cow;
2282 use std::io::{Read, Seek};
2283
2284 use common::{url::Params, ToParts};
2285 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2286
2287 let mut dd = common::DefaultDelegate;
2288 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2289 dlg.begin(common::MethodInfo {
2290 id: "spectrum.paws.register",
2291 http_method: hyper::Method::POST,
2292 });
2293
2294 for &field in ["alt"].iter() {
2295 if self._additional_params.contains_key(field) {
2296 dlg.finished(false);
2297 return Err(common::Error::FieldClash(field));
2298 }
2299 }
2300
2301 let mut params = Params::with_capacity(3 + self._additional_params.len());
2302
2303 params.extend(self._additional_params.iter());
2304
2305 params.push("alt", "json");
2306 let mut url = self.hub._base_url.clone() + "register";
2307
2308 match dlg.api_key() {
2309 Some(value) => params.push("key", value),
2310 None => {
2311 dlg.finished(false);
2312 return Err(common::Error::MissingAPIKey);
2313 }
2314 }
2315
2316 let url = params.parse_with_url(&url);
2317
2318 let mut json_mime_type = mime::APPLICATION_JSON;
2319 let mut request_value_reader = {
2320 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2321 common::remove_json_null_values(&mut value);
2322 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2323 serde_json::to_writer(&mut dst, &value).unwrap();
2324 dst
2325 };
2326 let request_size = request_value_reader
2327 .seek(std::io::SeekFrom::End(0))
2328 .unwrap();
2329 request_value_reader
2330 .seek(std::io::SeekFrom::Start(0))
2331 .unwrap();
2332
2333 loop {
2334 request_value_reader
2335 .seek(std::io::SeekFrom::Start(0))
2336 .unwrap();
2337 let mut req_result = {
2338 let client = &self.hub.client;
2339 dlg.pre_request();
2340 let mut req_builder = hyper::Request::builder()
2341 .method(hyper::Method::POST)
2342 .uri(url.as_str())
2343 .header(USER_AGENT, self.hub._user_agent.clone());
2344
2345 let request = req_builder
2346 .header(CONTENT_TYPE, json_mime_type.to_string())
2347 .header(CONTENT_LENGTH, request_size as u64)
2348 .body(common::to_body(
2349 request_value_reader.get_ref().clone().into(),
2350 ));
2351
2352 client.request(request.unwrap()).await
2353 };
2354
2355 match req_result {
2356 Err(err) => {
2357 if let common::Retry::After(d) = dlg.http_error(&err) {
2358 sleep(d).await;
2359 continue;
2360 }
2361 dlg.finished(false);
2362 return Err(common::Error::HttpError(err));
2363 }
2364 Ok(res) => {
2365 let (mut parts, body) = res.into_parts();
2366 let mut body = common::Body::new(body);
2367 if !parts.status.is_success() {
2368 let bytes = common::to_bytes(body).await.unwrap_or_default();
2369 let error = serde_json::from_str(&common::to_string(&bytes));
2370 let response = common::to_response(parts, bytes.into());
2371
2372 if let common::Retry::After(d) =
2373 dlg.http_failure(&response, error.as_ref().ok())
2374 {
2375 sleep(d).await;
2376 continue;
2377 }
2378
2379 dlg.finished(false);
2380
2381 return Err(match error {
2382 Ok(value) => common::Error::BadRequest(value),
2383 _ => common::Error::Failure(response),
2384 });
2385 }
2386 let response = {
2387 let bytes = common::to_bytes(body).await.unwrap_or_default();
2388 let encoded = common::to_string(&bytes);
2389 match serde_json::from_str(&encoded) {
2390 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2391 Err(error) => {
2392 dlg.response_json_decode_error(&encoded, &error);
2393 return Err(common::Error::JsonDecodeError(
2394 encoded.to_string(),
2395 error,
2396 ));
2397 }
2398 }
2399 };
2400
2401 dlg.finished(true);
2402 return Ok(response);
2403 }
2404 }
2405 }
2406 }
2407
2408 ///
2409 /// Sets the *request* property to the given value.
2410 ///
2411 /// Even though the property as already been set when instantiating this call,
2412 /// we provide this method for API completeness.
2413 pub fn request(mut self, new_value: PawsRegisterRequest) -> PawRegisterCall<'a, C> {
2414 self._request = new_value;
2415 self
2416 }
2417 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2418 /// while executing the actual API request.
2419 ///
2420 /// ````text
2421 /// It should be used to handle progress information, and to implement a certain level of resilience.
2422 /// ````
2423 ///
2424 /// Sets the *delegate* property to the given value.
2425 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PawRegisterCall<'a, C> {
2426 self._delegate = Some(new_value);
2427 self
2428 }
2429
2430 /// Set any additional parameter of the query string used in the request.
2431 /// It should be used to set parameters which are not yet available through their own
2432 /// setters.
2433 ///
2434 /// Please note that this method must not be used to set any of the known parameters
2435 /// which have their own setter method. If done anyway, the request will fail.
2436 ///
2437 /// # Additional Parameters
2438 ///
2439 /// * *alt* (query-string) - Data format for the response.
2440 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2441 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2442 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2443 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2444 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
2445 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2446 pub fn param<T>(mut self, name: T, value: T) -> PawRegisterCall<'a, C>
2447 where
2448 T: AsRef<str>,
2449 {
2450 self._additional_params
2451 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2452 self
2453 }
2454}
2455
2456/// Validates a device for white space use in accordance with regulatory rules. The Google Spectrum Database does not support master/slave configurations, so this always yields an UNIMPLEMENTED error.
2457///
2458/// A builder for the *verifyDevice* method supported by a *paw* resource.
2459/// It is not used directly, but through a [`PawMethods`] instance.
2460///
2461/// # Example
2462///
2463/// Instantiate a resource method builder
2464///
2465/// ```test_harness,no_run
2466/// # extern crate hyper;
2467/// # extern crate hyper_rustls;
2468/// # extern crate google_spectrum1_explorer as spectrum1_explorer;
2469/// use spectrum1_explorer::api::PawsVerifyDeviceRequest;
2470/// # async fn dox() {
2471/// # use spectrum1_explorer::{Spectrum, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2472///
2473/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2474/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2475/// # .with_native_roots()
2476/// # .unwrap()
2477/// # .https_only()
2478/// # .enable_http2()
2479/// # .build();
2480///
2481/// # let executor = hyper_util::rt::TokioExecutor::new();
2482/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2483/// # secret,
2484/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2485/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2486/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2487/// # ),
2488/// # ).build().await.unwrap();
2489///
2490/// # let client = hyper_util::client::legacy::Client::builder(
2491/// # hyper_util::rt::TokioExecutor::new()
2492/// # )
2493/// # .build(
2494/// # hyper_rustls::HttpsConnectorBuilder::new()
2495/// # .with_native_roots()
2496/// # .unwrap()
2497/// # .https_or_http()
2498/// # .enable_http2()
2499/// # .build()
2500/// # );
2501/// # let mut hub = Spectrum::new(client, auth);
2502/// // As the method needs a request, you would usually fill it with the desired information
2503/// // into the respective structure. Some of the parts shown here might not be applicable !
2504/// // Values shown here are possibly random and not representative !
2505/// let mut req = PawsVerifyDeviceRequest::default();
2506///
2507/// // You can configure optional parameters by calling the respective setters at will, and
2508/// // execute the final call using `doit()`.
2509/// // Values shown here are possibly random and not representative !
2510/// let result = hub.paws().verify_device(req)
2511/// .doit().await;
2512/// # }
2513/// ```
2514pub struct PawVerifyDeviceCall<'a, C>
2515where
2516 C: 'a,
2517{
2518 hub: &'a Spectrum<C>,
2519 _request: PawsVerifyDeviceRequest,
2520 _delegate: Option<&'a mut dyn common::Delegate>,
2521 _additional_params: HashMap<String, String>,
2522}
2523
2524impl<'a, C> common::CallBuilder for PawVerifyDeviceCall<'a, C> {}
2525
2526impl<'a, C> PawVerifyDeviceCall<'a, C>
2527where
2528 C: common::Connector,
2529{
2530 /// Perform the operation you have build so far.
2531 pub async fn doit(mut self) -> common::Result<(common::Response, PawsVerifyDeviceResponse)> {
2532 use std::borrow::Cow;
2533 use std::io::{Read, Seek};
2534
2535 use common::{url::Params, ToParts};
2536 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2537
2538 let mut dd = common::DefaultDelegate;
2539 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2540 dlg.begin(common::MethodInfo {
2541 id: "spectrum.paws.verifyDevice",
2542 http_method: hyper::Method::POST,
2543 });
2544
2545 for &field in ["alt"].iter() {
2546 if self._additional_params.contains_key(field) {
2547 dlg.finished(false);
2548 return Err(common::Error::FieldClash(field));
2549 }
2550 }
2551
2552 let mut params = Params::with_capacity(3 + self._additional_params.len());
2553
2554 params.extend(self._additional_params.iter());
2555
2556 params.push("alt", "json");
2557 let mut url = self.hub._base_url.clone() + "verifyDevice";
2558
2559 match dlg.api_key() {
2560 Some(value) => params.push("key", value),
2561 None => {
2562 dlg.finished(false);
2563 return Err(common::Error::MissingAPIKey);
2564 }
2565 }
2566
2567 let url = params.parse_with_url(&url);
2568
2569 let mut json_mime_type = mime::APPLICATION_JSON;
2570 let mut request_value_reader = {
2571 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2572 common::remove_json_null_values(&mut value);
2573 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2574 serde_json::to_writer(&mut dst, &value).unwrap();
2575 dst
2576 };
2577 let request_size = request_value_reader
2578 .seek(std::io::SeekFrom::End(0))
2579 .unwrap();
2580 request_value_reader
2581 .seek(std::io::SeekFrom::Start(0))
2582 .unwrap();
2583
2584 loop {
2585 request_value_reader
2586 .seek(std::io::SeekFrom::Start(0))
2587 .unwrap();
2588 let mut req_result = {
2589 let client = &self.hub.client;
2590 dlg.pre_request();
2591 let mut req_builder = hyper::Request::builder()
2592 .method(hyper::Method::POST)
2593 .uri(url.as_str())
2594 .header(USER_AGENT, self.hub._user_agent.clone());
2595
2596 let request = req_builder
2597 .header(CONTENT_TYPE, json_mime_type.to_string())
2598 .header(CONTENT_LENGTH, request_size as u64)
2599 .body(common::to_body(
2600 request_value_reader.get_ref().clone().into(),
2601 ));
2602
2603 client.request(request.unwrap()).await
2604 };
2605
2606 match req_result {
2607 Err(err) => {
2608 if let common::Retry::After(d) = dlg.http_error(&err) {
2609 sleep(d).await;
2610 continue;
2611 }
2612 dlg.finished(false);
2613 return Err(common::Error::HttpError(err));
2614 }
2615 Ok(res) => {
2616 let (mut parts, body) = res.into_parts();
2617 let mut body = common::Body::new(body);
2618 if !parts.status.is_success() {
2619 let bytes = common::to_bytes(body).await.unwrap_or_default();
2620 let error = serde_json::from_str(&common::to_string(&bytes));
2621 let response = common::to_response(parts, bytes.into());
2622
2623 if let common::Retry::After(d) =
2624 dlg.http_failure(&response, error.as_ref().ok())
2625 {
2626 sleep(d).await;
2627 continue;
2628 }
2629
2630 dlg.finished(false);
2631
2632 return Err(match error {
2633 Ok(value) => common::Error::BadRequest(value),
2634 _ => common::Error::Failure(response),
2635 });
2636 }
2637 let response = {
2638 let bytes = common::to_bytes(body).await.unwrap_or_default();
2639 let encoded = common::to_string(&bytes);
2640 match serde_json::from_str(&encoded) {
2641 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2642 Err(error) => {
2643 dlg.response_json_decode_error(&encoded, &error);
2644 return Err(common::Error::JsonDecodeError(
2645 encoded.to_string(),
2646 error,
2647 ));
2648 }
2649 }
2650 };
2651
2652 dlg.finished(true);
2653 return Ok(response);
2654 }
2655 }
2656 }
2657 }
2658
2659 ///
2660 /// Sets the *request* property to the given value.
2661 ///
2662 /// Even though the property as already been set when instantiating this call,
2663 /// we provide this method for API completeness.
2664 pub fn request(mut self, new_value: PawsVerifyDeviceRequest) -> PawVerifyDeviceCall<'a, C> {
2665 self._request = new_value;
2666 self
2667 }
2668 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2669 /// while executing the actual API request.
2670 ///
2671 /// ````text
2672 /// It should be used to handle progress information, and to implement a certain level of resilience.
2673 /// ````
2674 ///
2675 /// Sets the *delegate* property to the given value.
2676 pub fn delegate(
2677 mut self,
2678 new_value: &'a mut dyn common::Delegate,
2679 ) -> PawVerifyDeviceCall<'a, C> {
2680 self._delegate = Some(new_value);
2681 self
2682 }
2683
2684 /// Set any additional parameter of the query string used in the request.
2685 /// It should be used to set parameters which are not yet available through their own
2686 /// setters.
2687 ///
2688 /// Please note that this method must not be used to set any of the known parameters
2689 /// which have their own setter method. If done anyway, the request will fail.
2690 ///
2691 /// # Additional Parameters
2692 ///
2693 /// * *alt* (query-string) - Data format for the response.
2694 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2695 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2696 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2697 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2698 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
2699 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2700 pub fn param<T>(mut self, name: T, value: T) -> PawVerifyDeviceCall<'a, C>
2701 where
2702 T: AsRef<str>,
2703 {
2704 self._additional_params
2705 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2706 self
2707 }
2708}