google_pubsub1/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/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18
19 /// View and manage Pub/Sub topics and subscriptions
20 Full,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27 Scope::Full => "https://www.googleapis.com/auth/pubsub",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::Full
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Pubsub related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_pubsub1 as pubsub1;
53/// use pubsub1::{Result, Error};
54/// # async fn dox() {
55/// use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56///
57/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
58/// // `client_secret`, among other things.
59/// let secret: yup_oauth2::ApplicationSecret = Default::default();
60/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
61/// // unless you replace `None` with the desired Flow.
62/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
63/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
64/// // retrieve them from storage.
65/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
66/// .with_native_roots()
67/// .unwrap()
68/// .https_only()
69/// .enable_http2()
70/// .build();
71///
72/// let executor = hyper_util::rt::TokioExecutor::new();
73/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
74/// secret,
75/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76/// yup_oauth2::client::CustomHyperClientBuilder::from(
77/// hyper_util::client::legacy::Client::builder(executor).build(connector),
78/// ),
79/// ).build().await.unwrap();
80///
81/// let client = hyper_util::client::legacy::Client::builder(
82/// hyper_util::rt::TokioExecutor::new()
83/// )
84/// .build(
85/// hyper_rustls::HttpsConnectorBuilder::new()
86/// .with_native_roots()
87/// .unwrap()
88/// .https_or_http()
89/// .enable_http2()
90/// .build()
91/// );
92/// let mut hub = Pubsub::new(client, auth);
93/// // You can configure optional parameters by calling the respective setters at will, and
94/// // execute the final call using `doit()`.
95/// // Values shown here are possibly random and not representative !
96/// let result = hub.projects().schemas_get_iam_policy("resource")
97/// .options_requested_policy_version(-27)
98/// .doit().await;
99///
100/// match result {
101/// Err(e) => match e {
102/// // The Error enum provides details about what exactly happened.
103/// // You can also just use its `Debug`, `Display` or `Error` traits
104/// Error::HttpError(_)
105/// |Error::Io(_)
106/// |Error::MissingAPIKey
107/// |Error::MissingToken(_)
108/// |Error::Cancelled
109/// |Error::UploadSizeLimitExceeded(_, _)
110/// |Error::Failure(_)
111/// |Error::BadRequest(_)
112/// |Error::FieldClash(_)
113/// |Error::JsonDecodeError(_, _) => println!("{}", e),
114/// },
115/// Ok(res) => println!("Success: {:?}", res),
116/// }
117/// # }
118/// ```
119#[derive(Clone)]
120pub struct Pubsub<C> {
121 pub client: common::Client<C>,
122 pub auth: Box<dyn common::GetToken>,
123 _user_agent: String,
124 _base_url: String,
125 _root_url: String,
126}
127
128impl<C> common::Hub for Pubsub<C> {}
129
130impl<'a, C> Pubsub<C> {
131 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Pubsub<C> {
132 Pubsub {
133 client,
134 auth: Box::new(auth),
135 _user_agent: "google-api-rust-client/7.0.0".to_string(),
136 _base_url: "https://pubsub.googleapis.com/".to_string(),
137 _root_url: "https://pubsub.googleapis.com/".to_string(),
138 }
139 }
140
141 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
142 ProjectMethods { hub: self }
143 }
144
145 /// Set the user-agent header field to use in all requests to the server.
146 /// It defaults to `google-api-rust-client/7.0.0`.
147 ///
148 /// Returns the previously set user-agent.
149 pub fn user_agent(&mut self, agent_name: String) -> String {
150 std::mem::replace(&mut self._user_agent, agent_name)
151 }
152
153 /// Set the base url to use in all requests to the server.
154 /// It defaults to `https://pubsub.googleapis.com/`.
155 ///
156 /// Returns the previously set base url.
157 pub fn base_url(&mut self, new_base_url: String) -> String {
158 std::mem::replace(&mut self._base_url, new_base_url)
159 }
160
161 /// Set the root url to use in all requests to the server.
162 /// It defaults to `https://pubsub.googleapis.com/`.
163 ///
164 /// Returns the previously set root url.
165 pub fn root_url(&mut self, new_root_url: String) -> String {
166 std::mem::replace(&mut self._root_url, new_root_url)
167 }
168}
169
170// ############
171// SCHEMAS ###
172// ##########
173/// Request for the Acknowledge method.
174///
175/// # Activities
176///
177/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
178/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
179///
180/// * [subscriptions acknowledge projects](ProjectSubscriptionAcknowledgeCall) (request)
181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
182#[serde_with::serde_as]
183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
184pub struct AcknowledgeRequest {
185 /// Required. The acknowledgment ID for the messages being acknowledged that was returned by the Pub/Sub system in the `Pull` response. Must not be empty.
186 #[serde(rename = "ackIds")]
187 pub ack_ids: Option<Vec<String>>,
188}
189
190impl common::RequestValue for AcknowledgeRequest {}
191
192/// Information about an associated [Analytics Hub subscription](https://cloud.google.com/bigquery/docs/analytics-hub-manage-subscriptions).
193///
194/// This type is not used in any activity, and only used as *part* of another schema.
195///
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct AnalyticsHubSubscriptionInfo {
200 /// Optional. The name of the associated Analytics Hub listing resource. Pattern: "projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}"
201 pub listing: Option<String>,
202 /// Optional. The name of the associated Analytics Hub subscription resource. Pattern: "projects/{project}/locations/{location}/subscriptions/{subscription}"
203 pub subscription: Option<String>,
204}
205
206impl common::Part for AnalyticsHubSubscriptionInfo {}
207
208/// Configuration for writing message data in Avro format. Message payloads and metadata will be written to files as an Avro binary.
209///
210/// This type is not used in any activity, and only used as *part* of another schema.
211///
212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
213#[serde_with::serde_as]
214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
215pub struct AvroConfig {
216 /// Optional. When true, the output Cloud Storage file will be serialized using the topic schema, if it exists.
217 #[serde(rename = "useTopicSchema")]
218 pub use_topic_schema: Option<bool>,
219 /// Optional. When true, write the subscription name, message_id, publish_time, attributes, and ordering_key as additional fields in the output. The subscription name, message_id, and publish_time fields are put in their own fields while all other message properties other than data (for example, an ordering_key, if present) are added as entries in the attributes map.
220 #[serde(rename = "writeMetadata")]
221 pub write_metadata: Option<bool>,
222}
223
224impl common::Part for AvroConfig {}
225
226/// Configuration for reading Cloud Storage data in Avro binary format. The bytes of each object will be set to the `data` field of a Pub/Sub message.
227///
228/// This type is not used in any activity, and only used as *part* of another schema.
229///
230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
231#[serde_with::serde_as]
232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
233pub struct AvroFormat {
234 _never_set: Option<bool>,
235}
236
237impl common::Part for AvroFormat {}
238
239/// Ingestion settings for Amazon Kinesis Data Streams.
240///
241/// This type is not used in any activity, and only used as *part* of another schema.
242///
243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
244#[serde_with::serde_as]
245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
246pub struct AwsKinesis {
247 /// Required. AWS role ARN to be used for Federated Identity authentication with Kinesis. Check the Pub/Sub docs for how to set up this role and the required permissions that need to be attached to it.
248 #[serde(rename = "awsRoleArn")]
249 pub aws_role_arn: Option<String>,
250 /// Required. The Kinesis consumer ARN to used for ingestion in Enhanced Fan-Out mode. The consumer must be already created and ready to be used.
251 #[serde(rename = "consumerArn")]
252 pub consumer_arn: Option<String>,
253 /// Required. The GCP service account to be used for Federated Identity authentication with Kinesis (via a `AssumeRoleWithWebIdentity` call for the provided role). The `aws_role_arn` must be set up with `accounts.google.com:sub` equals to this service account number.
254 #[serde(rename = "gcpServiceAccount")]
255 pub gcp_service_account: Option<String>,
256 /// Output only. An output-only field that indicates the state of the Kinesis ingestion source.
257 pub state: Option<String>,
258 /// Required. The Kinesis stream ARN to ingest data from.
259 #[serde(rename = "streamArn")]
260 pub stream_arn: Option<String>,
261}
262
263impl common::Part for AwsKinesis {}
264
265/// Ingestion settings for Amazon MSK.
266///
267/// This type is not used in any activity, and only used as *part* of another schema.
268///
269#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
270#[serde_with::serde_as]
271#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
272pub struct AwsMsk {
273 /// Required. AWS role ARN to be used for Federated Identity authentication with Amazon MSK. Check the Pub/Sub docs for how to set up this role and the required permissions that need to be attached to it.
274 #[serde(rename = "awsRoleArn")]
275 pub aws_role_arn: Option<String>,
276 /// Required. The Amazon Resource Name (ARN) that uniquely identifies the cluster.
277 #[serde(rename = "clusterArn")]
278 pub cluster_arn: Option<String>,
279 /// Required. The GCP service account to be used for Federated Identity authentication with Amazon MSK (via a `AssumeRoleWithWebIdentity` call for the provided role). The `aws_role_arn` must be set up with `accounts.google.com:sub` equals to this service account number.
280 #[serde(rename = "gcpServiceAccount")]
281 pub gcp_service_account: Option<String>,
282 /// Output only. An output-only field that indicates the state of the Amazon MSK ingestion source.
283 pub state: Option<String>,
284 /// Required. The name of the topic in the Amazon MSK cluster that Pub/Sub will import from.
285 pub topic: Option<String>,
286}
287
288impl common::Part for AwsMsk {}
289
290/// Ingestion settings for Azure Event Hubs.
291///
292/// This type is not used in any activity, and only used as *part* of another schema.
293///
294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
295#[serde_with::serde_as]
296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
297pub struct AzureEventHubs {
298 /// Optional. The client id of the Azure application that is being used to authenticate Pub/Sub.
299 #[serde(rename = "clientId")]
300 pub client_id: Option<String>,
301 /// Optional. The name of the Event Hub.
302 #[serde(rename = "eventHub")]
303 pub event_hub: Option<String>,
304 /// Optional. The GCP service account to be used for Federated Identity authentication.
305 #[serde(rename = "gcpServiceAccount")]
306 pub gcp_service_account: Option<String>,
307 /// Optional. The name of the Event Hubs namespace.
308 pub namespace: Option<String>,
309 /// Optional. Name of the resource group within the azure subscription.
310 #[serde(rename = "resourceGroup")]
311 pub resource_group: Option<String>,
312 /// Output only. An output-only field that indicates the state of the Event Hubs ingestion source.
313 pub state: Option<String>,
314 /// Optional. The Azure subscription id.
315 #[serde(rename = "subscriptionId")]
316 pub subscription_id: Option<String>,
317 /// Optional. The tenant id of the Azure application that is being used to authenticate Pub/Sub.
318 #[serde(rename = "tenantId")]
319 pub tenant_id: Option<String>,
320}
321
322impl common::Part for AzureEventHubs {}
323
324/// Configuration for a BigQuery subscription.
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 BigQueryConfig {
332 /// Optional. When true and use_topic_schema is true, any fields that are a part of the topic schema that are not part of the BigQuery table schema are dropped when writing to BigQuery. Otherwise, the schemas must be kept in sync and any messages with extra fields are not written and remain in the subscription's backlog.
333 #[serde(rename = "dropUnknownFields")]
334 pub drop_unknown_fields: Option<bool>,
335 /// Optional. The service account to use to write to BigQuery. The subscription creator or updater that specifies this field must have `iam.serviceAccounts.actAs` permission on the service account. If not specified, the Pub/Sub [service agent](https://cloud.google.com/iam/docs/service-agents), service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
336 #[serde(rename = "serviceAccountEmail")]
337 pub service_account_email: Option<String>,
338 /// Output only. An output-only field that indicates whether or not the subscription can receive messages.
339 pub state: Option<String>,
340 /// Optional. The name of the table to which to write data, of the form {projectId}.{datasetId}.{tableId}
341 pub table: Option<String>,
342 /// Optional. When true, use the BigQuery table's schema as the columns to write to in BigQuery. `use_table_schema` and `use_topic_schema` cannot be enabled at the same time.
343 #[serde(rename = "useTableSchema")]
344 pub use_table_schema: Option<bool>,
345 /// Optional. When true, use the topic's schema as the columns to write to in BigQuery, if it exists. `use_topic_schema` and `use_table_schema` cannot be enabled at the same time.
346 #[serde(rename = "useTopicSchema")]
347 pub use_topic_schema: Option<bool>,
348 /// Optional. When true, write the subscription name, message_id, publish_time, attributes, and ordering_key to additional columns in the table. The subscription name, message_id, and publish_time fields are put in their own columns while all other message properties (other than data) are written to a JSON object in the attributes column.
349 #[serde(rename = "writeMetadata")]
350 pub write_metadata: Option<bool>,
351}
352
353impl common::Part for BigQueryConfig {}
354
355/// Associates `members`, or principals, with a `role`.
356///
357/// This type is not used in any activity, and only used as *part* of another schema.
358///
359#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
360#[serde_with::serde_as]
361#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
362pub struct Binding {
363 /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
364 pub condition: Option<Expr>,
365 /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
366 pub members: Option<Vec<String>>,
367 /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
368 pub role: Option<String>,
369}
370
371impl common::Part for Binding {}
372
373/// Ingestion settings for Cloud Storage.
374///
375/// This type is not used in any activity, and only used as *part* of another schema.
376///
377#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
378#[serde_with::serde_as]
379#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
380pub struct CloudStorage {
381 /// Optional. Data from Cloud Storage will be interpreted in Avro format.
382 #[serde(rename = "avroFormat")]
383 pub avro_format: Option<AvroFormat>,
384 /// Optional. Cloud Storage bucket. The bucket name must be without any prefix like "gs://". See the [bucket naming requirements] (https://cloud.google.com/storage/docs/buckets#naming).
385 pub bucket: Option<String>,
386 /// Optional. Glob pattern used to match objects that will be ingested. If unset, all objects will be ingested. See the [supported patterns](https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-objects-and-prefixes-using-glob).
387 #[serde(rename = "matchGlob")]
388 pub match_glob: Option<String>,
389 /// Optional. Only objects with a larger or equal creation timestamp will be ingested.
390 #[serde(rename = "minimumObjectCreateTime")]
391 pub minimum_object_create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
392 /// Optional. It will be assumed data from Cloud Storage was written via [Cloud Storage subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage).
393 #[serde(rename = "pubsubAvroFormat")]
394 pub pubsub_avro_format: Option<PubSubAvroFormat>,
395 /// Output only. An output-only field that indicates the state of the Cloud Storage ingestion source.
396 pub state: Option<String>,
397 /// Optional. Data from Cloud Storage will be interpreted as text.
398 #[serde(rename = "textFormat")]
399 pub text_format: Option<TextFormat>,
400}
401
402impl common::Part for CloudStorage {}
403
404/// Configuration for a Cloud Storage subscription.
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 CloudStorageConfig {
412 /// Optional. If set, message data will be written to Cloud Storage in Avro format.
413 #[serde(rename = "avroConfig")]
414 pub avro_config: Option<AvroConfig>,
415 /// Required. User-provided name for the Cloud Storage bucket. The bucket must be created by the user. The bucket name must be without any prefix like "gs://". See the [bucket naming requirements] (https://cloud.google.com/storage/docs/buckets#naming).
416 pub bucket: Option<String>,
417 /// Optional. User-provided format string specifying how to represent datetimes in Cloud Storage filenames. See the [datetime format guidance](https://cloud.google.com/pubsub/docs/create-cloudstorage-subscription#file_names).
418 #[serde(rename = "filenameDatetimeFormat")]
419 pub filename_datetime_format: Option<String>,
420 /// Optional. User-provided prefix for Cloud Storage filename. See the [object naming requirements](https://cloud.google.com/storage/docs/objects#naming).
421 #[serde(rename = "filenamePrefix")]
422 pub filename_prefix: Option<String>,
423 /// Optional. User-provided suffix for Cloud Storage filename. See the [object naming requirements](https://cloud.google.com/storage/docs/objects#naming). Must not end in "/".
424 #[serde(rename = "filenameSuffix")]
425 pub filename_suffix: Option<String>,
426 /// Optional. The maximum bytes that can be written to a Cloud Storage file before a new file is created. Min 1 KB, max 10 GiB. The max_bytes limit may be exceeded in cases where messages are larger than the limit.
427 #[serde(rename = "maxBytes")]
428 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
429 pub max_bytes: Option<i64>,
430 /// Optional. The maximum duration that can elapse before a new Cloud Storage file is created. Min 1 minute, max 10 minutes, default 5 minutes. May not exceed the subscription's acknowledgment deadline.
431 #[serde(rename = "maxDuration")]
432 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
433 pub max_duration: Option<chrono::Duration>,
434 /// Optional. The maximum number of messages that can be written to a Cloud Storage file before a new file is created. Min 1000 messages.
435 #[serde(rename = "maxMessages")]
436 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
437 pub max_messages: Option<i64>,
438 /// Optional. The service account to use to write to Cloud Storage. The subscription creator or updater that specifies this field must have `iam.serviceAccounts.actAs` permission on the service account. If not specified, the Pub/Sub [service agent](https://cloud.google.com/iam/docs/service-agents), service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
439 #[serde(rename = "serviceAccountEmail")]
440 pub service_account_email: Option<String>,
441 /// Output only. An output-only field that indicates whether or not the subscription can receive messages.
442 pub state: Option<String>,
443 /// Optional. If set, message data will be written to Cloud Storage in text format.
444 #[serde(rename = "textConfig")]
445 pub text_config: Option<TextConfig>,
446}
447
448impl common::Part for CloudStorageConfig {}
449
450/// Request for CommitSchema method.
451///
452/// # Activities
453///
454/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
455/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
456///
457/// * [schemas commit projects](ProjectSchemaCommitCall) (request)
458#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
459#[serde_with::serde_as]
460#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
461pub struct CommitSchemaRequest {
462 /// Required. The schema revision to commit.
463 pub schema: Option<Schema>,
464}
465
466impl common::RequestValue for CommitSchemaRequest {}
467
468/// Ingestion settings for Confluent Cloud.
469///
470/// This type is not used in any activity, and only used as *part* of another schema.
471///
472#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
473#[serde_with::serde_as]
474#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
475pub struct ConfluentCloud {
476 /// Required. The address of the bootstrap server. The format is url:port.
477 #[serde(rename = "bootstrapServer")]
478 pub bootstrap_server: Option<String>,
479 /// Required. The id of the cluster.
480 #[serde(rename = "clusterId")]
481 pub cluster_id: Option<String>,
482 /// Required. The GCP service account to be used for Federated Identity authentication with `identity_pool_id`.
483 #[serde(rename = "gcpServiceAccount")]
484 pub gcp_service_account: Option<String>,
485 /// Required. The id of the identity pool to be used for Federated Identity authentication with Confluent Cloud. See https://docs.confluent.io/cloud/current/security/authenticate/workload-identities/identity-providers/oauth/identity-pools.html#add-oauth-identity-pools.
486 #[serde(rename = "identityPoolId")]
487 pub identity_pool_id: Option<String>,
488 /// Output only. An output-only field that indicates the state of the Confluent Cloud ingestion source.
489 pub state: Option<String>,
490 /// Required. The name of the topic in the Confluent Cloud cluster that Pub/Sub will import from.
491 pub topic: Option<String>,
492}
493
494impl common::Part for ConfluentCloud {}
495
496/// Request for the `CreateSnapshot` method.
497///
498/// # Activities
499///
500/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
501/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
502///
503/// * [snapshots create projects](ProjectSnapshotCreateCall) (request)
504#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
505#[serde_with::serde_as]
506#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
507pub struct CreateSnapshotRequest {
508 /// Optional. See [Creating and managing labels](https://cloud.google.com/pubsub/docs/labels).
509 pub labels: Option<HashMap<String, String>>,
510 /// Required. Identifier. The subscription whose backlog the snapshot retains. Specifically, the created snapshot is guaranteed to retain: (a) The existing backlog on the subscription. More precisely, this is defined as the messages in the subscription's backlog that are unacknowledged upon the successful completion of the `CreateSnapshot` request; as well as: (b) Any messages published to the subscription's topic following the successful completion of the CreateSnapshot request. Format is `projects/{project}/subscriptions/{sub}`.
511 pub subscription: Option<String>,
512 /// Optional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing"
513 pub tags: Option<HashMap<String, String>>,
514}
515
516impl common::RequestValue for CreateSnapshotRequest {}
517
518/// Dead lettering is done on a best effort basis. The same message might be dead lettered multiple times. If validation on any of the fields fails at subscription creation/updation, the create/update subscription request will fail.
519///
520/// This type is not used in any activity, and only used as *part* of another schema.
521///
522#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
523#[serde_with::serde_as]
524#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
525pub struct DeadLetterPolicy {
526 /// Optional. The name of the topic to which dead letter messages should be published. Format is `projects/{project}/topics/{topic}`.The Pub/Sub service account associated with the enclosing subscription's parent project (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have permission to Publish() to this topic. The operation will fail if the topic does not exist. Users should ensure that there is a subscription attached to this topic since messages published to a topic with no subscriptions are lost.
527 #[serde(rename = "deadLetterTopic")]
528 pub dead_letter_topic: Option<String>,
529 /// Optional. The maximum number of delivery attempts for any message. The value must be between 5 and 100. The number of delivery attempts is defined as 1 + (the sum of number of NACKs and number of times the acknowledgment deadline has been exceeded for the message). A NACK is any call to ModifyAckDeadline with a 0 deadline. Note that client libraries may automatically extend ack_deadlines. This field will be honored on a best effort basis. If this parameter is 0, a default value of 5 is used.
530 #[serde(rename = "maxDeliveryAttempts")]
531 pub max_delivery_attempts: Option<i32>,
532}
533
534impl common::Part for DeadLetterPolicy {}
535
536/// Response for the DetachSubscription method. Reserved for future use.
537///
538/// # Activities
539///
540/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
541/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
542///
543/// * [subscriptions detach projects](ProjectSubscriptionDetachCall) (response)
544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
545#[serde_with::serde_as]
546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
547pub struct DetachSubscriptionResponse {
548 _never_set: Option<bool>,
549}
550
551impl common::ResponseResult for DetachSubscriptionResponse {}
552
553/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
554///
555/// # Activities
556///
557/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
558/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
559///
560/// * [schemas delete projects](ProjectSchemaDeleteCall) (response)
561/// * [snapshots delete projects](ProjectSnapshotDeleteCall) (response)
562/// * [subscriptions acknowledge projects](ProjectSubscriptionAcknowledgeCall) (response)
563/// * [subscriptions delete projects](ProjectSubscriptionDeleteCall) (response)
564/// * [subscriptions modify ack deadline projects](ProjectSubscriptionModifyAckDeadlineCall) (response)
565/// * [subscriptions modify push config projects](ProjectSubscriptionModifyPushConfigCall) (response)
566/// * [topics delete projects](ProjectTopicDeleteCall) (response)
567#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
568#[serde_with::serde_as]
569#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
570pub struct Empty {
571 _never_set: Option<bool>,
572}
573
574impl common::ResponseResult for Empty {}
575
576/// A policy that specifies the conditions for resource expiration (i.e., automatic resource deletion).
577///
578/// This type is not used in any activity, and only used as *part* of another schema.
579///
580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
581#[serde_with::serde_as]
582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
583pub struct ExpirationPolicy {
584 /// Optional. Specifies the "time-to-live" duration for an associated resource. The resource expires if it is not active for a period of `ttl`. The definition of "activity" depends on the type of the associated resource. The minimum and maximum allowed values for `ttl` depend on the type of the associated resource, as well. If `ttl` is not set, the associated resource never expires.
585 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
586 pub ttl: Option<chrono::Duration>,
587}
588
589impl common::Part for ExpirationPolicy {}
590
591/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
592///
593/// This type is not used in any activity, and only used as *part* of another schema.
594///
595#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
596#[serde_with::serde_as]
597#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
598pub struct Expr {
599 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
600 pub description: Option<String>,
601 /// Textual representation of an expression in Common Expression Language syntax.
602 pub expression: Option<String>,
603 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
604 pub location: Option<String>,
605 /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
606 pub title: Option<String>,
607}
608
609impl common::Part for Expr {}
610
611/// Settings for an ingestion data source on a topic.
612///
613/// This type is not used in any activity, and only used as *part* of another schema.
614///
615#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
616#[serde_with::serde_as]
617#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
618pub struct IngestionDataSourceSettings {
619 /// Optional. Amazon Kinesis Data Streams.
620 #[serde(rename = "awsKinesis")]
621 pub aws_kinesis: Option<AwsKinesis>,
622 /// Optional. Amazon MSK.
623 #[serde(rename = "awsMsk")]
624 pub aws_msk: Option<AwsMsk>,
625 /// Optional. Azure Event Hubs.
626 #[serde(rename = "azureEventHubs")]
627 pub azure_event_hubs: Option<AzureEventHubs>,
628 /// Optional. Cloud Storage.
629 #[serde(rename = "cloudStorage")]
630 pub cloud_storage: Option<CloudStorage>,
631 /// Optional. Confluent Cloud.
632 #[serde(rename = "confluentCloud")]
633 pub confluent_cloud: Option<ConfluentCloud>,
634 /// Optional. Platform Logs settings. If unset, no Platform Logs will be generated.
635 #[serde(rename = "platformLogsSettings")]
636 pub platform_logs_settings: Option<PlatformLogsSettings>,
637}
638
639impl common::Part for IngestionDataSourceSettings {}
640
641/// User-defined JavaScript function that can transform or filter a Pub/Sub message.
642///
643/// This type is not used in any activity, and only used as *part* of another schema.
644///
645#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
646#[serde_with::serde_as]
647#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
648pub struct JavaScriptUDF {
649 /// Required. JavaScript code that contains a function `function_name` with the below signature: ``` /** * Transforms a Pub/Sub message. * @return {(Object)>|null)} - To * filter a message, return `null`. To transform a message return a map * with the following keys: * - (required) 'data' : {string} * - (optional) 'attributes' : {Object} * Returning empty `attributes` will remove all attributes from the * message. * * @param {(Object)>} Pub/Sub * message. Keys: * - (required) 'data' : {string} * - (required) 'attributes' : {Object} * * @param {Object} metadata - Pub/Sub message metadata. * Keys: * - (optional) 'message_id' : {string} * - (optional) 'publish_time': {string} YYYY-MM-DDTHH:MM:SSZ format * - (optional) 'ordering_key': {string} */ function (message, metadata) { } ```
650 pub code: Option<String>,
651 /// Required. Name of the JavasScript function that should applied to Pub/Sub messages.
652 #[serde(rename = "functionName")]
653 pub function_name: Option<String>,
654}
655
656impl common::Part for JavaScriptUDF {}
657
658/// Response for the `ListSchemaRevisions` method.
659///
660/// # Activities
661///
662/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
663/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
664///
665/// * [schemas list revisions projects](ProjectSchemaListRevisionCall) (response)
666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
667#[serde_with::serde_as]
668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
669pub struct ListSchemaRevisionsResponse {
670 /// A token that can be sent as `page_token` to retrieve the next page. If this field is empty, there are no subsequent pages.
671 #[serde(rename = "nextPageToken")]
672 pub next_page_token: Option<String>,
673 /// The revisions of the schema.
674 pub schemas: Option<Vec<Schema>>,
675}
676
677impl common::ResponseResult for ListSchemaRevisionsResponse {}
678
679/// Response for the `ListSchemas` method.
680///
681/// # Activities
682///
683/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
684/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
685///
686/// * [schemas list projects](ProjectSchemaListCall) (response)
687#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
688#[serde_with::serde_as]
689#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
690pub struct ListSchemasResponse {
691 /// If not empty, indicates that there may be more schemas that match the request; this value should be passed in a new `ListSchemasRequest`.
692 #[serde(rename = "nextPageToken")]
693 pub next_page_token: Option<String>,
694 /// The resulting schemas.
695 pub schemas: Option<Vec<Schema>>,
696}
697
698impl common::ResponseResult for ListSchemasResponse {}
699
700/// Response for the `ListSnapshots` method.
701///
702/// # Activities
703///
704/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
705/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
706///
707/// * [snapshots list projects](ProjectSnapshotListCall) (response)
708#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
709#[serde_with::serde_as]
710#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
711pub struct ListSnapshotsResponse {
712 /// Optional. If not empty, indicates that there may be more snapshot that match the request; this value should be passed in a new `ListSnapshotsRequest`.
713 #[serde(rename = "nextPageToken")]
714 pub next_page_token: Option<String>,
715 /// Optional. The resulting snapshots.
716 pub snapshots: Option<Vec<Snapshot>>,
717}
718
719impl common::ResponseResult for ListSnapshotsResponse {}
720
721/// Response for the `ListSubscriptions` method.
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/// * [subscriptions list projects](ProjectSubscriptionListCall) (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 ListSubscriptionsResponse {
733 /// Optional. If not empty, indicates that there may be more subscriptions that match the request; this value should be passed in a new `ListSubscriptionsRequest` to get more subscriptions.
734 #[serde(rename = "nextPageToken")]
735 pub next_page_token: Option<String>,
736 /// Optional. The subscriptions that match the request.
737 pub subscriptions: Option<Vec<Subscription>>,
738}
739
740impl common::ResponseResult for ListSubscriptionsResponse {}
741
742/// Response for the `ListTopicSnapshots` method.
743///
744/// # Activities
745///
746/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
747/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
748///
749/// * [topics snapshots list projects](ProjectTopicSnapshotListCall) (response)
750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
751#[serde_with::serde_as]
752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
753pub struct ListTopicSnapshotsResponse {
754 /// Optional. If not empty, indicates that there may be more snapshots that match the request; this value should be passed in a new `ListTopicSnapshotsRequest` to get more snapshots.
755 #[serde(rename = "nextPageToken")]
756 pub next_page_token: Option<String>,
757 /// Optional. The names of the snapshots that match the request.
758 pub snapshots: Option<Vec<String>>,
759}
760
761impl common::ResponseResult for ListTopicSnapshotsResponse {}
762
763/// Response for the `ListTopicSubscriptions` method.
764///
765/// # Activities
766///
767/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
768/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
769///
770/// * [topics subscriptions list projects](ProjectTopicSubscriptionListCall) (response)
771#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
772#[serde_with::serde_as]
773#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
774pub struct ListTopicSubscriptionsResponse {
775 /// Optional. If not empty, indicates that there may be more subscriptions that match the request; this value should be passed in a new `ListTopicSubscriptionsRequest` to get more subscriptions.
776 #[serde(rename = "nextPageToken")]
777 pub next_page_token: Option<String>,
778 /// Optional. The names of subscriptions attached to the topic specified in the request.
779 pub subscriptions: Option<Vec<String>>,
780}
781
782impl common::ResponseResult for ListTopicSubscriptionsResponse {}
783
784/// Response for the `ListTopics` method.
785///
786/// # Activities
787///
788/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
789/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
790///
791/// * [topics list projects](ProjectTopicListCall) (response)
792#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
793#[serde_with::serde_as]
794#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
795pub struct ListTopicsResponse {
796 /// Optional. If not empty, indicates that there may be more topics that match the request; this value should be passed in a new `ListTopicsRequest`.
797 #[serde(rename = "nextPageToken")]
798 pub next_page_token: Option<String>,
799 /// Optional. The resulting topics.
800 pub topics: Option<Vec<Topic>>,
801}
802
803impl common::ResponseResult for ListTopicsResponse {}
804
805/// A policy constraining the storage of messages published to the topic.
806///
807/// This type is not used in any activity, and only used as *part* of another schema.
808///
809#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
810#[serde_with::serde_as]
811#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
812pub struct MessageStoragePolicy {
813 /// Optional. A list of IDs of Google Cloud regions where messages that are published to the topic may be persisted in storage. Messages published by publishers running in non-allowed Google Cloud regions (or running outside of Google Cloud altogether) are routed for storage in one of the allowed regions. An empty list means that no regions are allowed, and is not a valid configuration.
814 #[serde(rename = "allowedPersistenceRegions")]
815 pub allowed_persistence_regions: Option<Vec<String>>,
816 /// Optional. If true, `allowed_persistence_regions` is also used to enforce in-transit guarantees for messages. That is, Pub/Sub will fail Publish operations on this topic and subscribe operations on any subscription attached to this topic in any region that is not in `allowed_persistence_regions`.
817 #[serde(rename = "enforceInTransit")]
818 pub enforce_in_transit: Option<bool>,
819}
820
821impl common::Part for MessageStoragePolicy {}
822
823/// All supported message transforms types.
824///
825/// This type is not used in any activity, and only used as *part* of another schema.
826///
827#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
828#[serde_with::serde_as]
829#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
830pub struct MessageTransform {
831 /// Optional. If true, the transform is disabled and will not be applied to messages. Defaults to `false`.
832 pub disabled: Option<bool>,
833 /// Optional. This field is deprecated, use the `disabled` field to disable transforms.
834 pub enabled: Option<bool>,
835 /// Optional. JavaScript User Defined Function. If multiple JavaScriptUDF's are specified on a resource, each must have a unique `function_name`.
836 #[serde(rename = "javascriptUdf")]
837 pub javascript_udf: Option<JavaScriptUDF>,
838}
839
840impl common::Part for MessageTransform {}
841
842/// Request for the ModifyAckDeadline method.
843///
844/// # Activities
845///
846/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
847/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
848///
849/// * [subscriptions modify ack deadline projects](ProjectSubscriptionModifyAckDeadlineCall) (request)
850#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
851#[serde_with::serde_as]
852#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
853pub struct ModifyAckDeadlineRequest {
854 /// Required. The new ack deadline with respect to the time this request was sent to the Pub/Sub system. For example, if the value is 10, the new ack deadline will expire 10 seconds after the `ModifyAckDeadline` call was made. Specifying zero might immediately make the message available for delivery to another subscriber client. This typically results in an increase in the rate of message redeliveries (that is, duplicates). The minimum deadline you can specify is 0 seconds. The maximum deadline you can specify in a single request is 600 seconds (10 minutes).
855 #[serde(rename = "ackDeadlineSeconds")]
856 pub ack_deadline_seconds: Option<i32>,
857 /// Required. List of acknowledgment IDs.
858 #[serde(rename = "ackIds")]
859 pub ack_ids: Option<Vec<String>>,
860}
861
862impl common::RequestValue for ModifyAckDeadlineRequest {}
863
864/// Request for the ModifyPushConfig method.
865///
866/// # Activities
867///
868/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
869/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
870///
871/// * [subscriptions modify push config projects](ProjectSubscriptionModifyPushConfigCall) (request)
872#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
873#[serde_with::serde_as]
874#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
875pub struct ModifyPushConfigRequest {
876 /// Required. The push configuration for future deliveries. An empty `pushConfig` indicates that the Pub/Sub system should stop pushing messages from the given subscription and allow messages to be pulled and acknowledged - effectively pausing the subscription if `Pull` or `StreamingPull` is not called.
877 #[serde(rename = "pushConfig")]
878 pub push_config: Option<PushConfig>,
879}
880
881impl common::RequestValue for ModifyPushConfigRequest {}
882
883/// Sets the `data` field as the HTTP body for delivery.
884///
885/// This type is not used in any activity, and only used as *part* of another schema.
886///
887#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
888#[serde_with::serde_as]
889#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
890pub struct NoWrapper {
891 /// Optional. When true, writes the Pub/Sub message metadata to `x-goog-pubsub-:` headers of the HTTP request. Writes the Pub/Sub message attributes to `:` headers of the HTTP request.
892 #[serde(rename = "writeMetadata")]
893 pub write_metadata: Option<bool>,
894}
895
896impl common::Part for NoWrapper {}
897
898/// Contains information needed for generating an [OpenID Connect token](https://developers.google.com/identity/protocols/OpenIDConnect).
899///
900/// This type is not used in any activity, and only used as *part* of another schema.
901///
902#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
903#[serde_with::serde_as]
904#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
905pub struct OidcToken {
906 /// Optional. Audience to be used when generating OIDC token. The audience claim identifies the recipients that the JWT is intended for. The audience value is a single case-sensitive string. Having multiple values (array) for the audience field is not supported. More info about the OIDC JWT token audience here: https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified, the Push endpoint URL will be used.
907 pub audience: Option<String>,
908 /// Optional. [Service account email](https://cloud.google.com/iam/docs/service-accounts) used for generating the OIDC token. For more information on setting up authentication, see [Push subscriptions](https://cloud.google.com/pubsub/docs/push).
909 #[serde(rename = "serviceAccountEmail")]
910 pub service_account_email: Option<String>,
911}
912
913impl common::Part for OidcToken {}
914
915/// Settings for Platform Logs produced by Pub/Sub.
916///
917/// This type is not used in any activity, and only used as *part* of another schema.
918///
919#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
920#[serde_with::serde_as]
921#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
922pub struct PlatformLogsSettings {
923 /// Optional. The minimum severity level of Platform Logs that will be written.
924 pub severity: Option<String>,
925}
926
927impl common::Part for PlatformLogsSettings {}
928
929/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
930///
931/// # Activities
932///
933/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
934/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
935///
936/// * [schemas get iam policy projects](ProjectSchemaGetIamPolicyCall) (response)
937/// * [schemas set iam policy projects](ProjectSchemaSetIamPolicyCall) (response)
938/// * [snapshots get iam policy projects](ProjectSnapshotGetIamPolicyCall) (response)
939/// * [snapshots set iam policy projects](ProjectSnapshotSetIamPolicyCall) (response)
940/// * [subscriptions get iam policy projects](ProjectSubscriptionGetIamPolicyCall) (response)
941/// * [subscriptions set iam policy projects](ProjectSubscriptionSetIamPolicyCall) (response)
942/// * [topics get iam policy projects](ProjectTopicGetIamPolicyCall) (response)
943/// * [topics set iam policy projects](ProjectTopicSetIamPolicyCall) (response)
944#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
945#[serde_with::serde_as]
946#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
947pub struct Policy {
948 /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
949 pub bindings: Option<Vec<Binding>>,
950 /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
951 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
952 pub etag: Option<Vec<u8>>,
953 /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
954 pub version: Option<i32>,
955}
956
957impl common::ResponseResult for Policy {}
958
959/// Configuration for reading Cloud Storage data written via [Cloud Storage subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage). The data and attributes fields of the originally exported Pub/Sub message will be restored when publishing.
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 PubSubAvroFormat {
967 _never_set: Option<bool>,
968}
969
970impl common::Part for PubSubAvroFormat {}
971
972/// Request for the Publish method.
973///
974/// # Activities
975///
976/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
977/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
978///
979/// * [topics publish projects](ProjectTopicPublishCall) (request)
980#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
981#[serde_with::serde_as]
982#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
983pub struct PublishRequest {
984 /// Required. The messages to publish.
985 pub messages: Option<Vec<PubsubMessage>>,
986}
987
988impl common::RequestValue for PublishRequest {}
989
990/// Response for the `Publish` method.
991///
992/// # Activities
993///
994/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
995/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
996///
997/// * [topics publish projects](ProjectTopicPublishCall) (response)
998#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
999#[serde_with::serde_as]
1000#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1001pub struct PublishResponse {
1002 /// Optional. The server-assigned ID of each published message, in the same order as the messages in the request. IDs are guaranteed to be unique within the topic.
1003 #[serde(rename = "messageIds")]
1004 pub message_ids: Option<Vec<String>>,
1005}
1006
1007impl common::ResponseResult for PublishResponse {}
1008
1009/// A message that is published by publishers and consumed by subscribers. The message must contain either a non-empty data field or at least one attribute. Note that client libraries represent this object differently depending on the language. See the corresponding [client library documentation](https://cloud.google.com/pubsub/docs/reference/libraries) for more information. See [quotas and limits] (https://cloud.google.com/pubsub/quotas) for more information about message limits.
1010///
1011/// This type is not used in any activity, and only used as *part* of another schema.
1012///
1013#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1014#[serde_with::serde_as]
1015#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1016pub struct PubsubMessage {
1017 /// Optional. Attributes for this message. If this field is empty, the message must contain non-empty data. This can be used to filter messages on the subscription.
1018 pub attributes: Option<HashMap<String, String>>,
1019 /// Optional. The message data field. If this field is empty, the message must contain at least one attribute.
1020 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1021 pub data: Option<Vec<u8>>,
1022 /// ID of this message, assigned by the server when the message is published. Guaranteed to be unique within the topic. This value may be read by a subscriber that receives a `PubsubMessage` via a `Pull` call or a push delivery. It must not be populated by the publisher in a `Publish` call.
1023 #[serde(rename = "messageId")]
1024 pub message_id: Option<String>,
1025 /// Optional. If non-empty, identifies related messages for which publish order should be respected. If a `Subscription` has `enable_message_ordering` set to `true`, messages published with the same non-empty `ordering_key` value will be delivered to subscribers in the order in which they are received by the Pub/Sub system. All `PubsubMessage`s published in a given `PublishRequest` must specify the same `ordering_key` value. For more information, see [ordering messages](https://cloud.google.com/pubsub/docs/ordering).
1026 #[serde(rename = "orderingKey")]
1027 pub ordering_key: Option<String>,
1028 /// The time at which the message was published, populated by the server when it receives the `Publish` call. It must not be populated by the publisher in a `Publish` call.
1029 #[serde(rename = "publishTime")]
1030 pub publish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1031}
1032
1033impl common::Part for PubsubMessage {}
1034
1035/// The payload to the push endpoint is in the form of the JSON representation of a PubsubMessage (https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage).
1036///
1037/// This type is not used in any activity, and only used as *part* of another schema.
1038///
1039#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1040#[serde_with::serde_as]
1041#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1042pub struct PubsubWrapper {
1043 _never_set: Option<bool>,
1044}
1045
1046impl common::Part for PubsubWrapper {}
1047
1048/// Request for the `Pull` method.
1049///
1050/// # Activities
1051///
1052/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1053/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1054///
1055/// * [subscriptions pull projects](ProjectSubscriptionPullCall) (request)
1056#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1057#[serde_with::serde_as]
1058#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1059pub struct PullRequest {
1060 /// Required. The maximum number of messages to return for this request. Must be a positive integer. The Pub/Sub system may return fewer than the number specified.
1061 #[serde(rename = "maxMessages")]
1062 pub max_messages: Option<i32>,
1063 /// Optional. If this field set to true, the system will respond immediately even if it there are no messages available to return in the `Pull` response. Otherwise, the system may wait (for a bounded amount of time) until at least one message is available, rather than returning no messages. Warning: setting this field to `true` is discouraged because it adversely impacts the performance of `Pull` operations. We recommend that users do not set this field.
1064 #[serde(rename = "returnImmediately")]
1065 pub return_immediately: Option<bool>,
1066}
1067
1068impl common::RequestValue for PullRequest {}
1069
1070/// Response for the `Pull` method.
1071///
1072/// # Activities
1073///
1074/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1075/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1076///
1077/// * [subscriptions pull projects](ProjectSubscriptionPullCall) (response)
1078#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1079#[serde_with::serde_as]
1080#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1081pub struct PullResponse {
1082 /// Optional. Received Pub/Sub messages. The list will be empty if there are no more messages available in the backlog, or if no messages could be returned before the request timeout. For JSON, the response can be entirely empty. The Pub/Sub system may return fewer than the `maxMessages` requested even if there are more messages available in the backlog.
1083 #[serde(rename = "receivedMessages")]
1084 pub received_messages: Option<Vec<ReceivedMessage>>,
1085}
1086
1087impl common::ResponseResult for PullResponse {}
1088
1089/// Configuration for a push delivery endpoint.
1090///
1091/// This type is not used in any activity, and only used as *part* of another schema.
1092///
1093#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1094#[serde_with::serde_as]
1095#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1096pub struct PushConfig {
1097 /// Optional. Endpoint configuration attributes that can be used to control different aspects of the message delivery. The only currently supported attribute is `x-goog-version`, which you can use to change the format of the pushed message. This attribute indicates the version of the data expected by the endpoint. This controls the shape of the pushed message (i.e., its fields and metadata). If not present during the `CreateSubscription` call, it will default to the version of the Pub/Sub API used to make such call. If not present in a `ModifyPushConfig` call, its value will not be changed. `GetSubscription` calls will always return a valid version, even if the subscription was created without this attribute. The only supported values for the `x-goog-version` attribute are: * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API. * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API. For example: `attributes { "x-goog-version": "v1" }`
1098 pub attributes: Option<HashMap<String, String>>,
1099 /// Optional. When set, the payload to the push endpoint is not wrapped.
1100 #[serde(rename = "noWrapper")]
1101 pub no_wrapper: Option<NoWrapper>,
1102 /// Optional. If specified, Pub/Sub will generate and attach an OIDC JWT token as an `Authorization` header in the HTTP request for every pushed message.
1103 #[serde(rename = "oidcToken")]
1104 pub oidc_token: Option<OidcToken>,
1105 /// Optional. When set, the payload to the push endpoint is in the form of the JSON representation of a PubsubMessage (https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage).
1106 #[serde(rename = "pubsubWrapper")]
1107 pub pubsub_wrapper: Option<PubsubWrapper>,
1108 /// Optional. A URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use `https://example.com/push`.
1109 #[serde(rename = "pushEndpoint")]
1110 pub push_endpoint: Option<String>,
1111}
1112
1113impl common::Part for PushConfig {}
1114
1115/// A message and its corresponding acknowledgment ID.
1116///
1117/// This type is not used in any activity, and only used as *part* of another schema.
1118///
1119#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1120#[serde_with::serde_as]
1121#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1122pub struct ReceivedMessage {
1123 /// Optional. This ID can be used to acknowledge the received message.
1124 #[serde(rename = "ackId")]
1125 pub ack_id: Option<String>,
1126 /// Optional. The approximate number of times that Pub/Sub has attempted to deliver the associated message to a subscriber. More precisely, this is 1 + (number of NACKs) + (number of ack_deadline exceeds) for this message. A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline exceeds event is whenever a message is not acknowledged within ack_deadline. Note that ack_deadline is initially Subscription.ackDeadlineSeconds, but may get extended automatically by the client library. Upon the first delivery of a given message, `delivery_attempt` will have a value of 1. The value is calculated at best effort and is approximate. If a DeadLetterPolicy is not set on the subscription, this will be 0.
1127 #[serde(rename = "deliveryAttempt")]
1128 pub delivery_attempt: Option<i32>,
1129 /// Optional. The message.
1130 pub message: Option<PubsubMessage>,
1131}
1132
1133impl common::Part for ReceivedMessage {}
1134
1135/// A policy that specifies how Pub/Sub retries message delivery. Retry delay will be exponential based on provided minimum and maximum backoffs. https://en.wikipedia.org/wiki/Exponential_backoff. RetryPolicy will be triggered on NACKs or acknowledgment deadline exceeded events for a given message. Retry Policy is implemented on a best effort basis. At times, the delay between consecutive deliveries may not match the configuration. That is, delay can be more or less than configured backoff.
1136///
1137/// This type is not used in any activity, and only used as *part* of another schema.
1138///
1139#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1140#[serde_with::serde_as]
1141#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1142pub struct RetryPolicy {
1143 /// Optional. The maximum delay between consecutive deliveries of a given message. Value should be between 0 and 600 seconds. Defaults to 600 seconds.
1144 #[serde(rename = "maximumBackoff")]
1145 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1146 pub maximum_backoff: Option<chrono::Duration>,
1147 /// Optional. The minimum delay between consecutive deliveries of a given message. Value should be between 0 and 600 seconds. Defaults to 10 seconds.
1148 #[serde(rename = "minimumBackoff")]
1149 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1150 pub minimum_backoff: Option<chrono::Duration>,
1151}
1152
1153impl common::Part for RetryPolicy {}
1154
1155/// Request for the `RollbackSchema` method.
1156///
1157/// # Activities
1158///
1159/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1160/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1161///
1162/// * [schemas rollback projects](ProjectSchemaRollbackCall) (request)
1163#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1164#[serde_with::serde_as]
1165#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1166pub struct RollbackSchemaRequest {
1167 /// Required. The revision ID to roll back to. It must be a revision of the same schema. Example: c7cfa2a8
1168 #[serde(rename = "revisionId")]
1169 pub revision_id: Option<String>,
1170}
1171
1172impl common::RequestValue for RollbackSchemaRequest {}
1173
1174/// A schema resource.
1175///
1176/// # Activities
1177///
1178/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1179/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1180///
1181/// * [schemas commit projects](ProjectSchemaCommitCall) (response)
1182/// * [schemas create projects](ProjectSchemaCreateCall) (request|response)
1183/// * [schemas delete revision projects](ProjectSchemaDeleteRevisionCall) (response)
1184/// * [schemas get projects](ProjectSchemaGetCall) (response)
1185/// * [schemas rollback projects](ProjectSchemaRollbackCall) (response)
1186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1187#[serde_with::serde_as]
1188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1189pub struct Schema {
1190 /// The definition of the schema. This should contain a string representing the full definition of the schema that is a valid schema definition of the type specified in `type`.
1191 pub definition: Option<String>,
1192 /// Required. Name of the schema. Format is `projects/{project}/schemas/{schema}`.
1193 pub name: Option<String>,
1194 /// Output only. The timestamp that the revision was created.
1195 #[serde(rename = "revisionCreateTime")]
1196 pub revision_create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1197 /// Output only. Immutable. The revision ID of the schema.
1198 #[serde(rename = "revisionId")]
1199 pub revision_id: Option<String>,
1200 /// The type of the schema definition.
1201 #[serde(rename = "type")]
1202 pub type_: Option<String>,
1203}
1204
1205impl common::RequestValue for Schema {}
1206impl common::ResponseResult for Schema {}
1207
1208/// Settings for validating messages published against a schema.
1209///
1210/// This type is not used in any activity, and only used as *part* of another schema.
1211///
1212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1213#[serde_with::serde_as]
1214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1215pub struct SchemaSettings {
1216 /// Optional. The encoding of messages validated against `schema`.
1217 pub encoding: Option<String>,
1218 /// Optional. The minimum (inclusive) revision allowed for validating messages. If empty or not present, allow any revision to be validated against last_revision or any revision created before.
1219 #[serde(rename = "firstRevisionId")]
1220 pub first_revision_id: Option<String>,
1221 /// Optional. The maximum (inclusive) revision allowed for validating messages. If empty or not present, allow any revision to be validated against first_revision or any revision created after.
1222 #[serde(rename = "lastRevisionId")]
1223 pub last_revision_id: Option<String>,
1224 /// Required. The name of the schema that messages published should be validated against. Format is `projects/{project}/schemas/{schema}`. The value of this field will be `_deleted-schema_` if the schema has been deleted.
1225 pub schema: Option<String>,
1226}
1227
1228impl common::Part for SchemaSettings {}
1229
1230/// Request for the `Seek` method.
1231///
1232/// # Activities
1233///
1234/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1235/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1236///
1237/// * [subscriptions seek projects](ProjectSubscriptionSeekCall) (request)
1238#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1239#[serde_with::serde_as]
1240#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1241pub struct SeekRequest {
1242 /// Optional. The snapshot to seek to. The snapshot's topic must be the same as that of the provided subscription. Format is `projects/{project}/snapshots/{snap}`.
1243 pub snapshot: Option<String>,
1244 /// Optional. The time to seek to. Messages retained in the subscription that were published before this time are marked as acknowledged, and messages retained in the subscription that were published after this time are marked as unacknowledged. Note that this operation affects only those messages retained in the subscription (configured by the combination of `message_retention_duration` and `retain_acked_messages`). For example, if `time` corresponds to a point before the message retention window (or to a point before the system's notion of the subscription creation time), only retained messages will be marked as unacknowledged, and already-expunged messages will not be restored.
1245 pub time: Option<chrono::DateTime<chrono::offset::Utc>>,
1246}
1247
1248impl common::RequestValue for SeekRequest {}
1249
1250/// Response for the `Seek` method (this response is empty).
1251///
1252/// # Activities
1253///
1254/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1255/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1256///
1257/// * [subscriptions seek projects](ProjectSubscriptionSeekCall) (response)
1258#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1259#[serde_with::serde_as]
1260#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1261pub struct SeekResponse {
1262 _never_set: Option<bool>,
1263}
1264
1265impl common::ResponseResult for SeekResponse {}
1266
1267/// Request message for `SetIamPolicy` method.
1268///
1269/// # Activities
1270///
1271/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1272/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1273///
1274/// * [schemas set iam policy projects](ProjectSchemaSetIamPolicyCall) (request)
1275/// * [snapshots set iam policy projects](ProjectSnapshotSetIamPolicyCall) (request)
1276/// * [subscriptions set iam policy projects](ProjectSubscriptionSetIamPolicyCall) (request)
1277/// * [topics set iam policy projects](ProjectTopicSetIamPolicyCall) (request)
1278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1279#[serde_with::serde_as]
1280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1281pub struct SetIamPolicyRequest {
1282 /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
1283 pub policy: Option<Policy>,
1284}
1285
1286impl common::RequestValue for SetIamPolicyRequest {}
1287
1288/// A snapshot resource. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
1289///
1290/// # Activities
1291///
1292/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1293/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1294///
1295/// * [snapshots create projects](ProjectSnapshotCreateCall) (response)
1296/// * [snapshots get projects](ProjectSnapshotGetCall) (response)
1297/// * [snapshots patch projects](ProjectSnapshotPatchCall) (response)
1298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1299#[serde_with::serde_as]
1300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1301pub struct Snapshot {
1302 /// Optional. The snapshot is guaranteed to exist up until this time. A newly-created snapshot expires no later than 7 days from the time of its creation. Its exact lifetime is determined at creation by the existing backlog in the source subscription. Specifically, the lifetime of the snapshot is `7 days - (age of oldest unacked message in the subscription)`. For example, consider a subscription whose oldest unacked message is 3 days old. If a snapshot is created from this subscription, the snapshot -- which will always capture this 3-day-old backlog as long as the snapshot exists -- will expire in 4 days. The service will refuse to create a snapshot that would expire in less than 1 hour after creation.
1303 #[serde(rename = "expireTime")]
1304 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1305 /// Optional. See [Creating and managing labels] (https://cloud.google.com/pubsub/docs/labels).
1306 pub labels: Option<HashMap<String, String>>,
1307 /// Optional. The name of the snapshot.
1308 pub name: Option<String>,
1309 /// Optional. The name of the topic from which this snapshot is retaining messages.
1310 pub topic: Option<String>,
1311}
1312
1313impl common::ResponseResult for Snapshot {}
1314
1315/// A subscription resource. If none of `push_config`, `bigquery_config`, or `cloud_storage_config` is set, then the subscriber will pull and ack messages using API methods. At most one of these fields may be set.
1316///
1317/// # Activities
1318///
1319/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1320/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1321///
1322/// * [subscriptions create projects](ProjectSubscriptionCreateCall) (request|response)
1323/// * [subscriptions get projects](ProjectSubscriptionGetCall) (response)
1324/// * [subscriptions patch projects](ProjectSubscriptionPatchCall) (response)
1325#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1326#[serde_with::serde_as]
1327#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1328pub struct Subscription {
1329 /// Optional. The approximate amount of time (on a best-effort basis) Pub/Sub waits for the subscriber to acknowledge receipt before resending the message. In the interval after the message is delivered and before it is acknowledged, it is considered to be _outstanding_. During that time period, the message will not be redelivered (on a best-effort basis). For pull subscriptions, this value is used as the initial value for the ack deadline. To override this value for a given message, call `ModifyAckDeadline` with the corresponding `ack_id` if using non-streaming pull or send the `ack_id` in a `StreamingModifyAckDeadlineRequest` if using streaming pull. The minimum custom deadline you can specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds (10 minutes). If this parameter is 0, a default value of 10 seconds is used. For push delivery, this value is also used to set the request timeout for the call to the push endpoint. If the subscriber never acknowledges the message, the Pub/Sub system will eventually redeliver the message.
1330 #[serde(rename = "ackDeadlineSeconds")]
1331 pub ack_deadline_seconds: Option<i32>,
1332 /// Output only. Information about the associated Analytics Hub subscription. Only set if the subscritpion is created by Analytics Hub.
1333 #[serde(rename = "analyticsHubSubscriptionInfo")]
1334 pub analytics_hub_subscription_info: Option<AnalyticsHubSubscriptionInfo>,
1335 /// Optional. If delivery to BigQuery is used with this subscription, this field is used to configure it.
1336 #[serde(rename = "bigqueryConfig")]
1337 pub bigquery_config: Option<BigQueryConfig>,
1338 /// Optional. If delivery to Google Cloud Storage is used with this subscription, this field is used to configure it.
1339 #[serde(rename = "cloudStorageConfig")]
1340 pub cloud_storage_config: Option<CloudStorageConfig>,
1341 /// Optional. A policy that specifies the conditions for dead lettering messages in this subscription. If dead_letter_policy is not set, dead lettering is disabled. The Pub/Sub service account associated with this subscriptions's parent project (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have permission to Acknowledge() messages on this subscription.
1342 #[serde(rename = "deadLetterPolicy")]
1343 pub dead_letter_policy: Option<DeadLetterPolicy>,
1344 /// Optional. Indicates whether the subscription is detached from its topic. Detached subscriptions don't receive messages from their topic and don't retain any backlog. `Pull` and `StreamingPull` requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will not be made.
1345 pub detached: Option<bool>,
1346 /// Optional. If true, Pub/Sub provides the following guarantees for the delivery of a message with a given value of `message_id` on this subscription: * The message sent to a subscriber is guaranteed not to be resent before the message's acknowledgment deadline expires. * An acknowledged message will not be resent to a subscriber. Note that subscribers may still receive multiple copies of a message when `enable_exactly_once_delivery` is true if the message was published multiple times by a publisher client. These copies are considered distinct by Pub/Sub and have distinct `message_id` values.
1347 #[serde(rename = "enableExactlyOnceDelivery")]
1348 pub enable_exactly_once_delivery: Option<bool>,
1349 /// Optional. If true, messages published with the same `ordering_key` in `PubsubMessage` will be delivered to the subscribers in the order in which they are received by the Pub/Sub system. Otherwise, they may be delivered in any order.
1350 #[serde(rename = "enableMessageOrdering")]
1351 pub enable_message_ordering: Option<bool>,
1352 /// Optional. A policy that specifies the conditions for this subscription's expiration. A subscription is considered active as long as any connected subscriber is successfully consuming messages from the subscription or is issuing operations on the subscription. If `expiration_policy` is not set, a *default policy* with `ttl` of 31 days will be used. The minimum allowed value for `expiration_policy.ttl` is 1 day. If `expiration_policy` is set, but `expiration_policy.ttl` is not set, the subscription never expires.
1353 #[serde(rename = "expirationPolicy")]
1354 pub expiration_policy: Option<ExpirationPolicy>,
1355 /// Optional. An expression written in the Pub/Sub [filter language](https://cloud.google.com/pubsub/docs/filtering). If non-empty, then only `PubsubMessage`s whose `attributes` field matches the filter are delivered on this subscription. If empty, then no messages are filtered out.
1356 pub filter: Option<String>,
1357 /// Optional. See [Creating and managing labels](https://cloud.google.com/pubsub/docs/labels).
1358 pub labels: Option<HashMap<String, String>>,
1359 /// Optional. How long to retain unacknowledged messages in the subscription's backlog, from the moment a message is published. If `retain_acked_messages` is true, then this also configures the retention of acknowledged messages, and thus configures how far back in time a `Seek` can be done. Defaults to 7 days. Cannot be more than 31 days or less than 10 minutes.
1360 #[serde(rename = "messageRetentionDuration")]
1361 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1362 pub message_retention_duration: Option<chrono::Duration>,
1363 /// Optional. Transforms to be applied to messages before they are delivered to subscribers. Transforms are applied in the order specified.
1364 #[serde(rename = "messageTransforms")]
1365 pub message_transforms: Option<Vec<MessageTransform>>,
1366 /// Required. Identifier. The name of the subscription. It must have the format `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
1367 pub name: Option<String>,
1368 /// Optional. If push delivery is used with this subscription, this field is used to configure it.
1369 #[serde(rename = "pushConfig")]
1370 pub push_config: Option<PushConfig>,
1371 /// Optional. Indicates whether to retain acknowledged messages. If true, then messages are not expunged from the subscription's backlog, even if they are acknowledged, until they fall out of the `message_retention_duration` window. This must be true if you would like to [`Seek` to a timestamp] (https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) in the past to replay previously-acknowledged messages.
1372 #[serde(rename = "retainAckedMessages")]
1373 pub retain_acked_messages: Option<bool>,
1374 /// Optional. A policy that specifies how Pub/Sub retries message delivery for this subscription. If not set, the default retry policy is applied. This generally implies that messages will be retried as soon as possible for healthy subscribers. RetryPolicy will be triggered on NACKs or acknowledgment deadline exceeded events for a given message.
1375 #[serde(rename = "retryPolicy")]
1376 pub retry_policy: Option<RetryPolicy>,
1377 /// Output only. An output-only field indicating whether or not the subscription can receive messages.
1378 pub state: Option<String>,
1379 /// Optional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing"
1380 pub tags: Option<HashMap<String, String>>,
1381 /// Required. Identifier. The name of the topic from which this subscription is receiving messages. Format is `projects/{project}/topics/{topic}`. The value of this field will be `_deleted-topic_` if the topic has been deleted.
1382 pub topic: Option<String>,
1383 /// Output only. Indicates the minimum duration for which a message is retained after it is published to the subscription's topic. If this field is set, messages published to the subscription's topic in the last `topic_message_retention_duration` are always available to subscribers. See the `message_retention_duration` field in `Topic`. This field is set only in responses from the server; it is ignored if it is set in any requests.
1384 #[serde(rename = "topicMessageRetentionDuration")]
1385 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1386 pub topic_message_retention_duration: Option<chrono::Duration>,
1387}
1388
1389impl common::RequestValue for Subscription {}
1390impl common::ResponseResult for Subscription {}
1391
1392/// Request message for `TestIamPermissions` method.
1393///
1394/// # Activities
1395///
1396/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1397/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1398///
1399/// * [schemas test iam permissions projects](ProjectSchemaTestIamPermissionCall) (request)
1400/// * [snapshots test iam permissions projects](ProjectSnapshotTestIamPermissionCall) (request)
1401/// * [subscriptions test iam permissions projects](ProjectSubscriptionTestIamPermissionCall) (request)
1402/// * [topics test iam permissions projects](ProjectTopicTestIamPermissionCall) (request)
1403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1404#[serde_with::serde_as]
1405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1406pub struct TestIamPermissionsRequest {
1407 /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1408 pub permissions: Option<Vec<String>>,
1409}
1410
1411impl common::RequestValue for TestIamPermissionsRequest {}
1412
1413/// Response message for `TestIamPermissions` method.
1414///
1415/// # Activities
1416///
1417/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1418/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1419///
1420/// * [schemas test iam permissions projects](ProjectSchemaTestIamPermissionCall) (response)
1421/// * [snapshots test iam permissions projects](ProjectSnapshotTestIamPermissionCall) (response)
1422/// * [subscriptions test iam permissions projects](ProjectSubscriptionTestIamPermissionCall) (response)
1423/// * [topics test iam permissions projects](ProjectTopicTestIamPermissionCall) (response)
1424#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1425#[serde_with::serde_as]
1426#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1427pub struct TestIamPermissionsResponse {
1428 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1429 pub permissions: Option<Vec<String>>,
1430}
1431
1432impl common::ResponseResult for TestIamPermissionsResponse {}
1433
1434/// Configuration for writing message data in text format. Message payloads will be written to files as raw text, separated by a newline.
1435///
1436/// This type is not used in any activity, and only used as *part* of another schema.
1437///
1438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1439#[serde_with::serde_as]
1440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1441pub struct TextConfig {
1442 _never_set: Option<bool>,
1443}
1444
1445impl common::Part for TextConfig {}
1446
1447/// Configuration for reading Cloud Storage data in text format. Each line of text as specified by the delimiter will be set to the `data` field of a Pub/Sub message.
1448///
1449/// This type is not used in any activity, and only used as *part* of another schema.
1450///
1451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1452#[serde_with::serde_as]
1453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1454pub struct TextFormat {
1455 /// Optional. When unset, '\n' is used.
1456 pub delimiter: Option<String>,
1457}
1458
1459impl common::Part for TextFormat {}
1460
1461/// A topic resource.
1462///
1463/// # Activities
1464///
1465/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1466/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1467///
1468/// * [topics create projects](ProjectTopicCreateCall) (request|response)
1469/// * [topics get projects](ProjectTopicGetCall) (response)
1470/// * [topics patch projects](ProjectTopicPatchCall) (response)
1471#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1472#[serde_with::serde_as]
1473#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1474pub struct Topic {
1475 /// Optional. Settings for ingestion from a data source into this topic.
1476 #[serde(rename = "ingestionDataSourceSettings")]
1477 pub ingestion_data_source_settings: Option<IngestionDataSourceSettings>,
1478 /// Optional. The resource name of the Cloud KMS CryptoKey to be used to protect access to messages published on this topic. The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
1479 #[serde(rename = "kmsKeyName")]
1480 pub kms_key_name: Option<String>,
1481 /// Optional. See [Creating and managing labels] (https://cloud.google.com/pubsub/docs/labels).
1482 pub labels: Option<HashMap<String, String>>,
1483 /// Optional. Indicates the minimum duration to retain a message after it is published to the topic. If this field is set, messages published to the topic in the last `message_retention_duration` are always available to subscribers. For instance, it allows any attached subscription to [seek to a timestamp](https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) that is up to `message_retention_duration` in the past. If this field is not set, message retention is controlled by settings on individual subscriptions. Cannot be more than 31 days or less than 10 minutes.
1484 #[serde(rename = "messageRetentionDuration")]
1485 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1486 pub message_retention_duration: Option<chrono::Duration>,
1487 /// Optional. Policy constraining the set of Google Cloud Platform regions where messages published to the topic may be stored. If not present, then no constraints are in effect.
1488 #[serde(rename = "messageStoragePolicy")]
1489 pub message_storage_policy: Option<MessageStoragePolicy>,
1490 /// Optional. Transforms to be applied to messages published to the topic. Transforms are applied in the order specified.
1491 #[serde(rename = "messageTransforms")]
1492 pub message_transforms: Option<Vec<MessageTransform>>,
1493 /// Required. Identifier. The name of the topic. It must have the format `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
1494 pub name: Option<String>,
1495 /// Optional. Reserved for future use. This field is set only in responses from the server; it is ignored if it is set in any requests.
1496 #[serde(rename = "satisfiesPzs")]
1497 pub satisfies_pzs: Option<bool>,
1498 /// Optional. Settings for validating messages published against a schema.
1499 #[serde(rename = "schemaSettings")]
1500 pub schema_settings: Option<SchemaSettings>,
1501 /// Output only. An output-only field indicating the state of the topic.
1502 pub state: Option<String>,
1503 /// Optional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing"
1504 pub tags: Option<HashMap<String, String>>,
1505}
1506
1507impl common::RequestValue for Topic {}
1508impl common::ResponseResult for Topic {}
1509
1510/// Request for the UpdateSnapshot method.
1511///
1512/// # Activities
1513///
1514/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1515/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1516///
1517/// * [snapshots patch projects](ProjectSnapshotPatchCall) (request)
1518#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1519#[serde_with::serde_as]
1520#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1521pub struct UpdateSnapshotRequest {
1522 /// Required. The updated snapshot object.
1523 pub snapshot: Option<Snapshot>,
1524 /// Required. Indicates which fields in the provided snapshot to update. Must be specified and non-empty.
1525 #[serde(rename = "updateMask")]
1526 pub update_mask: Option<common::FieldMask>,
1527}
1528
1529impl common::RequestValue for UpdateSnapshotRequest {}
1530
1531/// Request for the UpdateSubscription method.
1532///
1533/// # Activities
1534///
1535/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1536/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1537///
1538/// * [subscriptions patch projects](ProjectSubscriptionPatchCall) (request)
1539#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1540#[serde_with::serde_as]
1541#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1542pub struct UpdateSubscriptionRequest {
1543 /// Required. The updated subscription object.
1544 pub subscription: Option<Subscription>,
1545 /// Required. Indicates which fields in the provided subscription to update. Must be specified and non-empty.
1546 #[serde(rename = "updateMask")]
1547 pub update_mask: Option<common::FieldMask>,
1548}
1549
1550impl common::RequestValue for UpdateSubscriptionRequest {}
1551
1552/// Request for the UpdateTopic method.
1553///
1554/// # Activities
1555///
1556/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1557/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1558///
1559/// * [topics patch projects](ProjectTopicPatchCall) (request)
1560#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1561#[serde_with::serde_as]
1562#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1563pub struct UpdateTopicRequest {
1564 /// Required. The updated topic object.
1565 pub topic: Option<Topic>,
1566 /// Required. Indicates which fields in the provided topic to update. Must be specified and non-empty. Note that if `update_mask` contains "message_storage_policy" but the `message_storage_policy` is not set in the `topic` provided above, then the updated value is determined by the policy configured at the project or organization level.
1567 #[serde(rename = "updateMask")]
1568 pub update_mask: Option<common::FieldMask>,
1569}
1570
1571impl common::RequestValue for UpdateTopicRequest {}
1572
1573/// Request for the `ValidateMessage` method.
1574///
1575/// # Activities
1576///
1577/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1578/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1579///
1580/// * [schemas validate message projects](ProjectSchemaValidateMessageCall) (request)
1581#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1582#[serde_with::serde_as]
1583#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1584pub struct ValidateMessageRequest {
1585 /// The encoding expected for messages
1586 pub encoding: Option<String>,
1587 /// Message to validate against the provided `schema_spec`.
1588 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1589 pub message: Option<Vec<u8>>,
1590 /// Name of the schema against which to validate. Format is `projects/{project}/schemas/{schema}`.
1591 pub name: Option<String>,
1592 /// Ad-hoc schema against which to validate
1593 pub schema: Option<Schema>,
1594}
1595
1596impl common::RequestValue for ValidateMessageRequest {}
1597
1598/// Response for the `ValidateMessage` method. Empty for now.
1599///
1600/// # Activities
1601///
1602/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1603/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1604///
1605/// * [schemas validate message projects](ProjectSchemaValidateMessageCall) (response)
1606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1607#[serde_with::serde_as]
1608#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1609pub struct ValidateMessageResponse {
1610 _never_set: Option<bool>,
1611}
1612
1613impl common::ResponseResult for ValidateMessageResponse {}
1614
1615/// Request for the `ValidateSchema` method.
1616///
1617/// # Activities
1618///
1619/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1620/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1621///
1622/// * [schemas validate projects](ProjectSchemaValidateCall) (request)
1623#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1624#[serde_with::serde_as]
1625#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1626pub struct ValidateSchemaRequest {
1627 /// Required. The schema object to validate.
1628 pub schema: Option<Schema>,
1629}
1630
1631impl common::RequestValue for ValidateSchemaRequest {}
1632
1633/// Response for the `ValidateSchema` method. Empty for now.
1634///
1635/// # Activities
1636///
1637/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1638/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1639///
1640/// * [schemas validate projects](ProjectSchemaValidateCall) (response)
1641#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1642#[serde_with::serde_as]
1643#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1644pub struct ValidateSchemaResponse {
1645 _never_set: Option<bool>,
1646}
1647
1648impl common::ResponseResult for ValidateSchemaResponse {}
1649
1650// ###################
1651// MethodBuilders ###
1652// #################
1653
1654/// A builder providing access to all methods supported on *project* resources.
1655/// It is not used directly, but through the [`Pubsub`] hub.
1656///
1657/// # Example
1658///
1659/// Instantiate a resource builder
1660///
1661/// ```test_harness,no_run
1662/// extern crate hyper;
1663/// extern crate hyper_rustls;
1664/// extern crate google_pubsub1 as pubsub1;
1665///
1666/// # async fn dox() {
1667/// use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1668///
1669/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1670/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1671/// .with_native_roots()
1672/// .unwrap()
1673/// .https_only()
1674/// .enable_http2()
1675/// .build();
1676///
1677/// let executor = hyper_util::rt::TokioExecutor::new();
1678/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1679/// secret,
1680/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1681/// yup_oauth2::client::CustomHyperClientBuilder::from(
1682/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1683/// ),
1684/// ).build().await.unwrap();
1685///
1686/// let client = hyper_util::client::legacy::Client::builder(
1687/// hyper_util::rt::TokioExecutor::new()
1688/// )
1689/// .build(
1690/// hyper_rustls::HttpsConnectorBuilder::new()
1691/// .with_native_roots()
1692/// .unwrap()
1693/// .https_or_http()
1694/// .enable_http2()
1695/// .build()
1696/// );
1697/// let mut hub = Pubsub::new(client, auth);
1698/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1699/// // like `schemas_commit(...)`, `schemas_create(...)`, `schemas_delete(...)`, `schemas_delete_revision(...)`, `schemas_get(...)`, `schemas_get_iam_policy(...)`, `schemas_list(...)`, `schemas_list_revisions(...)`, `schemas_rollback(...)`, `schemas_set_iam_policy(...)`, `schemas_test_iam_permissions(...)`, `schemas_validate(...)`, `schemas_validate_message(...)`, `snapshots_create(...)`, `snapshots_delete(...)`, `snapshots_get(...)`, `snapshots_get_iam_policy(...)`, `snapshots_list(...)`, `snapshots_patch(...)`, `snapshots_set_iam_policy(...)`, `snapshots_test_iam_permissions(...)`, `subscriptions_acknowledge(...)`, `subscriptions_create(...)`, `subscriptions_delete(...)`, `subscriptions_detach(...)`, `subscriptions_get(...)`, `subscriptions_get_iam_policy(...)`, `subscriptions_list(...)`, `subscriptions_modify_ack_deadline(...)`, `subscriptions_modify_push_config(...)`, `subscriptions_patch(...)`, `subscriptions_pull(...)`, `subscriptions_seek(...)`, `subscriptions_set_iam_policy(...)`, `subscriptions_test_iam_permissions(...)`, `topics_create(...)`, `topics_delete(...)`, `topics_get(...)`, `topics_get_iam_policy(...)`, `topics_list(...)`, `topics_patch(...)`, `topics_publish(...)`, `topics_set_iam_policy(...)`, `topics_snapshots_list(...)`, `topics_subscriptions_list(...)` and `topics_test_iam_permissions(...)`
1700/// // to build up your call.
1701/// let rb = hub.projects();
1702/// # }
1703/// ```
1704pub struct ProjectMethods<'a, C>
1705where
1706 C: 'a,
1707{
1708 hub: &'a Pubsub<C>,
1709}
1710
1711impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1712
1713impl<'a, C> ProjectMethods<'a, C> {
1714 /// Create a builder to help you perform the following task:
1715 ///
1716 /// Commits a new schema revision to an existing schema.
1717 ///
1718 /// # Arguments
1719 ///
1720 /// * `request` - No description provided.
1721 /// * `name` - Required. The name of the schema we are revising. Format is `projects/{project}/schemas/{schema}`.
1722 pub fn schemas_commit(
1723 &self,
1724 request: CommitSchemaRequest,
1725 name: &str,
1726 ) -> ProjectSchemaCommitCall<'a, C> {
1727 ProjectSchemaCommitCall {
1728 hub: self.hub,
1729 _request: request,
1730 _name: name.to_string(),
1731 _delegate: Default::default(),
1732 _additional_params: Default::default(),
1733 _scopes: Default::default(),
1734 }
1735 }
1736
1737 /// Create a builder to help you perform the following task:
1738 ///
1739 /// Creates a schema.
1740 ///
1741 /// # Arguments
1742 ///
1743 /// * `request` - No description provided.
1744 /// * `parent` - Required. The name of the project in which to create the schema. Format is `projects/{project-id}`.
1745 pub fn schemas_create(&self, request: Schema, parent: &str) -> ProjectSchemaCreateCall<'a, C> {
1746 ProjectSchemaCreateCall {
1747 hub: self.hub,
1748 _request: request,
1749 _parent: parent.to_string(),
1750 _schema_id: Default::default(),
1751 _delegate: Default::default(),
1752 _additional_params: Default::default(),
1753 _scopes: Default::default(),
1754 }
1755 }
1756
1757 /// Create a builder to help you perform the following task:
1758 ///
1759 /// Deletes a schema.
1760 ///
1761 /// # Arguments
1762 ///
1763 /// * `name` - Required. Name of the schema to delete. Format is `projects/{project}/schemas/{schema}`.
1764 pub fn schemas_delete(&self, name: &str) -> ProjectSchemaDeleteCall<'a, C> {
1765 ProjectSchemaDeleteCall {
1766 hub: self.hub,
1767 _name: name.to_string(),
1768 _delegate: Default::default(),
1769 _additional_params: Default::default(),
1770 _scopes: Default::default(),
1771 }
1772 }
1773
1774 /// Create a builder to help you perform the following task:
1775 ///
1776 /// Deletes a specific schema revision.
1777 ///
1778 /// # Arguments
1779 ///
1780 /// * `name` - Required. The name of the schema revision to be deleted, with a revision ID explicitly included. Example: `projects/123/schemas/my-schema@c7cfa2a8`
1781 pub fn schemas_delete_revision(&self, name: &str) -> ProjectSchemaDeleteRevisionCall<'a, C> {
1782 ProjectSchemaDeleteRevisionCall {
1783 hub: self.hub,
1784 _name: name.to_string(),
1785 _revision_id: Default::default(),
1786 _delegate: Default::default(),
1787 _additional_params: Default::default(),
1788 _scopes: Default::default(),
1789 }
1790 }
1791
1792 /// Create a builder to help you perform the following task:
1793 ///
1794 /// Gets a schema.
1795 ///
1796 /// # Arguments
1797 ///
1798 /// * `name` - Required. The name of the schema to get. Format is `projects/{project}/schemas/{schema}`.
1799 pub fn schemas_get(&self, name: &str) -> ProjectSchemaGetCall<'a, C> {
1800 ProjectSchemaGetCall {
1801 hub: self.hub,
1802 _name: name.to_string(),
1803 _view: Default::default(),
1804 _delegate: Default::default(),
1805 _additional_params: Default::default(),
1806 _scopes: Default::default(),
1807 }
1808 }
1809
1810 /// Create a builder to help you perform the following task:
1811 ///
1812 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1813 ///
1814 /// # Arguments
1815 ///
1816 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1817 pub fn schemas_get_iam_policy(&self, resource: &str) -> ProjectSchemaGetIamPolicyCall<'a, C> {
1818 ProjectSchemaGetIamPolicyCall {
1819 hub: self.hub,
1820 _resource: resource.to_string(),
1821 _options_requested_policy_version: Default::default(),
1822 _delegate: Default::default(),
1823 _additional_params: Default::default(),
1824 _scopes: Default::default(),
1825 }
1826 }
1827
1828 /// Create a builder to help you perform the following task:
1829 ///
1830 /// Lists schemas in a project.
1831 ///
1832 /// # Arguments
1833 ///
1834 /// * `parent` - Required. The name of the project in which to list schemas. Format is `projects/{project-id}`.
1835 pub fn schemas_list(&self, parent: &str) -> ProjectSchemaListCall<'a, C> {
1836 ProjectSchemaListCall {
1837 hub: self.hub,
1838 _parent: parent.to_string(),
1839 _view: Default::default(),
1840 _page_token: Default::default(),
1841 _page_size: Default::default(),
1842 _delegate: Default::default(),
1843 _additional_params: Default::default(),
1844 _scopes: Default::default(),
1845 }
1846 }
1847
1848 /// Create a builder to help you perform the following task:
1849 ///
1850 /// Lists all schema revisions for the named schema.
1851 ///
1852 /// # Arguments
1853 ///
1854 /// * `name` - Required. The name of the schema to list revisions for.
1855 pub fn schemas_list_revisions(&self, name: &str) -> ProjectSchemaListRevisionCall<'a, C> {
1856 ProjectSchemaListRevisionCall {
1857 hub: self.hub,
1858 _name: name.to_string(),
1859 _view: Default::default(),
1860 _page_token: Default::default(),
1861 _page_size: Default::default(),
1862 _delegate: Default::default(),
1863 _additional_params: Default::default(),
1864 _scopes: Default::default(),
1865 }
1866 }
1867
1868 /// Create a builder to help you perform the following task:
1869 ///
1870 /// Creates a new schema revision that is a copy of the provided revision_id.
1871 ///
1872 /// # Arguments
1873 ///
1874 /// * `request` - No description provided.
1875 /// * `name` - Required. The schema being rolled back with revision id.
1876 pub fn schemas_rollback(
1877 &self,
1878 request: RollbackSchemaRequest,
1879 name: &str,
1880 ) -> ProjectSchemaRollbackCall<'a, C> {
1881 ProjectSchemaRollbackCall {
1882 hub: self.hub,
1883 _request: request,
1884 _name: name.to_string(),
1885 _delegate: Default::default(),
1886 _additional_params: Default::default(),
1887 _scopes: Default::default(),
1888 }
1889 }
1890
1891 /// Create a builder to help you perform the following task:
1892 ///
1893 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
1894 ///
1895 /// # Arguments
1896 ///
1897 /// * `request` - No description provided.
1898 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1899 pub fn schemas_set_iam_policy(
1900 &self,
1901 request: SetIamPolicyRequest,
1902 resource: &str,
1903 ) -> ProjectSchemaSetIamPolicyCall<'a, C> {
1904 ProjectSchemaSetIamPolicyCall {
1905 hub: self.hub,
1906 _request: request,
1907 _resource: resource.to_string(),
1908 _delegate: Default::default(),
1909 _additional_params: Default::default(),
1910 _scopes: Default::default(),
1911 }
1912 }
1913
1914 /// Create a builder to help you perform the following task:
1915 ///
1916 /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
1917 ///
1918 /// # Arguments
1919 ///
1920 /// * `request` - No description provided.
1921 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1922 pub fn schemas_test_iam_permissions(
1923 &self,
1924 request: TestIamPermissionsRequest,
1925 resource: &str,
1926 ) -> ProjectSchemaTestIamPermissionCall<'a, C> {
1927 ProjectSchemaTestIamPermissionCall {
1928 hub: self.hub,
1929 _request: request,
1930 _resource: resource.to_string(),
1931 _delegate: Default::default(),
1932 _additional_params: Default::default(),
1933 _scopes: Default::default(),
1934 }
1935 }
1936
1937 /// Create a builder to help you perform the following task:
1938 ///
1939 /// Validates a schema.
1940 ///
1941 /// # Arguments
1942 ///
1943 /// * `request` - No description provided.
1944 /// * `parent` - Required. The name of the project in which to validate schemas. Format is `projects/{project-id}`.
1945 pub fn schemas_validate(
1946 &self,
1947 request: ValidateSchemaRequest,
1948 parent: &str,
1949 ) -> ProjectSchemaValidateCall<'a, C> {
1950 ProjectSchemaValidateCall {
1951 hub: self.hub,
1952 _request: request,
1953 _parent: parent.to_string(),
1954 _delegate: Default::default(),
1955 _additional_params: Default::default(),
1956 _scopes: Default::default(),
1957 }
1958 }
1959
1960 /// Create a builder to help you perform the following task:
1961 ///
1962 /// Validates a message against a schema.
1963 ///
1964 /// # Arguments
1965 ///
1966 /// * `request` - No description provided.
1967 /// * `parent` - Required. The name of the project in which to validate schemas. Format is `projects/{project-id}`.
1968 pub fn schemas_validate_message(
1969 &self,
1970 request: ValidateMessageRequest,
1971 parent: &str,
1972 ) -> ProjectSchemaValidateMessageCall<'a, C> {
1973 ProjectSchemaValidateMessageCall {
1974 hub: self.hub,
1975 _request: request,
1976 _parent: parent.to_string(),
1977 _delegate: Default::default(),
1978 _additional_params: Default::default(),
1979 _scopes: Default::default(),
1980 }
1981 }
1982
1983 /// Create a builder to help you perform the following task:
1984 ///
1985 /// Creates a snapshot from the requested subscription. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. If the snapshot already exists, returns `ALREADY_EXISTS`. If the requested subscription doesn't exist, returns `NOT_FOUND`. If the backlog in the subscription is too old -- and the resulting snapshot would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned. See also the `Snapshot.expire_time` field. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription, conforming to the [resource name format] (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). The generated name is populated in the returned Snapshot object. Note that for REST API requests, you must specify a name in the request.
1986 ///
1987 /// # Arguments
1988 ///
1989 /// * `request` - No description provided.
1990 /// * `name` - Required. Identifier. User-provided name for this snapshot. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription. Note that for REST API requests, you must specify a name. See the [resource name rules](https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). Format is `projects/{project}/snapshots/{snap}`.
1991 pub fn snapshots_create(
1992 &self,
1993 request: CreateSnapshotRequest,
1994 name: &str,
1995 ) -> ProjectSnapshotCreateCall<'a, C> {
1996 ProjectSnapshotCreateCall {
1997 hub: self.hub,
1998 _request: request,
1999 _name: name.to_string(),
2000 _delegate: Default::default(),
2001 _additional_params: Default::default(),
2002 _scopes: Default::default(),
2003 }
2004 }
2005
2006 /// Create a builder to help you perform the following task:
2007 ///
2008 /// Removes an existing snapshot. Snapshots are used in [Seek] (https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. When the snapshot is deleted, all messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new one may be created with the same name, but the new one has no association with the old snapshot or its subscription, unless the same subscription is specified.
2009 ///
2010 /// # Arguments
2011 ///
2012 /// * `snapshot` - Required. Identifier. The name of the snapshot to delete. Format is `projects/{project}/snapshots/{snap}`.
2013 pub fn snapshots_delete(&self, snapshot: &str) -> ProjectSnapshotDeleteCall<'a, C> {
2014 ProjectSnapshotDeleteCall {
2015 hub: self.hub,
2016 _snapshot: snapshot.to_string(),
2017 _delegate: Default::default(),
2018 _additional_params: Default::default(),
2019 _scopes: Default::default(),
2020 }
2021 }
2022
2023 /// Create a builder to help you perform the following task:
2024 ///
2025 /// Gets the configuration details of a snapshot. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
2026 ///
2027 /// # Arguments
2028 ///
2029 /// * `snapshot` - Required. Identifier. The name of the snapshot to get. Format is `projects/{project}/snapshots/{snap}`.
2030 pub fn snapshots_get(&self, snapshot: &str) -> ProjectSnapshotGetCall<'a, C> {
2031 ProjectSnapshotGetCall {
2032 hub: self.hub,
2033 _snapshot: snapshot.to_string(),
2034 _delegate: Default::default(),
2035 _additional_params: Default::default(),
2036 _scopes: Default::default(),
2037 }
2038 }
2039
2040 /// Create a builder to help you perform the following task:
2041 ///
2042 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2043 ///
2044 /// # Arguments
2045 ///
2046 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2047 pub fn snapshots_get_iam_policy(
2048 &self,
2049 resource: &str,
2050 ) -> ProjectSnapshotGetIamPolicyCall<'a, C> {
2051 ProjectSnapshotGetIamPolicyCall {
2052 hub: self.hub,
2053 _resource: resource.to_string(),
2054 _options_requested_policy_version: Default::default(),
2055 _delegate: Default::default(),
2056 _additional_params: Default::default(),
2057 _scopes: Default::default(),
2058 }
2059 }
2060
2061 /// Create a builder to help you perform the following task:
2062 ///
2063 /// Lists the existing snapshots. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
2064 ///
2065 /// # Arguments
2066 ///
2067 /// * `project` - Required. Identifier. The name of the project in which to list snapshots. Format is `projects/{project-id}`.
2068 pub fn snapshots_list(&self, project: &str) -> ProjectSnapshotListCall<'a, C> {
2069 ProjectSnapshotListCall {
2070 hub: self.hub,
2071 _project: project.to_string(),
2072 _page_token: Default::default(),
2073 _page_size: Default::default(),
2074 _delegate: Default::default(),
2075 _additional_params: Default::default(),
2076 _scopes: Default::default(),
2077 }
2078 }
2079
2080 /// Create a builder to help you perform the following task:
2081 ///
2082 /// Updates an existing snapshot by updating the fields specified in the update mask. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
2083 ///
2084 /// # Arguments
2085 ///
2086 /// * `request` - No description provided.
2087 /// * `name` - Optional. The name of the snapshot.
2088 pub fn snapshots_patch(
2089 &self,
2090 request: UpdateSnapshotRequest,
2091 name: &str,
2092 ) -> ProjectSnapshotPatchCall<'a, C> {
2093 ProjectSnapshotPatchCall {
2094 hub: self.hub,
2095 _request: request,
2096 _name: name.to_string(),
2097 _delegate: Default::default(),
2098 _additional_params: Default::default(),
2099 _scopes: Default::default(),
2100 }
2101 }
2102
2103 /// Create a builder to help you perform the following task:
2104 ///
2105 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2106 ///
2107 /// # Arguments
2108 ///
2109 /// * `request` - No description provided.
2110 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2111 pub fn snapshots_set_iam_policy(
2112 &self,
2113 request: SetIamPolicyRequest,
2114 resource: &str,
2115 ) -> ProjectSnapshotSetIamPolicyCall<'a, C> {
2116 ProjectSnapshotSetIamPolicyCall {
2117 hub: self.hub,
2118 _request: request,
2119 _resource: resource.to_string(),
2120 _delegate: Default::default(),
2121 _additional_params: Default::default(),
2122 _scopes: Default::default(),
2123 }
2124 }
2125
2126 /// Create a builder to help you perform the following task:
2127 ///
2128 /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
2129 ///
2130 /// # Arguments
2131 ///
2132 /// * `request` - No description provided.
2133 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2134 pub fn snapshots_test_iam_permissions(
2135 &self,
2136 request: TestIamPermissionsRequest,
2137 resource: &str,
2138 ) -> ProjectSnapshotTestIamPermissionCall<'a, C> {
2139 ProjectSnapshotTestIamPermissionCall {
2140 hub: self.hub,
2141 _request: request,
2142 _resource: resource.to_string(),
2143 _delegate: Default::default(),
2144 _additional_params: Default::default(),
2145 _scopes: Default::default(),
2146 }
2147 }
2148
2149 /// Create a builder to help you perform the following task:
2150 ///
2151 /// Acknowledges the messages associated with the `ack_ids` in the `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages from the subscription. Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.
2152 ///
2153 /// # Arguments
2154 ///
2155 /// * `request` - No description provided.
2156 /// * `subscription` - Required. The subscription whose message is being acknowledged. Format is `projects/{project}/subscriptions/{sub}`.
2157 pub fn subscriptions_acknowledge(
2158 &self,
2159 request: AcknowledgeRequest,
2160 subscription: &str,
2161 ) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
2162 ProjectSubscriptionAcknowledgeCall {
2163 hub: self.hub,
2164 _request: request,
2165 _subscription: subscription.to_string(),
2166 _delegate: Default::default(),
2167 _additional_params: Default::default(),
2168 _scopes: Default::default(),
2169 }
2170 }
2171
2172 /// Create a builder to help you perform the following task:
2173 ///
2174 /// Creates a subscription to a given topic. See the [resource name rules] (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). If the subscription already exists, returns `ALREADY_EXISTS`. If the corresponding topic doesn't exist, returns `NOT_FOUND`. If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic, conforming to the [resource name format] (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). The generated name is populated in the returned Subscription object. Note that for REST API requests, you must specify a name in the request.
2175 ///
2176 /// # Arguments
2177 ///
2178 /// * `request` - No description provided.
2179 /// * `name` - Required. Identifier. The name of the subscription. It must have the format `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
2180 pub fn subscriptions_create(
2181 &self,
2182 request: Subscription,
2183 name: &str,
2184 ) -> ProjectSubscriptionCreateCall<'a, C> {
2185 ProjectSubscriptionCreateCall {
2186 hub: self.hub,
2187 _request: request,
2188 _name: name.to_string(),
2189 _delegate: Default::default(),
2190 _additional_params: Default::default(),
2191 _scopes: Default::default(),
2192 }
2193 }
2194
2195 /// Create a builder to help you perform the following task:
2196 ///
2197 /// Deletes an existing subscription. All messages retained in the subscription are immediately dropped. Calls to `Pull` after deletion will return `NOT_FOUND`. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription or its topic unless the same topic is specified.
2198 ///
2199 /// # Arguments
2200 ///
2201 /// * `subscription` - Required. Identifier. The subscription to delete. Format is `projects/{project}/subscriptions/{sub}`.
2202 pub fn subscriptions_delete(&self, subscription: &str) -> ProjectSubscriptionDeleteCall<'a, C> {
2203 ProjectSubscriptionDeleteCall {
2204 hub: self.hub,
2205 _subscription: subscription.to_string(),
2206 _delegate: Default::default(),
2207 _additional_params: Default::default(),
2208 _scopes: Default::default(),
2209 }
2210 }
2211
2212 /// Create a builder to help you perform the following task:
2213 ///
2214 /// Detaches a subscription from this topic. All messages retained in the subscription are dropped. Subsequent `Pull` and `StreamingPull` requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will stop.
2215 ///
2216 /// # Arguments
2217 ///
2218 /// * `subscription` - Required. The subscription to detach. Format is `projects/{project}/subscriptions/{subscription}`.
2219 pub fn subscriptions_detach(&self, subscription: &str) -> ProjectSubscriptionDetachCall<'a, C> {
2220 ProjectSubscriptionDetachCall {
2221 hub: self.hub,
2222 _subscription: subscription.to_string(),
2223 _delegate: Default::default(),
2224 _additional_params: Default::default(),
2225 _scopes: Default::default(),
2226 }
2227 }
2228
2229 /// Create a builder to help you perform the following task:
2230 ///
2231 /// Gets the configuration details of a subscription.
2232 ///
2233 /// # Arguments
2234 ///
2235 /// * `subscription` - Required. Identifier. The name of the subscription to get. Format is `projects/{project}/subscriptions/{sub}`.
2236 pub fn subscriptions_get(&self, subscription: &str) -> ProjectSubscriptionGetCall<'a, C> {
2237 ProjectSubscriptionGetCall {
2238 hub: self.hub,
2239 _subscription: subscription.to_string(),
2240 _delegate: Default::default(),
2241 _additional_params: Default::default(),
2242 _scopes: Default::default(),
2243 }
2244 }
2245
2246 /// Create a builder to help you perform the following task:
2247 ///
2248 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2249 ///
2250 /// # Arguments
2251 ///
2252 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2253 pub fn subscriptions_get_iam_policy(
2254 &self,
2255 resource: &str,
2256 ) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
2257 ProjectSubscriptionGetIamPolicyCall {
2258 hub: self.hub,
2259 _resource: resource.to_string(),
2260 _options_requested_policy_version: Default::default(),
2261 _delegate: Default::default(),
2262 _additional_params: Default::default(),
2263 _scopes: Default::default(),
2264 }
2265 }
2266
2267 /// Create a builder to help you perform the following task:
2268 ///
2269 /// Lists matching subscriptions.
2270 ///
2271 /// # Arguments
2272 ///
2273 /// * `project` - Required. Identifier. The name of the project in which to list subscriptions. Format is `projects/{project-id}`.
2274 pub fn subscriptions_list(&self, project: &str) -> ProjectSubscriptionListCall<'a, C> {
2275 ProjectSubscriptionListCall {
2276 hub: self.hub,
2277 _project: project.to_string(),
2278 _page_token: Default::default(),
2279 _page_size: Default::default(),
2280 _delegate: Default::default(),
2281 _additional_params: Default::default(),
2282 _scopes: Default::default(),
2283 }
2284 }
2285
2286 /// Create a builder to help you perform the following task:
2287 ///
2288 /// Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted. Note that this does not modify the subscription-level `ackDeadlineSeconds` used for subsequent messages.
2289 ///
2290 /// # Arguments
2291 ///
2292 /// * `request` - No description provided.
2293 /// * `subscription` - Required. The name of the subscription. Format is `projects/{project}/subscriptions/{sub}`.
2294 pub fn subscriptions_modify_ack_deadline(
2295 &self,
2296 request: ModifyAckDeadlineRequest,
2297 subscription: &str,
2298 ) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
2299 ProjectSubscriptionModifyAckDeadlineCall {
2300 hub: self.hub,
2301 _request: request,
2302 _subscription: subscription.to_string(),
2303 _delegate: Default::default(),
2304 _additional_params: Default::default(),
2305 _scopes: Default::default(),
2306 }
2307 }
2308
2309 /// Create a builder to help you perform the following task:
2310 ///
2311 /// Modifies the `PushConfig` for a specified subscription. This may be used to change a push subscription to a pull one (signified by an empty `PushConfig`) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the `PushConfig`.
2312 ///
2313 /// # Arguments
2314 ///
2315 /// * `request` - No description provided.
2316 /// * `subscription` - Required. The name of the subscription. Format is `projects/{project}/subscriptions/{sub}`.
2317 pub fn subscriptions_modify_push_config(
2318 &self,
2319 request: ModifyPushConfigRequest,
2320 subscription: &str,
2321 ) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
2322 ProjectSubscriptionModifyPushConfigCall {
2323 hub: self.hub,
2324 _request: request,
2325 _subscription: subscription.to_string(),
2326 _delegate: Default::default(),
2327 _additional_params: Default::default(),
2328 _scopes: Default::default(),
2329 }
2330 }
2331
2332 /// Create a builder to help you perform the following task:
2333 ///
2334 /// Updates an existing subscription by updating the fields specified in the update mask. Note that certain properties of a subscription, such as its topic, are not modifiable.
2335 ///
2336 /// # Arguments
2337 ///
2338 /// * `request` - No description provided.
2339 /// * `name` - Required. Identifier. The name of the subscription. It must have the format `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
2340 pub fn subscriptions_patch(
2341 &self,
2342 request: UpdateSubscriptionRequest,
2343 name: &str,
2344 ) -> ProjectSubscriptionPatchCall<'a, C> {
2345 ProjectSubscriptionPatchCall {
2346 hub: self.hub,
2347 _request: request,
2348 _name: name.to_string(),
2349 _delegate: Default::default(),
2350 _additional_params: Default::default(),
2351 _scopes: Default::default(),
2352 }
2353 }
2354
2355 /// Create a builder to help you perform the following task:
2356 ///
2357 /// Pulls messages from the server.
2358 ///
2359 /// # Arguments
2360 ///
2361 /// * `request` - No description provided.
2362 /// * `subscription` - Required. The subscription from which messages should be pulled. Format is `projects/{project}/subscriptions/{sub}`.
2363 pub fn subscriptions_pull(
2364 &self,
2365 request: PullRequest,
2366 subscription: &str,
2367 ) -> ProjectSubscriptionPullCall<'a, C> {
2368 ProjectSubscriptionPullCall {
2369 hub: self.hub,
2370 _request: request,
2371 _subscription: subscription.to_string(),
2372 _delegate: Default::default(),
2373 _additional_params: Default::default(),
2374 _scopes: Default::default(),
2375 }
2376 }
2377
2378 /// Create a builder to help you perform the following task:
2379 ///
2380 /// Seeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request. Snapshots are used in [Seek] (https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. Note that both the subscription and the snapshot must be on the same topic.
2381 ///
2382 /// # Arguments
2383 ///
2384 /// * `request` - No description provided.
2385 /// * `subscription` - Required. The subscription to affect.
2386 pub fn subscriptions_seek(
2387 &self,
2388 request: SeekRequest,
2389 subscription: &str,
2390 ) -> ProjectSubscriptionSeekCall<'a, C> {
2391 ProjectSubscriptionSeekCall {
2392 hub: self.hub,
2393 _request: request,
2394 _subscription: subscription.to_string(),
2395 _delegate: Default::default(),
2396 _additional_params: Default::default(),
2397 _scopes: Default::default(),
2398 }
2399 }
2400
2401 /// Create a builder to help you perform the following task:
2402 ///
2403 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2404 ///
2405 /// # Arguments
2406 ///
2407 /// * `request` - No description provided.
2408 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2409 pub fn subscriptions_set_iam_policy(
2410 &self,
2411 request: SetIamPolicyRequest,
2412 resource: &str,
2413 ) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
2414 ProjectSubscriptionSetIamPolicyCall {
2415 hub: self.hub,
2416 _request: request,
2417 _resource: resource.to_string(),
2418 _delegate: Default::default(),
2419 _additional_params: Default::default(),
2420 _scopes: Default::default(),
2421 }
2422 }
2423
2424 /// Create a builder to help you perform the following task:
2425 ///
2426 /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
2427 ///
2428 /// # Arguments
2429 ///
2430 /// * `request` - No description provided.
2431 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2432 pub fn subscriptions_test_iam_permissions(
2433 &self,
2434 request: TestIamPermissionsRequest,
2435 resource: &str,
2436 ) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
2437 ProjectSubscriptionTestIamPermissionCall {
2438 hub: self.hub,
2439 _request: request,
2440 _resource: resource.to_string(),
2441 _delegate: Default::default(),
2442 _additional_params: Default::default(),
2443 _scopes: Default::default(),
2444 }
2445 }
2446
2447 /// Create a builder to help you perform the following task:
2448 ///
2449 /// Lists the names of the snapshots on this topic. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
2450 ///
2451 /// # Arguments
2452 ///
2453 /// * `topic` - Required. The name of the topic that snapshots are attached to. Format is `projects/{project}/topics/{topic}`.
2454 pub fn topics_snapshots_list(&self, topic: &str) -> ProjectTopicSnapshotListCall<'a, C> {
2455 ProjectTopicSnapshotListCall {
2456 hub: self.hub,
2457 _topic: topic.to_string(),
2458 _page_token: Default::default(),
2459 _page_size: Default::default(),
2460 _delegate: Default::default(),
2461 _additional_params: Default::default(),
2462 _scopes: Default::default(),
2463 }
2464 }
2465
2466 /// Create a builder to help you perform the following task:
2467 ///
2468 /// Lists the names of the attached subscriptions on this topic.
2469 ///
2470 /// # Arguments
2471 ///
2472 /// * `topic` - Required. The name of the topic that subscriptions are attached to. Format is `projects/{project}/topics/{topic}`.
2473 pub fn topics_subscriptions_list(
2474 &self,
2475 topic: &str,
2476 ) -> ProjectTopicSubscriptionListCall<'a, C> {
2477 ProjectTopicSubscriptionListCall {
2478 hub: self.hub,
2479 _topic: topic.to_string(),
2480 _page_token: Default::default(),
2481 _page_size: Default::default(),
2482 _delegate: Default::default(),
2483 _additional_params: Default::default(),
2484 _scopes: Default::default(),
2485 }
2486 }
2487
2488 /// Create a builder to help you perform the following task:
2489 ///
2490 /// Creates the given topic with the given name. See the [resource name rules] (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
2491 ///
2492 /// # Arguments
2493 ///
2494 /// * `request` - No description provided.
2495 /// * `name` - Required. Identifier. The name of the topic. It must have the format `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
2496 pub fn topics_create(&self, request: Topic, name: &str) -> ProjectTopicCreateCall<'a, C> {
2497 ProjectTopicCreateCall {
2498 hub: self.hub,
2499 _request: request,
2500 _name: name.to_string(),
2501 _delegate: Default::default(),
2502 _additional_params: Default::default(),
2503 _scopes: Default::default(),
2504 }
2505 }
2506
2507 /// Create a builder to help you perform the following task:
2508 ///
2509 /// Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.
2510 ///
2511 /// # Arguments
2512 ///
2513 /// * `topic` - Required. Identifier. Name of the topic to delete. Format is `projects/{project}/topics/{topic}`.
2514 pub fn topics_delete(&self, topic: &str) -> ProjectTopicDeleteCall<'a, C> {
2515 ProjectTopicDeleteCall {
2516 hub: self.hub,
2517 _topic: topic.to_string(),
2518 _delegate: Default::default(),
2519 _additional_params: Default::default(),
2520 _scopes: Default::default(),
2521 }
2522 }
2523
2524 /// Create a builder to help you perform the following task:
2525 ///
2526 /// Gets the configuration of a topic.
2527 ///
2528 /// # Arguments
2529 ///
2530 /// * `topic` - Required. Identifier. The name of the topic to get. Format is `projects/{project}/topics/{topic}`.
2531 pub fn topics_get(&self, topic: &str) -> ProjectTopicGetCall<'a, C> {
2532 ProjectTopicGetCall {
2533 hub: self.hub,
2534 _topic: topic.to_string(),
2535 _delegate: Default::default(),
2536 _additional_params: Default::default(),
2537 _scopes: Default::default(),
2538 }
2539 }
2540
2541 /// Create a builder to help you perform the following task:
2542 ///
2543 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2544 ///
2545 /// # Arguments
2546 ///
2547 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2548 pub fn topics_get_iam_policy(&self, resource: &str) -> ProjectTopicGetIamPolicyCall<'a, C> {
2549 ProjectTopicGetIamPolicyCall {
2550 hub: self.hub,
2551 _resource: resource.to_string(),
2552 _options_requested_policy_version: Default::default(),
2553 _delegate: Default::default(),
2554 _additional_params: Default::default(),
2555 _scopes: Default::default(),
2556 }
2557 }
2558
2559 /// Create a builder to help you perform the following task:
2560 ///
2561 /// Lists matching topics.
2562 ///
2563 /// # Arguments
2564 ///
2565 /// * `project` - Required. Identifier. The name of the project in which to list topics. Format is `projects/{project-id}`.
2566 pub fn topics_list(&self, project: &str) -> ProjectTopicListCall<'a, C> {
2567 ProjectTopicListCall {
2568 hub: self.hub,
2569 _project: project.to_string(),
2570 _page_token: Default::default(),
2571 _page_size: Default::default(),
2572 _delegate: Default::default(),
2573 _additional_params: Default::default(),
2574 _scopes: Default::default(),
2575 }
2576 }
2577
2578 /// Create a builder to help you perform the following task:
2579 ///
2580 /// Updates an existing topic by updating the fields specified in the update mask. Note that certain properties of a topic are not modifiable.
2581 ///
2582 /// # Arguments
2583 ///
2584 /// * `request` - No description provided.
2585 /// * `name` - Required. Identifier. The name of the topic. It must have the format `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
2586 pub fn topics_patch(
2587 &self,
2588 request: UpdateTopicRequest,
2589 name: &str,
2590 ) -> ProjectTopicPatchCall<'a, C> {
2591 ProjectTopicPatchCall {
2592 hub: self.hub,
2593 _request: request,
2594 _name: name.to_string(),
2595 _delegate: Default::default(),
2596 _additional_params: Default::default(),
2597 _scopes: Default::default(),
2598 }
2599 }
2600
2601 /// Create a builder to help you perform the following task:
2602 ///
2603 /// Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist.
2604 ///
2605 /// # Arguments
2606 ///
2607 /// * `request` - No description provided.
2608 /// * `topic` - Required. Identifier. The messages in the request will be published on this topic. Format is `projects/{project}/topics/{topic}`.
2609 pub fn topics_publish(
2610 &self,
2611 request: PublishRequest,
2612 topic: &str,
2613 ) -> ProjectTopicPublishCall<'a, C> {
2614 ProjectTopicPublishCall {
2615 hub: self.hub,
2616 _request: request,
2617 _topic: topic.to_string(),
2618 _delegate: Default::default(),
2619 _additional_params: Default::default(),
2620 _scopes: Default::default(),
2621 }
2622 }
2623
2624 /// Create a builder to help you perform the following task:
2625 ///
2626 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2627 ///
2628 /// # Arguments
2629 ///
2630 /// * `request` - No description provided.
2631 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2632 pub fn topics_set_iam_policy(
2633 &self,
2634 request: SetIamPolicyRequest,
2635 resource: &str,
2636 ) -> ProjectTopicSetIamPolicyCall<'a, C> {
2637 ProjectTopicSetIamPolicyCall {
2638 hub: self.hub,
2639 _request: request,
2640 _resource: resource.to_string(),
2641 _delegate: Default::default(),
2642 _additional_params: Default::default(),
2643 _scopes: Default::default(),
2644 }
2645 }
2646
2647 /// Create a builder to help you perform the following task:
2648 ///
2649 /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
2650 ///
2651 /// # Arguments
2652 ///
2653 /// * `request` - No description provided.
2654 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2655 pub fn topics_test_iam_permissions(
2656 &self,
2657 request: TestIamPermissionsRequest,
2658 resource: &str,
2659 ) -> ProjectTopicTestIamPermissionCall<'a, C> {
2660 ProjectTopicTestIamPermissionCall {
2661 hub: self.hub,
2662 _request: request,
2663 _resource: resource.to_string(),
2664 _delegate: Default::default(),
2665 _additional_params: Default::default(),
2666 _scopes: Default::default(),
2667 }
2668 }
2669}
2670
2671// ###################
2672// CallBuilders ###
2673// #################
2674
2675/// Commits a new schema revision to an existing schema.
2676///
2677/// A builder for the *schemas.commit* method supported by a *project* resource.
2678/// It is not used directly, but through a [`ProjectMethods`] instance.
2679///
2680/// # Example
2681///
2682/// Instantiate a resource method builder
2683///
2684/// ```test_harness,no_run
2685/// # extern crate hyper;
2686/// # extern crate hyper_rustls;
2687/// # extern crate google_pubsub1 as pubsub1;
2688/// use pubsub1::api::CommitSchemaRequest;
2689/// # async fn dox() {
2690/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2691///
2692/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2693/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2694/// # .with_native_roots()
2695/// # .unwrap()
2696/// # .https_only()
2697/// # .enable_http2()
2698/// # .build();
2699///
2700/// # let executor = hyper_util::rt::TokioExecutor::new();
2701/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2702/// # secret,
2703/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2704/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2705/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2706/// # ),
2707/// # ).build().await.unwrap();
2708///
2709/// # let client = hyper_util::client::legacy::Client::builder(
2710/// # hyper_util::rt::TokioExecutor::new()
2711/// # )
2712/// # .build(
2713/// # hyper_rustls::HttpsConnectorBuilder::new()
2714/// # .with_native_roots()
2715/// # .unwrap()
2716/// # .https_or_http()
2717/// # .enable_http2()
2718/// # .build()
2719/// # );
2720/// # let mut hub = Pubsub::new(client, auth);
2721/// // As the method needs a request, you would usually fill it with the desired information
2722/// // into the respective structure. Some of the parts shown here might not be applicable !
2723/// // Values shown here are possibly random and not representative !
2724/// let mut req = CommitSchemaRequest::default();
2725///
2726/// // You can configure optional parameters by calling the respective setters at will, and
2727/// // execute the final call using `doit()`.
2728/// // Values shown here are possibly random and not representative !
2729/// let result = hub.projects().schemas_commit(req, "name")
2730/// .doit().await;
2731/// # }
2732/// ```
2733pub struct ProjectSchemaCommitCall<'a, C>
2734where
2735 C: 'a,
2736{
2737 hub: &'a Pubsub<C>,
2738 _request: CommitSchemaRequest,
2739 _name: String,
2740 _delegate: Option<&'a mut dyn common::Delegate>,
2741 _additional_params: HashMap<String, String>,
2742 _scopes: BTreeSet<String>,
2743}
2744
2745impl<'a, C> common::CallBuilder for ProjectSchemaCommitCall<'a, C> {}
2746
2747impl<'a, C> ProjectSchemaCommitCall<'a, C>
2748where
2749 C: common::Connector,
2750{
2751 /// Perform the operation you have build so far.
2752 pub async fn doit(mut self) -> common::Result<(common::Response, Schema)> {
2753 use std::borrow::Cow;
2754 use std::io::{Read, Seek};
2755
2756 use common::{url::Params, ToParts};
2757 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2758
2759 let mut dd = common::DefaultDelegate;
2760 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2761 dlg.begin(common::MethodInfo {
2762 id: "pubsub.projects.schemas.commit",
2763 http_method: hyper::Method::POST,
2764 });
2765
2766 for &field in ["alt", "name"].iter() {
2767 if self._additional_params.contains_key(field) {
2768 dlg.finished(false);
2769 return Err(common::Error::FieldClash(field));
2770 }
2771 }
2772
2773 let mut params = Params::with_capacity(4 + self._additional_params.len());
2774 params.push("name", self._name);
2775
2776 params.extend(self._additional_params.iter());
2777
2778 params.push("alt", "json");
2779 let mut url = self.hub._base_url.clone() + "v1/{+name}:commit";
2780 if self._scopes.is_empty() {
2781 self._scopes
2782 .insert(Scope::CloudPlatform.as_ref().to_string());
2783 }
2784
2785 #[allow(clippy::single_element_loop)]
2786 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2787 url = params.uri_replacement(url, param_name, find_this, true);
2788 }
2789 {
2790 let to_remove = ["name"];
2791 params.remove_params(&to_remove);
2792 }
2793
2794 let url = params.parse_with_url(&url);
2795
2796 let mut json_mime_type = mime::APPLICATION_JSON;
2797 let mut request_value_reader = {
2798 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2799 common::remove_json_null_values(&mut value);
2800 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2801 serde_json::to_writer(&mut dst, &value).unwrap();
2802 dst
2803 };
2804 let request_size = request_value_reader
2805 .seek(std::io::SeekFrom::End(0))
2806 .unwrap();
2807 request_value_reader
2808 .seek(std::io::SeekFrom::Start(0))
2809 .unwrap();
2810
2811 loop {
2812 let token = match self
2813 .hub
2814 .auth
2815 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2816 .await
2817 {
2818 Ok(token) => token,
2819 Err(e) => match dlg.token(e) {
2820 Ok(token) => token,
2821 Err(e) => {
2822 dlg.finished(false);
2823 return Err(common::Error::MissingToken(e));
2824 }
2825 },
2826 };
2827 request_value_reader
2828 .seek(std::io::SeekFrom::Start(0))
2829 .unwrap();
2830 let mut req_result = {
2831 let client = &self.hub.client;
2832 dlg.pre_request();
2833 let mut req_builder = hyper::Request::builder()
2834 .method(hyper::Method::POST)
2835 .uri(url.as_str())
2836 .header(USER_AGENT, self.hub._user_agent.clone());
2837
2838 if let Some(token) = token.as_ref() {
2839 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2840 }
2841
2842 let request = req_builder
2843 .header(CONTENT_TYPE, json_mime_type.to_string())
2844 .header(CONTENT_LENGTH, request_size as u64)
2845 .body(common::to_body(
2846 request_value_reader.get_ref().clone().into(),
2847 ));
2848
2849 client.request(request.unwrap()).await
2850 };
2851
2852 match req_result {
2853 Err(err) => {
2854 if let common::Retry::After(d) = dlg.http_error(&err) {
2855 sleep(d).await;
2856 continue;
2857 }
2858 dlg.finished(false);
2859 return Err(common::Error::HttpError(err));
2860 }
2861 Ok(res) => {
2862 let (mut parts, body) = res.into_parts();
2863 let mut body = common::Body::new(body);
2864 if !parts.status.is_success() {
2865 let bytes = common::to_bytes(body).await.unwrap_or_default();
2866 let error = serde_json::from_str(&common::to_string(&bytes));
2867 let response = common::to_response(parts, bytes.into());
2868
2869 if let common::Retry::After(d) =
2870 dlg.http_failure(&response, error.as_ref().ok())
2871 {
2872 sleep(d).await;
2873 continue;
2874 }
2875
2876 dlg.finished(false);
2877
2878 return Err(match error {
2879 Ok(value) => common::Error::BadRequest(value),
2880 _ => common::Error::Failure(response),
2881 });
2882 }
2883 let response = {
2884 let bytes = common::to_bytes(body).await.unwrap_or_default();
2885 let encoded = common::to_string(&bytes);
2886 match serde_json::from_str(&encoded) {
2887 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2888 Err(error) => {
2889 dlg.response_json_decode_error(&encoded, &error);
2890 return Err(common::Error::JsonDecodeError(
2891 encoded.to_string(),
2892 error,
2893 ));
2894 }
2895 }
2896 };
2897
2898 dlg.finished(true);
2899 return Ok(response);
2900 }
2901 }
2902 }
2903 }
2904
2905 ///
2906 /// Sets the *request* property to the given value.
2907 ///
2908 /// Even though the property as already been set when instantiating this call,
2909 /// we provide this method for API completeness.
2910 pub fn request(mut self, new_value: CommitSchemaRequest) -> ProjectSchemaCommitCall<'a, C> {
2911 self._request = new_value;
2912 self
2913 }
2914 /// Required. The name of the schema we are revising. Format is `projects/{project}/schemas/{schema}`.
2915 ///
2916 /// Sets the *name* path property to the given value.
2917 ///
2918 /// Even though the property as already been set when instantiating this call,
2919 /// we provide this method for API completeness.
2920 pub fn name(mut self, new_value: &str) -> ProjectSchemaCommitCall<'a, C> {
2921 self._name = new_value.to_string();
2922 self
2923 }
2924 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2925 /// while executing the actual API request.
2926 ///
2927 /// ````text
2928 /// It should be used to handle progress information, and to implement a certain level of resilience.
2929 /// ````
2930 ///
2931 /// Sets the *delegate* property to the given value.
2932 pub fn delegate(
2933 mut self,
2934 new_value: &'a mut dyn common::Delegate,
2935 ) -> ProjectSchemaCommitCall<'a, C> {
2936 self._delegate = Some(new_value);
2937 self
2938 }
2939
2940 /// Set any additional parameter of the query string used in the request.
2941 /// It should be used to set parameters which are not yet available through their own
2942 /// setters.
2943 ///
2944 /// Please note that this method must not be used to set any of the known parameters
2945 /// which have their own setter method. If done anyway, the request will fail.
2946 ///
2947 /// # Additional Parameters
2948 ///
2949 /// * *$.xgafv* (query-string) - V1 error format.
2950 /// * *access_token* (query-string) - OAuth access token.
2951 /// * *alt* (query-string) - Data format for response.
2952 /// * *callback* (query-string) - JSONP
2953 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2954 /// * *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.
2955 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2956 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2957 /// * *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.
2958 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2959 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2960 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaCommitCall<'a, C>
2961 where
2962 T: AsRef<str>,
2963 {
2964 self._additional_params
2965 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2966 self
2967 }
2968
2969 /// Identifies the authorization scope for the method you are building.
2970 ///
2971 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2972 /// [`Scope::CloudPlatform`].
2973 ///
2974 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2975 /// tokens for more than one scope.
2976 ///
2977 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2978 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2979 /// sufficient, a read-write scope will do as well.
2980 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaCommitCall<'a, C>
2981 where
2982 St: AsRef<str>,
2983 {
2984 self._scopes.insert(String::from(scope.as_ref()));
2985 self
2986 }
2987 /// Identifies the authorization scope(s) for the method you are building.
2988 ///
2989 /// See [`Self::add_scope()`] for details.
2990 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaCommitCall<'a, C>
2991 where
2992 I: IntoIterator<Item = St>,
2993 St: AsRef<str>,
2994 {
2995 self._scopes
2996 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2997 self
2998 }
2999
3000 /// Removes all scopes, and no default scope will be used either.
3001 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3002 /// for details).
3003 pub fn clear_scopes(mut self) -> ProjectSchemaCommitCall<'a, C> {
3004 self._scopes.clear();
3005 self
3006 }
3007}
3008
3009/// Creates a schema.
3010///
3011/// A builder for the *schemas.create* method supported by a *project* resource.
3012/// It is not used directly, but through a [`ProjectMethods`] instance.
3013///
3014/// # Example
3015///
3016/// Instantiate a resource method builder
3017///
3018/// ```test_harness,no_run
3019/// # extern crate hyper;
3020/// # extern crate hyper_rustls;
3021/// # extern crate google_pubsub1 as pubsub1;
3022/// use pubsub1::api::Schema;
3023/// # async fn dox() {
3024/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3025///
3026/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3027/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3028/// # .with_native_roots()
3029/// # .unwrap()
3030/// # .https_only()
3031/// # .enable_http2()
3032/// # .build();
3033///
3034/// # let executor = hyper_util::rt::TokioExecutor::new();
3035/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3036/// # secret,
3037/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3038/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3039/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3040/// # ),
3041/// # ).build().await.unwrap();
3042///
3043/// # let client = hyper_util::client::legacy::Client::builder(
3044/// # hyper_util::rt::TokioExecutor::new()
3045/// # )
3046/// # .build(
3047/// # hyper_rustls::HttpsConnectorBuilder::new()
3048/// # .with_native_roots()
3049/// # .unwrap()
3050/// # .https_or_http()
3051/// # .enable_http2()
3052/// # .build()
3053/// # );
3054/// # let mut hub = Pubsub::new(client, auth);
3055/// // As the method needs a request, you would usually fill it with the desired information
3056/// // into the respective structure. Some of the parts shown here might not be applicable !
3057/// // Values shown here are possibly random and not representative !
3058/// let mut req = Schema::default();
3059///
3060/// // You can configure optional parameters by calling the respective setters at will, and
3061/// // execute the final call using `doit()`.
3062/// // Values shown here are possibly random and not representative !
3063/// let result = hub.projects().schemas_create(req, "parent")
3064/// .schema_id("amet.")
3065/// .doit().await;
3066/// # }
3067/// ```
3068pub struct ProjectSchemaCreateCall<'a, C>
3069where
3070 C: 'a,
3071{
3072 hub: &'a Pubsub<C>,
3073 _request: Schema,
3074 _parent: String,
3075 _schema_id: Option<String>,
3076 _delegate: Option<&'a mut dyn common::Delegate>,
3077 _additional_params: HashMap<String, String>,
3078 _scopes: BTreeSet<String>,
3079}
3080
3081impl<'a, C> common::CallBuilder for ProjectSchemaCreateCall<'a, C> {}
3082
3083impl<'a, C> ProjectSchemaCreateCall<'a, C>
3084where
3085 C: common::Connector,
3086{
3087 /// Perform the operation you have build so far.
3088 pub async fn doit(mut self) -> common::Result<(common::Response, Schema)> {
3089 use std::borrow::Cow;
3090 use std::io::{Read, Seek};
3091
3092 use common::{url::Params, ToParts};
3093 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3094
3095 let mut dd = common::DefaultDelegate;
3096 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3097 dlg.begin(common::MethodInfo {
3098 id: "pubsub.projects.schemas.create",
3099 http_method: hyper::Method::POST,
3100 });
3101
3102 for &field in ["alt", "parent", "schemaId"].iter() {
3103 if self._additional_params.contains_key(field) {
3104 dlg.finished(false);
3105 return Err(common::Error::FieldClash(field));
3106 }
3107 }
3108
3109 let mut params = Params::with_capacity(5 + self._additional_params.len());
3110 params.push("parent", self._parent);
3111 if let Some(value) = self._schema_id.as_ref() {
3112 params.push("schemaId", value);
3113 }
3114
3115 params.extend(self._additional_params.iter());
3116
3117 params.push("alt", "json");
3118 let mut url = self.hub._base_url.clone() + "v1/{+parent}/schemas";
3119 if self._scopes.is_empty() {
3120 self._scopes
3121 .insert(Scope::CloudPlatform.as_ref().to_string());
3122 }
3123
3124 #[allow(clippy::single_element_loop)]
3125 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3126 url = params.uri_replacement(url, param_name, find_this, true);
3127 }
3128 {
3129 let to_remove = ["parent"];
3130 params.remove_params(&to_remove);
3131 }
3132
3133 let url = params.parse_with_url(&url);
3134
3135 let mut json_mime_type = mime::APPLICATION_JSON;
3136 let mut request_value_reader = {
3137 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3138 common::remove_json_null_values(&mut value);
3139 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3140 serde_json::to_writer(&mut dst, &value).unwrap();
3141 dst
3142 };
3143 let request_size = request_value_reader
3144 .seek(std::io::SeekFrom::End(0))
3145 .unwrap();
3146 request_value_reader
3147 .seek(std::io::SeekFrom::Start(0))
3148 .unwrap();
3149
3150 loop {
3151 let token = match self
3152 .hub
3153 .auth
3154 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3155 .await
3156 {
3157 Ok(token) => token,
3158 Err(e) => match dlg.token(e) {
3159 Ok(token) => token,
3160 Err(e) => {
3161 dlg.finished(false);
3162 return Err(common::Error::MissingToken(e));
3163 }
3164 },
3165 };
3166 request_value_reader
3167 .seek(std::io::SeekFrom::Start(0))
3168 .unwrap();
3169 let mut req_result = {
3170 let client = &self.hub.client;
3171 dlg.pre_request();
3172 let mut req_builder = hyper::Request::builder()
3173 .method(hyper::Method::POST)
3174 .uri(url.as_str())
3175 .header(USER_AGENT, self.hub._user_agent.clone());
3176
3177 if let Some(token) = token.as_ref() {
3178 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3179 }
3180
3181 let request = req_builder
3182 .header(CONTENT_TYPE, json_mime_type.to_string())
3183 .header(CONTENT_LENGTH, request_size as u64)
3184 .body(common::to_body(
3185 request_value_reader.get_ref().clone().into(),
3186 ));
3187
3188 client.request(request.unwrap()).await
3189 };
3190
3191 match req_result {
3192 Err(err) => {
3193 if let common::Retry::After(d) = dlg.http_error(&err) {
3194 sleep(d).await;
3195 continue;
3196 }
3197 dlg.finished(false);
3198 return Err(common::Error::HttpError(err));
3199 }
3200 Ok(res) => {
3201 let (mut parts, body) = res.into_parts();
3202 let mut body = common::Body::new(body);
3203 if !parts.status.is_success() {
3204 let bytes = common::to_bytes(body).await.unwrap_or_default();
3205 let error = serde_json::from_str(&common::to_string(&bytes));
3206 let response = common::to_response(parts, bytes.into());
3207
3208 if let common::Retry::After(d) =
3209 dlg.http_failure(&response, error.as_ref().ok())
3210 {
3211 sleep(d).await;
3212 continue;
3213 }
3214
3215 dlg.finished(false);
3216
3217 return Err(match error {
3218 Ok(value) => common::Error::BadRequest(value),
3219 _ => common::Error::Failure(response),
3220 });
3221 }
3222 let response = {
3223 let bytes = common::to_bytes(body).await.unwrap_or_default();
3224 let encoded = common::to_string(&bytes);
3225 match serde_json::from_str(&encoded) {
3226 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3227 Err(error) => {
3228 dlg.response_json_decode_error(&encoded, &error);
3229 return Err(common::Error::JsonDecodeError(
3230 encoded.to_string(),
3231 error,
3232 ));
3233 }
3234 }
3235 };
3236
3237 dlg.finished(true);
3238 return Ok(response);
3239 }
3240 }
3241 }
3242 }
3243
3244 ///
3245 /// Sets the *request* property to the given value.
3246 ///
3247 /// Even though the property as already been set when instantiating this call,
3248 /// we provide this method for API completeness.
3249 pub fn request(mut self, new_value: Schema) -> ProjectSchemaCreateCall<'a, C> {
3250 self._request = new_value;
3251 self
3252 }
3253 /// Required. The name of the project in which to create the schema. Format is `projects/{project-id}`.
3254 ///
3255 /// Sets the *parent* path property to the given value.
3256 ///
3257 /// Even though the property as already been set when instantiating this call,
3258 /// we provide this method for API completeness.
3259 pub fn parent(mut self, new_value: &str) -> ProjectSchemaCreateCall<'a, C> {
3260 self._parent = new_value.to_string();
3261 self
3262 }
3263 /// The ID to use for the schema, which will become the final component of the schema's resource name. See https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names for resource name constraints.
3264 ///
3265 /// Sets the *schema id* query property to the given value.
3266 pub fn schema_id(mut self, new_value: &str) -> ProjectSchemaCreateCall<'a, C> {
3267 self._schema_id = Some(new_value.to_string());
3268 self
3269 }
3270 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3271 /// while executing the actual API request.
3272 ///
3273 /// ````text
3274 /// It should be used to handle progress information, and to implement a certain level of resilience.
3275 /// ````
3276 ///
3277 /// Sets the *delegate* property to the given value.
3278 pub fn delegate(
3279 mut self,
3280 new_value: &'a mut dyn common::Delegate,
3281 ) -> ProjectSchemaCreateCall<'a, C> {
3282 self._delegate = Some(new_value);
3283 self
3284 }
3285
3286 /// Set any additional parameter of the query string used in the request.
3287 /// It should be used to set parameters which are not yet available through their own
3288 /// setters.
3289 ///
3290 /// Please note that this method must not be used to set any of the known parameters
3291 /// which have their own setter method. If done anyway, the request will fail.
3292 ///
3293 /// # Additional Parameters
3294 ///
3295 /// * *$.xgafv* (query-string) - V1 error format.
3296 /// * *access_token* (query-string) - OAuth access token.
3297 /// * *alt* (query-string) - Data format for response.
3298 /// * *callback* (query-string) - JSONP
3299 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3300 /// * *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.
3301 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3302 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3303 /// * *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.
3304 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3305 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3306 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaCreateCall<'a, C>
3307 where
3308 T: AsRef<str>,
3309 {
3310 self._additional_params
3311 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3312 self
3313 }
3314
3315 /// Identifies the authorization scope for the method you are building.
3316 ///
3317 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3318 /// [`Scope::CloudPlatform`].
3319 ///
3320 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3321 /// tokens for more than one scope.
3322 ///
3323 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3324 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3325 /// sufficient, a read-write scope will do as well.
3326 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaCreateCall<'a, C>
3327 where
3328 St: AsRef<str>,
3329 {
3330 self._scopes.insert(String::from(scope.as_ref()));
3331 self
3332 }
3333 /// Identifies the authorization scope(s) for the method you are building.
3334 ///
3335 /// See [`Self::add_scope()`] for details.
3336 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaCreateCall<'a, C>
3337 where
3338 I: IntoIterator<Item = St>,
3339 St: AsRef<str>,
3340 {
3341 self._scopes
3342 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3343 self
3344 }
3345
3346 /// Removes all scopes, and no default scope will be used either.
3347 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3348 /// for details).
3349 pub fn clear_scopes(mut self) -> ProjectSchemaCreateCall<'a, C> {
3350 self._scopes.clear();
3351 self
3352 }
3353}
3354
3355/// Deletes a schema.
3356///
3357/// A builder for the *schemas.delete* method supported by a *project* resource.
3358/// It is not used directly, but through a [`ProjectMethods`] instance.
3359///
3360/// # Example
3361///
3362/// Instantiate a resource method builder
3363///
3364/// ```test_harness,no_run
3365/// # extern crate hyper;
3366/// # extern crate hyper_rustls;
3367/// # extern crate google_pubsub1 as pubsub1;
3368/// # async fn dox() {
3369/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3370///
3371/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3372/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3373/// # .with_native_roots()
3374/// # .unwrap()
3375/// # .https_only()
3376/// # .enable_http2()
3377/// # .build();
3378///
3379/// # let executor = hyper_util::rt::TokioExecutor::new();
3380/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3381/// # secret,
3382/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3383/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3384/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3385/// # ),
3386/// # ).build().await.unwrap();
3387///
3388/// # let client = hyper_util::client::legacy::Client::builder(
3389/// # hyper_util::rt::TokioExecutor::new()
3390/// # )
3391/// # .build(
3392/// # hyper_rustls::HttpsConnectorBuilder::new()
3393/// # .with_native_roots()
3394/// # .unwrap()
3395/// # .https_or_http()
3396/// # .enable_http2()
3397/// # .build()
3398/// # );
3399/// # let mut hub = Pubsub::new(client, auth);
3400/// // You can configure optional parameters by calling the respective setters at will, and
3401/// // execute the final call using `doit()`.
3402/// // Values shown here are possibly random and not representative !
3403/// let result = hub.projects().schemas_delete("name")
3404/// .doit().await;
3405/// # }
3406/// ```
3407pub struct ProjectSchemaDeleteCall<'a, C>
3408where
3409 C: 'a,
3410{
3411 hub: &'a Pubsub<C>,
3412 _name: String,
3413 _delegate: Option<&'a mut dyn common::Delegate>,
3414 _additional_params: HashMap<String, String>,
3415 _scopes: BTreeSet<String>,
3416}
3417
3418impl<'a, C> common::CallBuilder for ProjectSchemaDeleteCall<'a, C> {}
3419
3420impl<'a, C> ProjectSchemaDeleteCall<'a, C>
3421where
3422 C: common::Connector,
3423{
3424 /// Perform the operation you have build so far.
3425 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3426 use std::borrow::Cow;
3427 use std::io::{Read, Seek};
3428
3429 use common::{url::Params, ToParts};
3430 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3431
3432 let mut dd = common::DefaultDelegate;
3433 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3434 dlg.begin(common::MethodInfo {
3435 id: "pubsub.projects.schemas.delete",
3436 http_method: hyper::Method::DELETE,
3437 });
3438
3439 for &field in ["alt", "name"].iter() {
3440 if self._additional_params.contains_key(field) {
3441 dlg.finished(false);
3442 return Err(common::Error::FieldClash(field));
3443 }
3444 }
3445
3446 let mut params = Params::with_capacity(3 + self._additional_params.len());
3447 params.push("name", self._name);
3448
3449 params.extend(self._additional_params.iter());
3450
3451 params.push("alt", "json");
3452 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3453 if self._scopes.is_empty() {
3454 self._scopes
3455 .insert(Scope::CloudPlatform.as_ref().to_string());
3456 }
3457
3458 #[allow(clippy::single_element_loop)]
3459 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3460 url = params.uri_replacement(url, param_name, find_this, true);
3461 }
3462 {
3463 let to_remove = ["name"];
3464 params.remove_params(&to_remove);
3465 }
3466
3467 let url = params.parse_with_url(&url);
3468
3469 loop {
3470 let token = match self
3471 .hub
3472 .auth
3473 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3474 .await
3475 {
3476 Ok(token) => token,
3477 Err(e) => match dlg.token(e) {
3478 Ok(token) => token,
3479 Err(e) => {
3480 dlg.finished(false);
3481 return Err(common::Error::MissingToken(e));
3482 }
3483 },
3484 };
3485 let mut req_result = {
3486 let client = &self.hub.client;
3487 dlg.pre_request();
3488 let mut req_builder = hyper::Request::builder()
3489 .method(hyper::Method::DELETE)
3490 .uri(url.as_str())
3491 .header(USER_AGENT, self.hub._user_agent.clone());
3492
3493 if let Some(token) = token.as_ref() {
3494 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3495 }
3496
3497 let request = req_builder
3498 .header(CONTENT_LENGTH, 0_u64)
3499 .body(common::to_body::<String>(None));
3500
3501 client.request(request.unwrap()).await
3502 };
3503
3504 match req_result {
3505 Err(err) => {
3506 if let common::Retry::After(d) = dlg.http_error(&err) {
3507 sleep(d).await;
3508 continue;
3509 }
3510 dlg.finished(false);
3511 return Err(common::Error::HttpError(err));
3512 }
3513 Ok(res) => {
3514 let (mut parts, body) = res.into_parts();
3515 let mut body = common::Body::new(body);
3516 if !parts.status.is_success() {
3517 let bytes = common::to_bytes(body).await.unwrap_or_default();
3518 let error = serde_json::from_str(&common::to_string(&bytes));
3519 let response = common::to_response(parts, bytes.into());
3520
3521 if let common::Retry::After(d) =
3522 dlg.http_failure(&response, error.as_ref().ok())
3523 {
3524 sleep(d).await;
3525 continue;
3526 }
3527
3528 dlg.finished(false);
3529
3530 return Err(match error {
3531 Ok(value) => common::Error::BadRequest(value),
3532 _ => common::Error::Failure(response),
3533 });
3534 }
3535 let response = {
3536 let bytes = common::to_bytes(body).await.unwrap_or_default();
3537 let encoded = common::to_string(&bytes);
3538 match serde_json::from_str(&encoded) {
3539 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3540 Err(error) => {
3541 dlg.response_json_decode_error(&encoded, &error);
3542 return Err(common::Error::JsonDecodeError(
3543 encoded.to_string(),
3544 error,
3545 ));
3546 }
3547 }
3548 };
3549
3550 dlg.finished(true);
3551 return Ok(response);
3552 }
3553 }
3554 }
3555 }
3556
3557 /// Required. Name of the schema to delete. Format is `projects/{project}/schemas/{schema}`.
3558 ///
3559 /// Sets the *name* path property to the given value.
3560 ///
3561 /// Even though the property as already been set when instantiating this call,
3562 /// we provide this method for API completeness.
3563 pub fn name(mut self, new_value: &str) -> ProjectSchemaDeleteCall<'a, C> {
3564 self._name = new_value.to_string();
3565 self
3566 }
3567 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3568 /// while executing the actual API request.
3569 ///
3570 /// ````text
3571 /// It should be used to handle progress information, and to implement a certain level of resilience.
3572 /// ````
3573 ///
3574 /// Sets the *delegate* property to the given value.
3575 pub fn delegate(
3576 mut self,
3577 new_value: &'a mut dyn common::Delegate,
3578 ) -> ProjectSchemaDeleteCall<'a, C> {
3579 self._delegate = Some(new_value);
3580 self
3581 }
3582
3583 /// Set any additional parameter of the query string used in the request.
3584 /// It should be used to set parameters which are not yet available through their own
3585 /// setters.
3586 ///
3587 /// Please note that this method must not be used to set any of the known parameters
3588 /// which have their own setter method. If done anyway, the request will fail.
3589 ///
3590 /// # Additional Parameters
3591 ///
3592 /// * *$.xgafv* (query-string) - V1 error format.
3593 /// * *access_token* (query-string) - OAuth access token.
3594 /// * *alt* (query-string) - Data format for response.
3595 /// * *callback* (query-string) - JSONP
3596 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3597 /// * *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.
3598 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3599 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3600 /// * *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.
3601 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3602 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3603 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaDeleteCall<'a, C>
3604 where
3605 T: AsRef<str>,
3606 {
3607 self._additional_params
3608 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3609 self
3610 }
3611
3612 /// Identifies the authorization scope for the method you are building.
3613 ///
3614 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3615 /// [`Scope::CloudPlatform`].
3616 ///
3617 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3618 /// tokens for more than one scope.
3619 ///
3620 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3621 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3622 /// sufficient, a read-write scope will do as well.
3623 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaDeleteCall<'a, C>
3624 where
3625 St: AsRef<str>,
3626 {
3627 self._scopes.insert(String::from(scope.as_ref()));
3628 self
3629 }
3630 /// Identifies the authorization scope(s) for the method you are building.
3631 ///
3632 /// See [`Self::add_scope()`] for details.
3633 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaDeleteCall<'a, C>
3634 where
3635 I: IntoIterator<Item = St>,
3636 St: AsRef<str>,
3637 {
3638 self._scopes
3639 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3640 self
3641 }
3642
3643 /// Removes all scopes, and no default scope will be used either.
3644 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3645 /// for details).
3646 pub fn clear_scopes(mut self) -> ProjectSchemaDeleteCall<'a, C> {
3647 self._scopes.clear();
3648 self
3649 }
3650}
3651
3652/// Deletes a specific schema revision.
3653///
3654/// A builder for the *schemas.deleteRevision* method supported by a *project* resource.
3655/// It is not used directly, but through a [`ProjectMethods`] instance.
3656///
3657/// # Example
3658///
3659/// Instantiate a resource method builder
3660///
3661/// ```test_harness,no_run
3662/// # extern crate hyper;
3663/// # extern crate hyper_rustls;
3664/// # extern crate google_pubsub1 as pubsub1;
3665/// # async fn dox() {
3666/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3667///
3668/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3669/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3670/// # .with_native_roots()
3671/// # .unwrap()
3672/// # .https_only()
3673/// # .enable_http2()
3674/// # .build();
3675///
3676/// # let executor = hyper_util::rt::TokioExecutor::new();
3677/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3678/// # secret,
3679/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3680/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3681/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3682/// # ),
3683/// # ).build().await.unwrap();
3684///
3685/// # let client = hyper_util::client::legacy::Client::builder(
3686/// # hyper_util::rt::TokioExecutor::new()
3687/// # )
3688/// # .build(
3689/// # hyper_rustls::HttpsConnectorBuilder::new()
3690/// # .with_native_roots()
3691/// # .unwrap()
3692/// # .https_or_http()
3693/// # .enable_http2()
3694/// # .build()
3695/// # );
3696/// # let mut hub = Pubsub::new(client, auth);
3697/// // You can configure optional parameters by calling the respective setters at will, and
3698/// // execute the final call using `doit()`.
3699/// // Values shown here are possibly random and not representative !
3700/// let result = hub.projects().schemas_delete_revision("name")
3701/// .revision_id("duo")
3702/// .doit().await;
3703/// # }
3704/// ```
3705pub struct ProjectSchemaDeleteRevisionCall<'a, C>
3706where
3707 C: 'a,
3708{
3709 hub: &'a Pubsub<C>,
3710 _name: String,
3711 _revision_id: Option<String>,
3712 _delegate: Option<&'a mut dyn common::Delegate>,
3713 _additional_params: HashMap<String, String>,
3714 _scopes: BTreeSet<String>,
3715}
3716
3717impl<'a, C> common::CallBuilder for ProjectSchemaDeleteRevisionCall<'a, C> {}
3718
3719impl<'a, C> ProjectSchemaDeleteRevisionCall<'a, C>
3720where
3721 C: common::Connector,
3722{
3723 /// Perform the operation you have build so far.
3724 pub async fn doit(mut self) -> common::Result<(common::Response, Schema)> {
3725 use std::borrow::Cow;
3726 use std::io::{Read, Seek};
3727
3728 use common::{url::Params, ToParts};
3729 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3730
3731 let mut dd = common::DefaultDelegate;
3732 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3733 dlg.begin(common::MethodInfo {
3734 id: "pubsub.projects.schemas.deleteRevision",
3735 http_method: hyper::Method::DELETE,
3736 });
3737
3738 for &field in ["alt", "name", "revisionId"].iter() {
3739 if self._additional_params.contains_key(field) {
3740 dlg.finished(false);
3741 return Err(common::Error::FieldClash(field));
3742 }
3743 }
3744
3745 let mut params = Params::with_capacity(4 + self._additional_params.len());
3746 params.push("name", self._name);
3747 if let Some(value) = self._revision_id.as_ref() {
3748 params.push("revisionId", value);
3749 }
3750
3751 params.extend(self._additional_params.iter());
3752
3753 params.push("alt", "json");
3754 let mut url = self.hub._base_url.clone() + "v1/{+name}:deleteRevision";
3755 if self._scopes.is_empty() {
3756 self._scopes
3757 .insert(Scope::CloudPlatform.as_ref().to_string());
3758 }
3759
3760 #[allow(clippy::single_element_loop)]
3761 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3762 url = params.uri_replacement(url, param_name, find_this, true);
3763 }
3764 {
3765 let to_remove = ["name"];
3766 params.remove_params(&to_remove);
3767 }
3768
3769 let url = params.parse_with_url(&url);
3770
3771 loop {
3772 let token = match self
3773 .hub
3774 .auth
3775 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3776 .await
3777 {
3778 Ok(token) => token,
3779 Err(e) => match dlg.token(e) {
3780 Ok(token) => token,
3781 Err(e) => {
3782 dlg.finished(false);
3783 return Err(common::Error::MissingToken(e));
3784 }
3785 },
3786 };
3787 let mut req_result = {
3788 let client = &self.hub.client;
3789 dlg.pre_request();
3790 let mut req_builder = hyper::Request::builder()
3791 .method(hyper::Method::DELETE)
3792 .uri(url.as_str())
3793 .header(USER_AGENT, self.hub._user_agent.clone());
3794
3795 if let Some(token) = token.as_ref() {
3796 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3797 }
3798
3799 let request = req_builder
3800 .header(CONTENT_LENGTH, 0_u64)
3801 .body(common::to_body::<String>(None));
3802
3803 client.request(request.unwrap()).await
3804 };
3805
3806 match req_result {
3807 Err(err) => {
3808 if let common::Retry::After(d) = dlg.http_error(&err) {
3809 sleep(d).await;
3810 continue;
3811 }
3812 dlg.finished(false);
3813 return Err(common::Error::HttpError(err));
3814 }
3815 Ok(res) => {
3816 let (mut parts, body) = res.into_parts();
3817 let mut body = common::Body::new(body);
3818 if !parts.status.is_success() {
3819 let bytes = common::to_bytes(body).await.unwrap_or_default();
3820 let error = serde_json::from_str(&common::to_string(&bytes));
3821 let response = common::to_response(parts, bytes.into());
3822
3823 if let common::Retry::After(d) =
3824 dlg.http_failure(&response, error.as_ref().ok())
3825 {
3826 sleep(d).await;
3827 continue;
3828 }
3829
3830 dlg.finished(false);
3831
3832 return Err(match error {
3833 Ok(value) => common::Error::BadRequest(value),
3834 _ => common::Error::Failure(response),
3835 });
3836 }
3837 let response = {
3838 let bytes = common::to_bytes(body).await.unwrap_or_default();
3839 let encoded = common::to_string(&bytes);
3840 match serde_json::from_str(&encoded) {
3841 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3842 Err(error) => {
3843 dlg.response_json_decode_error(&encoded, &error);
3844 return Err(common::Error::JsonDecodeError(
3845 encoded.to_string(),
3846 error,
3847 ));
3848 }
3849 }
3850 };
3851
3852 dlg.finished(true);
3853 return Ok(response);
3854 }
3855 }
3856 }
3857 }
3858
3859 /// Required. The name of the schema revision to be deleted, with a revision ID explicitly included. Example: `projects/123/schemas/my-schema@c7cfa2a8`
3860 ///
3861 /// Sets the *name* path property to the given value.
3862 ///
3863 /// Even though the property as already been set when instantiating this call,
3864 /// we provide this method for API completeness.
3865 pub fn name(mut self, new_value: &str) -> ProjectSchemaDeleteRevisionCall<'a, C> {
3866 self._name = new_value.to_string();
3867 self
3868 }
3869 /// Optional. This field is deprecated and should not be used for specifying the revision ID. The revision ID should be specified via the `name` parameter.
3870 ///
3871 /// Sets the *revision id* query property to the given value.
3872 pub fn revision_id(mut self, new_value: &str) -> ProjectSchemaDeleteRevisionCall<'a, C> {
3873 self._revision_id = Some(new_value.to_string());
3874 self
3875 }
3876 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3877 /// while executing the actual API request.
3878 ///
3879 /// ````text
3880 /// It should be used to handle progress information, and to implement a certain level of resilience.
3881 /// ````
3882 ///
3883 /// Sets the *delegate* property to the given value.
3884 pub fn delegate(
3885 mut self,
3886 new_value: &'a mut dyn common::Delegate,
3887 ) -> ProjectSchemaDeleteRevisionCall<'a, C> {
3888 self._delegate = Some(new_value);
3889 self
3890 }
3891
3892 /// Set any additional parameter of the query string used in the request.
3893 /// It should be used to set parameters which are not yet available through their own
3894 /// setters.
3895 ///
3896 /// Please note that this method must not be used to set any of the known parameters
3897 /// which have their own setter method. If done anyway, the request will fail.
3898 ///
3899 /// # Additional Parameters
3900 ///
3901 /// * *$.xgafv* (query-string) - V1 error format.
3902 /// * *access_token* (query-string) - OAuth access token.
3903 /// * *alt* (query-string) - Data format for response.
3904 /// * *callback* (query-string) - JSONP
3905 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3906 /// * *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.
3907 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3908 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3909 /// * *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.
3910 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3911 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3912 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaDeleteRevisionCall<'a, C>
3913 where
3914 T: AsRef<str>,
3915 {
3916 self._additional_params
3917 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3918 self
3919 }
3920
3921 /// Identifies the authorization scope for the method you are building.
3922 ///
3923 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3924 /// [`Scope::CloudPlatform`].
3925 ///
3926 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3927 /// tokens for more than one scope.
3928 ///
3929 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3930 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3931 /// sufficient, a read-write scope will do as well.
3932 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaDeleteRevisionCall<'a, C>
3933 where
3934 St: AsRef<str>,
3935 {
3936 self._scopes.insert(String::from(scope.as_ref()));
3937 self
3938 }
3939 /// Identifies the authorization scope(s) for the method you are building.
3940 ///
3941 /// See [`Self::add_scope()`] for details.
3942 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaDeleteRevisionCall<'a, C>
3943 where
3944 I: IntoIterator<Item = St>,
3945 St: AsRef<str>,
3946 {
3947 self._scopes
3948 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3949 self
3950 }
3951
3952 /// Removes all scopes, and no default scope will be used either.
3953 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3954 /// for details).
3955 pub fn clear_scopes(mut self) -> ProjectSchemaDeleteRevisionCall<'a, C> {
3956 self._scopes.clear();
3957 self
3958 }
3959}
3960
3961/// Gets a schema.
3962///
3963/// A builder for the *schemas.get* method supported by a *project* resource.
3964/// It is not used directly, but through a [`ProjectMethods`] instance.
3965///
3966/// # Example
3967///
3968/// Instantiate a resource method builder
3969///
3970/// ```test_harness,no_run
3971/// # extern crate hyper;
3972/// # extern crate hyper_rustls;
3973/// # extern crate google_pubsub1 as pubsub1;
3974/// # async fn dox() {
3975/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3976///
3977/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3978/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3979/// # .with_native_roots()
3980/// # .unwrap()
3981/// # .https_only()
3982/// # .enable_http2()
3983/// # .build();
3984///
3985/// # let executor = hyper_util::rt::TokioExecutor::new();
3986/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3987/// # secret,
3988/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3989/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3990/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3991/// # ),
3992/// # ).build().await.unwrap();
3993///
3994/// # let client = hyper_util::client::legacy::Client::builder(
3995/// # hyper_util::rt::TokioExecutor::new()
3996/// # )
3997/// # .build(
3998/// # hyper_rustls::HttpsConnectorBuilder::new()
3999/// # .with_native_roots()
4000/// # .unwrap()
4001/// # .https_or_http()
4002/// # .enable_http2()
4003/// # .build()
4004/// # );
4005/// # let mut hub = Pubsub::new(client, auth);
4006/// // You can configure optional parameters by calling the respective setters at will, and
4007/// // execute the final call using `doit()`.
4008/// // Values shown here are possibly random and not representative !
4009/// let result = hub.projects().schemas_get("name")
4010/// .view("gubergren")
4011/// .doit().await;
4012/// # }
4013/// ```
4014pub struct ProjectSchemaGetCall<'a, C>
4015where
4016 C: 'a,
4017{
4018 hub: &'a Pubsub<C>,
4019 _name: String,
4020 _view: Option<String>,
4021 _delegate: Option<&'a mut dyn common::Delegate>,
4022 _additional_params: HashMap<String, String>,
4023 _scopes: BTreeSet<String>,
4024}
4025
4026impl<'a, C> common::CallBuilder for ProjectSchemaGetCall<'a, C> {}
4027
4028impl<'a, C> ProjectSchemaGetCall<'a, C>
4029where
4030 C: common::Connector,
4031{
4032 /// Perform the operation you have build so far.
4033 pub async fn doit(mut self) -> common::Result<(common::Response, Schema)> {
4034 use std::borrow::Cow;
4035 use std::io::{Read, Seek};
4036
4037 use common::{url::Params, ToParts};
4038 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4039
4040 let mut dd = common::DefaultDelegate;
4041 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4042 dlg.begin(common::MethodInfo {
4043 id: "pubsub.projects.schemas.get",
4044 http_method: hyper::Method::GET,
4045 });
4046
4047 for &field in ["alt", "name", "view"].iter() {
4048 if self._additional_params.contains_key(field) {
4049 dlg.finished(false);
4050 return Err(common::Error::FieldClash(field));
4051 }
4052 }
4053
4054 let mut params = Params::with_capacity(4 + self._additional_params.len());
4055 params.push("name", self._name);
4056 if let Some(value) = self._view.as_ref() {
4057 params.push("view", value);
4058 }
4059
4060 params.extend(self._additional_params.iter());
4061
4062 params.push("alt", "json");
4063 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4064 if self._scopes.is_empty() {
4065 self._scopes
4066 .insert(Scope::CloudPlatform.as_ref().to_string());
4067 }
4068
4069 #[allow(clippy::single_element_loop)]
4070 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4071 url = params.uri_replacement(url, param_name, find_this, true);
4072 }
4073 {
4074 let to_remove = ["name"];
4075 params.remove_params(&to_remove);
4076 }
4077
4078 let url = params.parse_with_url(&url);
4079
4080 loop {
4081 let token = match self
4082 .hub
4083 .auth
4084 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4085 .await
4086 {
4087 Ok(token) => token,
4088 Err(e) => match dlg.token(e) {
4089 Ok(token) => token,
4090 Err(e) => {
4091 dlg.finished(false);
4092 return Err(common::Error::MissingToken(e));
4093 }
4094 },
4095 };
4096 let mut req_result = {
4097 let client = &self.hub.client;
4098 dlg.pre_request();
4099 let mut req_builder = hyper::Request::builder()
4100 .method(hyper::Method::GET)
4101 .uri(url.as_str())
4102 .header(USER_AGENT, self.hub._user_agent.clone());
4103
4104 if let Some(token) = token.as_ref() {
4105 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4106 }
4107
4108 let request = req_builder
4109 .header(CONTENT_LENGTH, 0_u64)
4110 .body(common::to_body::<String>(None));
4111
4112 client.request(request.unwrap()).await
4113 };
4114
4115 match req_result {
4116 Err(err) => {
4117 if let common::Retry::After(d) = dlg.http_error(&err) {
4118 sleep(d).await;
4119 continue;
4120 }
4121 dlg.finished(false);
4122 return Err(common::Error::HttpError(err));
4123 }
4124 Ok(res) => {
4125 let (mut parts, body) = res.into_parts();
4126 let mut body = common::Body::new(body);
4127 if !parts.status.is_success() {
4128 let bytes = common::to_bytes(body).await.unwrap_or_default();
4129 let error = serde_json::from_str(&common::to_string(&bytes));
4130 let response = common::to_response(parts, bytes.into());
4131
4132 if let common::Retry::After(d) =
4133 dlg.http_failure(&response, error.as_ref().ok())
4134 {
4135 sleep(d).await;
4136 continue;
4137 }
4138
4139 dlg.finished(false);
4140
4141 return Err(match error {
4142 Ok(value) => common::Error::BadRequest(value),
4143 _ => common::Error::Failure(response),
4144 });
4145 }
4146 let response = {
4147 let bytes = common::to_bytes(body).await.unwrap_or_default();
4148 let encoded = common::to_string(&bytes);
4149 match serde_json::from_str(&encoded) {
4150 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4151 Err(error) => {
4152 dlg.response_json_decode_error(&encoded, &error);
4153 return Err(common::Error::JsonDecodeError(
4154 encoded.to_string(),
4155 error,
4156 ));
4157 }
4158 }
4159 };
4160
4161 dlg.finished(true);
4162 return Ok(response);
4163 }
4164 }
4165 }
4166 }
4167
4168 /// Required. The name of the schema to get. Format is `projects/{project}/schemas/{schema}`.
4169 ///
4170 /// Sets the *name* path property to the given value.
4171 ///
4172 /// Even though the property as already been set when instantiating this call,
4173 /// we provide this method for API completeness.
4174 pub fn name(mut self, new_value: &str) -> ProjectSchemaGetCall<'a, C> {
4175 self._name = new_value.to_string();
4176 self
4177 }
4178 /// The set of fields to return in the response. If not set, returns a Schema with all fields filled out. Set to `BASIC` to omit the `definition`.
4179 ///
4180 /// Sets the *view* query property to the given value.
4181 pub fn view(mut self, new_value: &str) -> ProjectSchemaGetCall<'a, C> {
4182 self._view = Some(new_value.to_string());
4183 self
4184 }
4185 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4186 /// while executing the actual API request.
4187 ///
4188 /// ````text
4189 /// It should be used to handle progress information, and to implement a certain level of resilience.
4190 /// ````
4191 ///
4192 /// Sets the *delegate* property to the given value.
4193 pub fn delegate(
4194 mut self,
4195 new_value: &'a mut dyn common::Delegate,
4196 ) -> ProjectSchemaGetCall<'a, C> {
4197 self._delegate = Some(new_value);
4198 self
4199 }
4200
4201 /// Set any additional parameter of the query string used in the request.
4202 /// It should be used to set parameters which are not yet available through their own
4203 /// setters.
4204 ///
4205 /// Please note that this method must not be used to set any of the known parameters
4206 /// which have their own setter method. If done anyway, the request will fail.
4207 ///
4208 /// # Additional Parameters
4209 ///
4210 /// * *$.xgafv* (query-string) - V1 error format.
4211 /// * *access_token* (query-string) - OAuth access token.
4212 /// * *alt* (query-string) - Data format for response.
4213 /// * *callback* (query-string) - JSONP
4214 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4215 /// * *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.
4216 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4217 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4218 /// * *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.
4219 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4220 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4221 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaGetCall<'a, C>
4222 where
4223 T: AsRef<str>,
4224 {
4225 self._additional_params
4226 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4227 self
4228 }
4229
4230 /// Identifies the authorization scope for the method you are building.
4231 ///
4232 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4233 /// [`Scope::CloudPlatform`].
4234 ///
4235 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4236 /// tokens for more than one scope.
4237 ///
4238 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4239 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4240 /// sufficient, a read-write scope will do as well.
4241 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaGetCall<'a, C>
4242 where
4243 St: AsRef<str>,
4244 {
4245 self._scopes.insert(String::from(scope.as_ref()));
4246 self
4247 }
4248 /// Identifies the authorization scope(s) for the method you are building.
4249 ///
4250 /// See [`Self::add_scope()`] for details.
4251 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaGetCall<'a, C>
4252 where
4253 I: IntoIterator<Item = St>,
4254 St: AsRef<str>,
4255 {
4256 self._scopes
4257 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4258 self
4259 }
4260
4261 /// Removes all scopes, and no default scope will be used either.
4262 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4263 /// for details).
4264 pub fn clear_scopes(mut self) -> ProjectSchemaGetCall<'a, C> {
4265 self._scopes.clear();
4266 self
4267 }
4268}
4269
4270/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
4271///
4272/// A builder for the *schemas.getIamPolicy* method supported by a *project* resource.
4273/// It is not used directly, but through a [`ProjectMethods`] instance.
4274///
4275/// # Example
4276///
4277/// Instantiate a resource method builder
4278///
4279/// ```test_harness,no_run
4280/// # extern crate hyper;
4281/// # extern crate hyper_rustls;
4282/// # extern crate google_pubsub1 as pubsub1;
4283/// # async fn dox() {
4284/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4285///
4286/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4287/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4288/// # .with_native_roots()
4289/// # .unwrap()
4290/// # .https_only()
4291/// # .enable_http2()
4292/// # .build();
4293///
4294/// # let executor = hyper_util::rt::TokioExecutor::new();
4295/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4296/// # secret,
4297/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4298/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4299/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4300/// # ),
4301/// # ).build().await.unwrap();
4302///
4303/// # let client = hyper_util::client::legacy::Client::builder(
4304/// # hyper_util::rt::TokioExecutor::new()
4305/// # )
4306/// # .build(
4307/// # hyper_rustls::HttpsConnectorBuilder::new()
4308/// # .with_native_roots()
4309/// # .unwrap()
4310/// # .https_or_http()
4311/// # .enable_http2()
4312/// # .build()
4313/// # );
4314/// # let mut hub = Pubsub::new(client, auth);
4315/// // You can configure optional parameters by calling the respective setters at will, and
4316/// // execute the final call using `doit()`.
4317/// // Values shown here are possibly random and not representative !
4318/// let result = hub.projects().schemas_get_iam_policy("resource")
4319/// .options_requested_policy_version(-12)
4320/// .doit().await;
4321/// # }
4322/// ```
4323pub struct ProjectSchemaGetIamPolicyCall<'a, C>
4324where
4325 C: 'a,
4326{
4327 hub: &'a Pubsub<C>,
4328 _resource: String,
4329 _options_requested_policy_version: Option<i32>,
4330 _delegate: Option<&'a mut dyn common::Delegate>,
4331 _additional_params: HashMap<String, String>,
4332 _scopes: BTreeSet<String>,
4333}
4334
4335impl<'a, C> common::CallBuilder for ProjectSchemaGetIamPolicyCall<'a, C> {}
4336
4337impl<'a, C> ProjectSchemaGetIamPolicyCall<'a, C>
4338where
4339 C: common::Connector,
4340{
4341 /// Perform the operation you have build so far.
4342 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4343 use std::borrow::Cow;
4344 use std::io::{Read, Seek};
4345
4346 use common::{url::Params, ToParts};
4347 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4348
4349 let mut dd = common::DefaultDelegate;
4350 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4351 dlg.begin(common::MethodInfo {
4352 id: "pubsub.projects.schemas.getIamPolicy",
4353 http_method: hyper::Method::GET,
4354 });
4355
4356 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
4357 if self._additional_params.contains_key(field) {
4358 dlg.finished(false);
4359 return Err(common::Error::FieldClash(field));
4360 }
4361 }
4362
4363 let mut params = Params::with_capacity(4 + self._additional_params.len());
4364 params.push("resource", self._resource);
4365 if let Some(value) = self._options_requested_policy_version.as_ref() {
4366 params.push("options.requestedPolicyVersion", value.to_string());
4367 }
4368
4369 params.extend(self._additional_params.iter());
4370
4371 params.push("alt", "json");
4372 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
4373 if self._scopes.is_empty() {
4374 self._scopes
4375 .insert(Scope::CloudPlatform.as_ref().to_string());
4376 }
4377
4378 #[allow(clippy::single_element_loop)]
4379 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4380 url = params.uri_replacement(url, param_name, find_this, true);
4381 }
4382 {
4383 let to_remove = ["resource"];
4384 params.remove_params(&to_remove);
4385 }
4386
4387 let url = params.parse_with_url(&url);
4388
4389 loop {
4390 let token = match self
4391 .hub
4392 .auth
4393 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4394 .await
4395 {
4396 Ok(token) => token,
4397 Err(e) => match dlg.token(e) {
4398 Ok(token) => token,
4399 Err(e) => {
4400 dlg.finished(false);
4401 return Err(common::Error::MissingToken(e));
4402 }
4403 },
4404 };
4405 let mut req_result = {
4406 let client = &self.hub.client;
4407 dlg.pre_request();
4408 let mut req_builder = hyper::Request::builder()
4409 .method(hyper::Method::GET)
4410 .uri(url.as_str())
4411 .header(USER_AGENT, self.hub._user_agent.clone());
4412
4413 if let Some(token) = token.as_ref() {
4414 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4415 }
4416
4417 let request = req_builder
4418 .header(CONTENT_LENGTH, 0_u64)
4419 .body(common::to_body::<String>(None));
4420
4421 client.request(request.unwrap()).await
4422 };
4423
4424 match req_result {
4425 Err(err) => {
4426 if let common::Retry::After(d) = dlg.http_error(&err) {
4427 sleep(d).await;
4428 continue;
4429 }
4430 dlg.finished(false);
4431 return Err(common::Error::HttpError(err));
4432 }
4433 Ok(res) => {
4434 let (mut parts, body) = res.into_parts();
4435 let mut body = common::Body::new(body);
4436 if !parts.status.is_success() {
4437 let bytes = common::to_bytes(body).await.unwrap_or_default();
4438 let error = serde_json::from_str(&common::to_string(&bytes));
4439 let response = common::to_response(parts, bytes.into());
4440
4441 if let common::Retry::After(d) =
4442 dlg.http_failure(&response, error.as_ref().ok())
4443 {
4444 sleep(d).await;
4445 continue;
4446 }
4447
4448 dlg.finished(false);
4449
4450 return Err(match error {
4451 Ok(value) => common::Error::BadRequest(value),
4452 _ => common::Error::Failure(response),
4453 });
4454 }
4455 let response = {
4456 let bytes = common::to_bytes(body).await.unwrap_or_default();
4457 let encoded = common::to_string(&bytes);
4458 match serde_json::from_str(&encoded) {
4459 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4460 Err(error) => {
4461 dlg.response_json_decode_error(&encoded, &error);
4462 return Err(common::Error::JsonDecodeError(
4463 encoded.to_string(),
4464 error,
4465 ));
4466 }
4467 }
4468 };
4469
4470 dlg.finished(true);
4471 return Ok(response);
4472 }
4473 }
4474 }
4475 }
4476
4477 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
4478 ///
4479 /// Sets the *resource* path property to the given value.
4480 ///
4481 /// Even though the property as already been set when instantiating this call,
4482 /// we provide this method for API completeness.
4483 pub fn resource(mut self, new_value: &str) -> ProjectSchemaGetIamPolicyCall<'a, C> {
4484 self._resource = new_value.to_string();
4485 self
4486 }
4487 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
4488 ///
4489 /// Sets the *options.requested policy version* query property to the given value.
4490 pub fn options_requested_policy_version(
4491 mut self,
4492 new_value: i32,
4493 ) -> ProjectSchemaGetIamPolicyCall<'a, C> {
4494 self._options_requested_policy_version = Some(new_value);
4495 self
4496 }
4497 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4498 /// while executing the actual API request.
4499 ///
4500 /// ````text
4501 /// It should be used to handle progress information, and to implement a certain level of resilience.
4502 /// ````
4503 ///
4504 /// Sets the *delegate* property to the given value.
4505 pub fn delegate(
4506 mut self,
4507 new_value: &'a mut dyn common::Delegate,
4508 ) -> ProjectSchemaGetIamPolicyCall<'a, C> {
4509 self._delegate = Some(new_value);
4510 self
4511 }
4512
4513 /// Set any additional parameter of the query string used in the request.
4514 /// It should be used to set parameters which are not yet available through their own
4515 /// setters.
4516 ///
4517 /// Please note that this method must not be used to set any of the known parameters
4518 /// which have their own setter method. If done anyway, the request will fail.
4519 ///
4520 /// # Additional Parameters
4521 ///
4522 /// * *$.xgafv* (query-string) - V1 error format.
4523 /// * *access_token* (query-string) - OAuth access token.
4524 /// * *alt* (query-string) - Data format for response.
4525 /// * *callback* (query-string) - JSONP
4526 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4527 /// * *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.
4528 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4529 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4530 /// * *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.
4531 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4532 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4533 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaGetIamPolicyCall<'a, C>
4534 where
4535 T: AsRef<str>,
4536 {
4537 self._additional_params
4538 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4539 self
4540 }
4541
4542 /// Identifies the authorization scope for the method you are building.
4543 ///
4544 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4545 /// [`Scope::CloudPlatform`].
4546 ///
4547 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4548 /// tokens for more than one scope.
4549 ///
4550 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4551 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4552 /// sufficient, a read-write scope will do as well.
4553 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaGetIamPolicyCall<'a, C>
4554 where
4555 St: AsRef<str>,
4556 {
4557 self._scopes.insert(String::from(scope.as_ref()));
4558 self
4559 }
4560 /// Identifies the authorization scope(s) for the method you are building.
4561 ///
4562 /// See [`Self::add_scope()`] for details.
4563 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaGetIamPolicyCall<'a, C>
4564 where
4565 I: IntoIterator<Item = St>,
4566 St: AsRef<str>,
4567 {
4568 self._scopes
4569 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4570 self
4571 }
4572
4573 /// Removes all scopes, and no default scope will be used either.
4574 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4575 /// for details).
4576 pub fn clear_scopes(mut self) -> ProjectSchemaGetIamPolicyCall<'a, C> {
4577 self._scopes.clear();
4578 self
4579 }
4580}
4581
4582/// Lists schemas in a project.
4583///
4584/// A builder for the *schemas.list* method supported by a *project* resource.
4585/// It is not used directly, but through a [`ProjectMethods`] instance.
4586///
4587/// # Example
4588///
4589/// Instantiate a resource method builder
4590///
4591/// ```test_harness,no_run
4592/// # extern crate hyper;
4593/// # extern crate hyper_rustls;
4594/// # extern crate google_pubsub1 as pubsub1;
4595/// # async fn dox() {
4596/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4597///
4598/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4599/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4600/// # .with_native_roots()
4601/// # .unwrap()
4602/// # .https_only()
4603/// # .enable_http2()
4604/// # .build();
4605///
4606/// # let executor = hyper_util::rt::TokioExecutor::new();
4607/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4608/// # secret,
4609/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4610/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4611/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4612/// # ),
4613/// # ).build().await.unwrap();
4614///
4615/// # let client = hyper_util::client::legacy::Client::builder(
4616/// # hyper_util::rt::TokioExecutor::new()
4617/// # )
4618/// # .build(
4619/// # hyper_rustls::HttpsConnectorBuilder::new()
4620/// # .with_native_roots()
4621/// # .unwrap()
4622/// # .https_or_http()
4623/// # .enable_http2()
4624/// # .build()
4625/// # );
4626/// # let mut hub = Pubsub::new(client, auth);
4627/// // You can configure optional parameters by calling the respective setters at will, and
4628/// // execute the final call using `doit()`.
4629/// // Values shown here are possibly random and not representative !
4630/// let result = hub.projects().schemas_list("parent")
4631/// .view("dolor")
4632/// .page_token("ea")
4633/// .page_size(-55)
4634/// .doit().await;
4635/// # }
4636/// ```
4637pub struct ProjectSchemaListCall<'a, C>
4638where
4639 C: 'a,
4640{
4641 hub: &'a Pubsub<C>,
4642 _parent: String,
4643 _view: Option<String>,
4644 _page_token: Option<String>,
4645 _page_size: Option<i32>,
4646 _delegate: Option<&'a mut dyn common::Delegate>,
4647 _additional_params: HashMap<String, String>,
4648 _scopes: BTreeSet<String>,
4649}
4650
4651impl<'a, C> common::CallBuilder for ProjectSchemaListCall<'a, C> {}
4652
4653impl<'a, C> ProjectSchemaListCall<'a, C>
4654where
4655 C: common::Connector,
4656{
4657 /// Perform the operation you have build so far.
4658 pub async fn doit(mut self) -> common::Result<(common::Response, ListSchemasResponse)> {
4659 use std::borrow::Cow;
4660 use std::io::{Read, Seek};
4661
4662 use common::{url::Params, ToParts};
4663 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4664
4665 let mut dd = common::DefaultDelegate;
4666 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4667 dlg.begin(common::MethodInfo {
4668 id: "pubsub.projects.schemas.list",
4669 http_method: hyper::Method::GET,
4670 });
4671
4672 for &field in ["alt", "parent", "view", "pageToken", "pageSize"].iter() {
4673 if self._additional_params.contains_key(field) {
4674 dlg.finished(false);
4675 return Err(common::Error::FieldClash(field));
4676 }
4677 }
4678
4679 let mut params = Params::with_capacity(6 + self._additional_params.len());
4680 params.push("parent", self._parent);
4681 if let Some(value) = self._view.as_ref() {
4682 params.push("view", value);
4683 }
4684 if let Some(value) = self._page_token.as_ref() {
4685 params.push("pageToken", value);
4686 }
4687 if let Some(value) = self._page_size.as_ref() {
4688 params.push("pageSize", value.to_string());
4689 }
4690
4691 params.extend(self._additional_params.iter());
4692
4693 params.push("alt", "json");
4694 let mut url = self.hub._base_url.clone() + "v1/{+parent}/schemas";
4695 if self._scopes.is_empty() {
4696 self._scopes
4697 .insert(Scope::CloudPlatform.as_ref().to_string());
4698 }
4699
4700 #[allow(clippy::single_element_loop)]
4701 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4702 url = params.uri_replacement(url, param_name, find_this, true);
4703 }
4704 {
4705 let to_remove = ["parent"];
4706 params.remove_params(&to_remove);
4707 }
4708
4709 let url = params.parse_with_url(&url);
4710
4711 loop {
4712 let token = match self
4713 .hub
4714 .auth
4715 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4716 .await
4717 {
4718 Ok(token) => token,
4719 Err(e) => match dlg.token(e) {
4720 Ok(token) => token,
4721 Err(e) => {
4722 dlg.finished(false);
4723 return Err(common::Error::MissingToken(e));
4724 }
4725 },
4726 };
4727 let mut req_result = {
4728 let client = &self.hub.client;
4729 dlg.pre_request();
4730 let mut req_builder = hyper::Request::builder()
4731 .method(hyper::Method::GET)
4732 .uri(url.as_str())
4733 .header(USER_AGENT, self.hub._user_agent.clone());
4734
4735 if let Some(token) = token.as_ref() {
4736 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4737 }
4738
4739 let request = req_builder
4740 .header(CONTENT_LENGTH, 0_u64)
4741 .body(common::to_body::<String>(None));
4742
4743 client.request(request.unwrap()).await
4744 };
4745
4746 match req_result {
4747 Err(err) => {
4748 if let common::Retry::After(d) = dlg.http_error(&err) {
4749 sleep(d).await;
4750 continue;
4751 }
4752 dlg.finished(false);
4753 return Err(common::Error::HttpError(err));
4754 }
4755 Ok(res) => {
4756 let (mut parts, body) = res.into_parts();
4757 let mut body = common::Body::new(body);
4758 if !parts.status.is_success() {
4759 let bytes = common::to_bytes(body).await.unwrap_or_default();
4760 let error = serde_json::from_str(&common::to_string(&bytes));
4761 let response = common::to_response(parts, bytes.into());
4762
4763 if let common::Retry::After(d) =
4764 dlg.http_failure(&response, error.as_ref().ok())
4765 {
4766 sleep(d).await;
4767 continue;
4768 }
4769
4770 dlg.finished(false);
4771
4772 return Err(match error {
4773 Ok(value) => common::Error::BadRequest(value),
4774 _ => common::Error::Failure(response),
4775 });
4776 }
4777 let response = {
4778 let bytes = common::to_bytes(body).await.unwrap_or_default();
4779 let encoded = common::to_string(&bytes);
4780 match serde_json::from_str(&encoded) {
4781 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4782 Err(error) => {
4783 dlg.response_json_decode_error(&encoded, &error);
4784 return Err(common::Error::JsonDecodeError(
4785 encoded.to_string(),
4786 error,
4787 ));
4788 }
4789 }
4790 };
4791
4792 dlg.finished(true);
4793 return Ok(response);
4794 }
4795 }
4796 }
4797 }
4798
4799 /// Required. The name of the project in which to list schemas. Format is `projects/{project-id}`.
4800 ///
4801 /// Sets the *parent* path property to the given value.
4802 ///
4803 /// Even though the property as already been set when instantiating this call,
4804 /// we provide this method for API completeness.
4805 pub fn parent(mut self, new_value: &str) -> ProjectSchemaListCall<'a, C> {
4806 self._parent = new_value.to_string();
4807 self
4808 }
4809 /// The set of Schema fields to return in the response. If not set, returns Schemas with `name` and `type`, but not `definition`. Set to `FULL` to retrieve all fields.
4810 ///
4811 /// Sets the *view* query property to the given value.
4812 pub fn view(mut self, new_value: &str) -> ProjectSchemaListCall<'a, C> {
4813 self._view = Some(new_value.to_string());
4814 self
4815 }
4816 /// The value returned by the last `ListSchemasResponse`; indicates that this is a continuation of a prior `ListSchemas` call, and that the system should return the next page of data.
4817 ///
4818 /// Sets the *page token* query property to the given value.
4819 pub fn page_token(mut self, new_value: &str) -> ProjectSchemaListCall<'a, C> {
4820 self._page_token = Some(new_value.to_string());
4821 self
4822 }
4823 /// Maximum number of schemas to return.
4824 ///
4825 /// Sets the *page size* query property to the given value.
4826 pub fn page_size(mut self, new_value: i32) -> ProjectSchemaListCall<'a, C> {
4827 self._page_size = Some(new_value);
4828 self
4829 }
4830 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4831 /// while executing the actual API request.
4832 ///
4833 /// ````text
4834 /// It should be used to handle progress information, and to implement a certain level of resilience.
4835 /// ````
4836 ///
4837 /// Sets the *delegate* property to the given value.
4838 pub fn delegate(
4839 mut self,
4840 new_value: &'a mut dyn common::Delegate,
4841 ) -> ProjectSchemaListCall<'a, C> {
4842 self._delegate = Some(new_value);
4843 self
4844 }
4845
4846 /// Set any additional parameter of the query string used in the request.
4847 /// It should be used to set parameters which are not yet available through their own
4848 /// setters.
4849 ///
4850 /// Please note that this method must not be used to set any of the known parameters
4851 /// which have their own setter method. If done anyway, the request will fail.
4852 ///
4853 /// # Additional Parameters
4854 ///
4855 /// * *$.xgafv* (query-string) - V1 error format.
4856 /// * *access_token* (query-string) - OAuth access token.
4857 /// * *alt* (query-string) - Data format for response.
4858 /// * *callback* (query-string) - JSONP
4859 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4860 /// * *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.
4861 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4862 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4863 /// * *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.
4864 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4865 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4866 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaListCall<'a, C>
4867 where
4868 T: AsRef<str>,
4869 {
4870 self._additional_params
4871 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4872 self
4873 }
4874
4875 /// Identifies the authorization scope for the method you are building.
4876 ///
4877 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4878 /// [`Scope::CloudPlatform`].
4879 ///
4880 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4881 /// tokens for more than one scope.
4882 ///
4883 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4884 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4885 /// sufficient, a read-write scope will do as well.
4886 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaListCall<'a, C>
4887 where
4888 St: AsRef<str>,
4889 {
4890 self._scopes.insert(String::from(scope.as_ref()));
4891 self
4892 }
4893 /// Identifies the authorization scope(s) for the method you are building.
4894 ///
4895 /// See [`Self::add_scope()`] for details.
4896 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaListCall<'a, C>
4897 where
4898 I: IntoIterator<Item = St>,
4899 St: AsRef<str>,
4900 {
4901 self._scopes
4902 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4903 self
4904 }
4905
4906 /// Removes all scopes, and no default scope will be used either.
4907 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4908 /// for details).
4909 pub fn clear_scopes(mut self) -> ProjectSchemaListCall<'a, C> {
4910 self._scopes.clear();
4911 self
4912 }
4913}
4914
4915/// Lists all schema revisions for the named schema.
4916///
4917/// A builder for the *schemas.listRevisions* method supported by a *project* resource.
4918/// It is not used directly, but through a [`ProjectMethods`] instance.
4919///
4920/// # Example
4921///
4922/// Instantiate a resource method builder
4923///
4924/// ```test_harness,no_run
4925/// # extern crate hyper;
4926/// # extern crate hyper_rustls;
4927/// # extern crate google_pubsub1 as pubsub1;
4928/// # async fn dox() {
4929/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4930///
4931/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4932/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4933/// # .with_native_roots()
4934/// # .unwrap()
4935/// # .https_only()
4936/// # .enable_http2()
4937/// # .build();
4938///
4939/// # let executor = hyper_util::rt::TokioExecutor::new();
4940/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4941/// # secret,
4942/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4943/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4944/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4945/// # ),
4946/// # ).build().await.unwrap();
4947///
4948/// # let client = hyper_util::client::legacy::Client::builder(
4949/// # hyper_util::rt::TokioExecutor::new()
4950/// # )
4951/// # .build(
4952/// # hyper_rustls::HttpsConnectorBuilder::new()
4953/// # .with_native_roots()
4954/// # .unwrap()
4955/// # .https_or_http()
4956/// # .enable_http2()
4957/// # .build()
4958/// # );
4959/// # let mut hub = Pubsub::new(client, auth);
4960/// // You can configure optional parameters by calling the respective setters at will, and
4961/// // execute the final call using `doit()`.
4962/// // Values shown here are possibly random and not representative !
4963/// let result = hub.projects().schemas_list_revisions("name")
4964/// .view("amet")
4965/// .page_token("duo")
4966/// .page_size(-50)
4967/// .doit().await;
4968/// # }
4969/// ```
4970pub struct ProjectSchemaListRevisionCall<'a, C>
4971where
4972 C: 'a,
4973{
4974 hub: &'a Pubsub<C>,
4975 _name: String,
4976 _view: Option<String>,
4977 _page_token: Option<String>,
4978 _page_size: Option<i32>,
4979 _delegate: Option<&'a mut dyn common::Delegate>,
4980 _additional_params: HashMap<String, String>,
4981 _scopes: BTreeSet<String>,
4982}
4983
4984impl<'a, C> common::CallBuilder for ProjectSchemaListRevisionCall<'a, C> {}
4985
4986impl<'a, C> ProjectSchemaListRevisionCall<'a, C>
4987where
4988 C: common::Connector,
4989{
4990 /// Perform the operation you have build so far.
4991 pub async fn doit(mut self) -> common::Result<(common::Response, ListSchemaRevisionsResponse)> {
4992 use std::borrow::Cow;
4993 use std::io::{Read, Seek};
4994
4995 use common::{url::Params, ToParts};
4996 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4997
4998 let mut dd = common::DefaultDelegate;
4999 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5000 dlg.begin(common::MethodInfo {
5001 id: "pubsub.projects.schemas.listRevisions",
5002 http_method: hyper::Method::GET,
5003 });
5004
5005 for &field in ["alt", "name", "view", "pageToken", "pageSize"].iter() {
5006 if self._additional_params.contains_key(field) {
5007 dlg.finished(false);
5008 return Err(common::Error::FieldClash(field));
5009 }
5010 }
5011
5012 let mut params = Params::with_capacity(6 + self._additional_params.len());
5013 params.push("name", self._name);
5014 if let Some(value) = self._view.as_ref() {
5015 params.push("view", value);
5016 }
5017 if let Some(value) = self._page_token.as_ref() {
5018 params.push("pageToken", value);
5019 }
5020 if let Some(value) = self._page_size.as_ref() {
5021 params.push("pageSize", value.to_string());
5022 }
5023
5024 params.extend(self._additional_params.iter());
5025
5026 params.push("alt", "json");
5027 let mut url = self.hub._base_url.clone() + "v1/{+name}:listRevisions";
5028 if self._scopes.is_empty() {
5029 self._scopes
5030 .insert(Scope::CloudPlatform.as_ref().to_string());
5031 }
5032
5033 #[allow(clippy::single_element_loop)]
5034 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5035 url = params.uri_replacement(url, param_name, find_this, true);
5036 }
5037 {
5038 let to_remove = ["name"];
5039 params.remove_params(&to_remove);
5040 }
5041
5042 let url = params.parse_with_url(&url);
5043
5044 loop {
5045 let token = match self
5046 .hub
5047 .auth
5048 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5049 .await
5050 {
5051 Ok(token) => token,
5052 Err(e) => match dlg.token(e) {
5053 Ok(token) => token,
5054 Err(e) => {
5055 dlg.finished(false);
5056 return Err(common::Error::MissingToken(e));
5057 }
5058 },
5059 };
5060 let mut req_result = {
5061 let client = &self.hub.client;
5062 dlg.pre_request();
5063 let mut req_builder = hyper::Request::builder()
5064 .method(hyper::Method::GET)
5065 .uri(url.as_str())
5066 .header(USER_AGENT, self.hub._user_agent.clone());
5067
5068 if let Some(token) = token.as_ref() {
5069 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5070 }
5071
5072 let request = req_builder
5073 .header(CONTENT_LENGTH, 0_u64)
5074 .body(common::to_body::<String>(None));
5075
5076 client.request(request.unwrap()).await
5077 };
5078
5079 match req_result {
5080 Err(err) => {
5081 if let common::Retry::After(d) = dlg.http_error(&err) {
5082 sleep(d).await;
5083 continue;
5084 }
5085 dlg.finished(false);
5086 return Err(common::Error::HttpError(err));
5087 }
5088 Ok(res) => {
5089 let (mut parts, body) = res.into_parts();
5090 let mut body = common::Body::new(body);
5091 if !parts.status.is_success() {
5092 let bytes = common::to_bytes(body).await.unwrap_or_default();
5093 let error = serde_json::from_str(&common::to_string(&bytes));
5094 let response = common::to_response(parts, bytes.into());
5095
5096 if let common::Retry::After(d) =
5097 dlg.http_failure(&response, error.as_ref().ok())
5098 {
5099 sleep(d).await;
5100 continue;
5101 }
5102
5103 dlg.finished(false);
5104
5105 return Err(match error {
5106 Ok(value) => common::Error::BadRequest(value),
5107 _ => common::Error::Failure(response),
5108 });
5109 }
5110 let response = {
5111 let bytes = common::to_bytes(body).await.unwrap_or_default();
5112 let encoded = common::to_string(&bytes);
5113 match serde_json::from_str(&encoded) {
5114 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5115 Err(error) => {
5116 dlg.response_json_decode_error(&encoded, &error);
5117 return Err(common::Error::JsonDecodeError(
5118 encoded.to_string(),
5119 error,
5120 ));
5121 }
5122 }
5123 };
5124
5125 dlg.finished(true);
5126 return Ok(response);
5127 }
5128 }
5129 }
5130 }
5131
5132 /// Required. The name of the schema to list revisions for.
5133 ///
5134 /// Sets the *name* path property to the given value.
5135 ///
5136 /// Even though the property as already been set when instantiating this call,
5137 /// we provide this method for API completeness.
5138 pub fn name(mut self, new_value: &str) -> ProjectSchemaListRevisionCall<'a, C> {
5139 self._name = new_value.to_string();
5140 self
5141 }
5142 /// The set of Schema fields to return in the response. If not set, returns Schemas with `name` and `type`, but not `definition`. Set to `FULL` to retrieve all fields.
5143 ///
5144 /// Sets the *view* query property to the given value.
5145 pub fn view(mut self, new_value: &str) -> ProjectSchemaListRevisionCall<'a, C> {
5146 self._view = Some(new_value.to_string());
5147 self
5148 }
5149 /// The page token, received from a previous ListSchemaRevisions call. Provide this to retrieve the subsequent page.
5150 ///
5151 /// Sets the *page token* query property to the given value.
5152 pub fn page_token(mut self, new_value: &str) -> ProjectSchemaListRevisionCall<'a, C> {
5153 self._page_token = Some(new_value.to_string());
5154 self
5155 }
5156 /// The maximum number of revisions to return per page.
5157 ///
5158 /// Sets the *page size* query property to the given value.
5159 pub fn page_size(mut self, new_value: i32) -> ProjectSchemaListRevisionCall<'a, C> {
5160 self._page_size = Some(new_value);
5161 self
5162 }
5163 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5164 /// while executing the actual API request.
5165 ///
5166 /// ````text
5167 /// It should be used to handle progress information, and to implement a certain level of resilience.
5168 /// ````
5169 ///
5170 /// Sets the *delegate* property to the given value.
5171 pub fn delegate(
5172 mut self,
5173 new_value: &'a mut dyn common::Delegate,
5174 ) -> ProjectSchemaListRevisionCall<'a, C> {
5175 self._delegate = Some(new_value);
5176 self
5177 }
5178
5179 /// Set any additional parameter of the query string used in the request.
5180 /// It should be used to set parameters which are not yet available through their own
5181 /// setters.
5182 ///
5183 /// Please note that this method must not be used to set any of the known parameters
5184 /// which have their own setter method. If done anyway, the request will fail.
5185 ///
5186 /// # Additional Parameters
5187 ///
5188 /// * *$.xgafv* (query-string) - V1 error format.
5189 /// * *access_token* (query-string) - OAuth access token.
5190 /// * *alt* (query-string) - Data format for response.
5191 /// * *callback* (query-string) - JSONP
5192 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5193 /// * *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.
5194 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5195 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5196 /// * *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.
5197 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5198 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5199 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaListRevisionCall<'a, C>
5200 where
5201 T: AsRef<str>,
5202 {
5203 self._additional_params
5204 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5205 self
5206 }
5207
5208 /// Identifies the authorization scope for the method you are building.
5209 ///
5210 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5211 /// [`Scope::CloudPlatform`].
5212 ///
5213 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5214 /// tokens for more than one scope.
5215 ///
5216 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5217 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5218 /// sufficient, a read-write scope will do as well.
5219 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaListRevisionCall<'a, C>
5220 where
5221 St: AsRef<str>,
5222 {
5223 self._scopes.insert(String::from(scope.as_ref()));
5224 self
5225 }
5226 /// Identifies the authorization scope(s) for the method you are building.
5227 ///
5228 /// See [`Self::add_scope()`] for details.
5229 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaListRevisionCall<'a, C>
5230 where
5231 I: IntoIterator<Item = St>,
5232 St: AsRef<str>,
5233 {
5234 self._scopes
5235 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5236 self
5237 }
5238
5239 /// Removes all scopes, and no default scope will be used either.
5240 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5241 /// for details).
5242 pub fn clear_scopes(mut self) -> ProjectSchemaListRevisionCall<'a, C> {
5243 self._scopes.clear();
5244 self
5245 }
5246}
5247
5248/// Creates a new schema revision that is a copy of the provided revision_id.
5249///
5250/// A builder for the *schemas.rollback* method supported by a *project* resource.
5251/// It is not used directly, but through a [`ProjectMethods`] instance.
5252///
5253/// # Example
5254///
5255/// Instantiate a resource method builder
5256///
5257/// ```test_harness,no_run
5258/// # extern crate hyper;
5259/// # extern crate hyper_rustls;
5260/// # extern crate google_pubsub1 as pubsub1;
5261/// use pubsub1::api::RollbackSchemaRequest;
5262/// # async fn dox() {
5263/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5264///
5265/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5266/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5267/// # .with_native_roots()
5268/// # .unwrap()
5269/// # .https_only()
5270/// # .enable_http2()
5271/// # .build();
5272///
5273/// # let executor = hyper_util::rt::TokioExecutor::new();
5274/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5275/// # secret,
5276/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5277/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5278/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5279/// # ),
5280/// # ).build().await.unwrap();
5281///
5282/// # let client = hyper_util::client::legacy::Client::builder(
5283/// # hyper_util::rt::TokioExecutor::new()
5284/// # )
5285/// # .build(
5286/// # hyper_rustls::HttpsConnectorBuilder::new()
5287/// # .with_native_roots()
5288/// # .unwrap()
5289/// # .https_or_http()
5290/// # .enable_http2()
5291/// # .build()
5292/// # );
5293/// # let mut hub = Pubsub::new(client, auth);
5294/// // As the method needs a request, you would usually fill it with the desired information
5295/// // into the respective structure. Some of the parts shown here might not be applicable !
5296/// // Values shown here are possibly random and not representative !
5297/// let mut req = RollbackSchemaRequest::default();
5298///
5299/// // You can configure optional parameters by calling the respective setters at will, and
5300/// // execute the final call using `doit()`.
5301/// // Values shown here are possibly random and not representative !
5302/// let result = hub.projects().schemas_rollback(req, "name")
5303/// .doit().await;
5304/// # }
5305/// ```
5306pub struct ProjectSchemaRollbackCall<'a, C>
5307where
5308 C: 'a,
5309{
5310 hub: &'a Pubsub<C>,
5311 _request: RollbackSchemaRequest,
5312 _name: String,
5313 _delegate: Option<&'a mut dyn common::Delegate>,
5314 _additional_params: HashMap<String, String>,
5315 _scopes: BTreeSet<String>,
5316}
5317
5318impl<'a, C> common::CallBuilder for ProjectSchemaRollbackCall<'a, C> {}
5319
5320impl<'a, C> ProjectSchemaRollbackCall<'a, C>
5321where
5322 C: common::Connector,
5323{
5324 /// Perform the operation you have build so far.
5325 pub async fn doit(mut self) -> common::Result<(common::Response, Schema)> {
5326 use std::borrow::Cow;
5327 use std::io::{Read, Seek};
5328
5329 use common::{url::Params, ToParts};
5330 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5331
5332 let mut dd = common::DefaultDelegate;
5333 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5334 dlg.begin(common::MethodInfo {
5335 id: "pubsub.projects.schemas.rollback",
5336 http_method: hyper::Method::POST,
5337 });
5338
5339 for &field in ["alt", "name"].iter() {
5340 if self._additional_params.contains_key(field) {
5341 dlg.finished(false);
5342 return Err(common::Error::FieldClash(field));
5343 }
5344 }
5345
5346 let mut params = Params::with_capacity(4 + self._additional_params.len());
5347 params.push("name", self._name);
5348
5349 params.extend(self._additional_params.iter());
5350
5351 params.push("alt", "json");
5352 let mut url = self.hub._base_url.clone() + "v1/{+name}:rollback";
5353 if self._scopes.is_empty() {
5354 self._scopes
5355 .insert(Scope::CloudPlatform.as_ref().to_string());
5356 }
5357
5358 #[allow(clippy::single_element_loop)]
5359 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5360 url = params.uri_replacement(url, param_name, find_this, true);
5361 }
5362 {
5363 let to_remove = ["name"];
5364 params.remove_params(&to_remove);
5365 }
5366
5367 let url = params.parse_with_url(&url);
5368
5369 let mut json_mime_type = mime::APPLICATION_JSON;
5370 let mut request_value_reader = {
5371 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5372 common::remove_json_null_values(&mut value);
5373 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5374 serde_json::to_writer(&mut dst, &value).unwrap();
5375 dst
5376 };
5377 let request_size = request_value_reader
5378 .seek(std::io::SeekFrom::End(0))
5379 .unwrap();
5380 request_value_reader
5381 .seek(std::io::SeekFrom::Start(0))
5382 .unwrap();
5383
5384 loop {
5385 let token = match self
5386 .hub
5387 .auth
5388 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5389 .await
5390 {
5391 Ok(token) => token,
5392 Err(e) => match dlg.token(e) {
5393 Ok(token) => token,
5394 Err(e) => {
5395 dlg.finished(false);
5396 return Err(common::Error::MissingToken(e));
5397 }
5398 },
5399 };
5400 request_value_reader
5401 .seek(std::io::SeekFrom::Start(0))
5402 .unwrap();
5403 let mut req_result = {
5404 let client = &self.hub.client;
5405 dlg.pre_request();
5406 let mut req_builder = hyper::Request::builder()
5407 .method(hyper::Method::POST)
5408 .uri(url.as_str())
5409 .header(USER_AGENT, self.hub._user_agent.clone());
5410
5411 if let Some(token) = token.as_ref() {
5412 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5413 }
5414
5415 let request = req_builder
5416 .header(CONTENT_TYPE, json_mime_type.to_string())
5417 .header(CONTENT_LENGTH, request_size as u64)
5418 .body(common::to_body(
5419 request_value_reader.get_ref().clone().into(),
5420 ));
5421
5422 client.request(request.unwrap()).await
5423 };
5424
5425 match req_result {
5426 Err(err) => {
5427 if let common::Retry::After(d) = dlg.http_error(&err) {
5428 sleep(d).await;
5429 continue;
5430 }
5431 dlg.finished(false);
5432 return Err(common::Error::HttpError(err));
5433 }
5434 Ok(res) => {
5435 let (mut parts, body) = res.into_parts();
5436 let mut body = common::Body::new(body);
5437 if !parts.status.is_success() {
5438 let bytes = common::to_bytes(body).await.unwrap_or_default();
5439 let error = serde_json::from_str(&common::to_string(&bytes));
5440 let response = common::to_response(parts, bytes.into());
5441
5442 if let common::Retry::After(d) =
5443 dlg.http_failure(&response, error.as_ref().ok())
5444 {
5445 sleep(d).await;
5446 continue;
5447 }
5448
5449 dlg.finished(false);
5450
5451 return Err(match error {
5452 Ok(value) => common::Error::BadRequest(value),
5453 _ => common::Error::Failure(response),
5454 });
5455 }
5456 let response = {
5457 let bytes = common::to_bytes(body).await.unwrap_or_default();
5458 let encoded = common::to_string(&bytes);
5459 match serde_json::from_str(&encoded) {
5460 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5461 Err(error) => {
5462 dlg.response_json_decode_error(&encoded, &error);
5463 return Err(common::Error::JsonDecodeError(
5464 encoded.to_string(),
5465 error,
5466 ));
5467 }
5468 }
5469 };
5470
5471 dlg.finished(true);
5472 return Ok(response);
5473 }
5474 }
5475 }
5476 }
5477
5478 ///
5479 /// Sets the *request* property to the given value.
5480 ///
5481 /// Even though the property as already been set when instantiating this call,
5482 /// we provide this method for API completeness.
5483 pub fn request(mut self, new_value: RollbackSchemaRequest) -> ProjectSchemaRollbackCall<'a, C> {
5484 self._request = new_value;
5485 self
5486 }
5487 /// Required. The schema being rolled back with revision id.
5488 ///
5489 /// Sets the *name* path property to the given value.
5490 ///
5491 /// Even though the property as already been set when instantiating this call,
5492 /// we provide this method for API completeness.
5493 pub fn name(mut self, new_value: &str) -> ProjectSchemaRollbackCall<'a, C> {
5494 self._name = new_value.to_string();
5495 self
5496 }
5497 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5498 /// while executing the actual API request.
5499 ///
5500 /// ````text
5501 /// It should be used to handle progress information, and to implement a certain level of resilience.
5502 /// ````
5503 ///
5504 /// Sets the *delegate* property to the given value.
5505 pub fn delegate(
5506 mut self,
5507 new_value: &'a mut dyn common::Delegate,
5508 ) -> ProjectSchemaRollbackCall<'a, C> {
5509 self._delegate = Some(new_value);
5510 self
5511 }
5512
5513 /// Set any additional parameter of the query string used in the request.
5514 /// It should be used to set parameters which are not yet available through their own
5515 /// setters.
5516 ///
5517 /// Please note that this method must not be used to set any of the known parameters
5518 /// which have their own setter method. If done anyway, the request will fail.
5519 ///
5520 /// # Additional Parameters
5521 ///
5522 /// * *$.xgafv* (query-string) - V1 error format.
5523 /// * *access_token* (query-string) - OAuth access token.
5524 /// * *alt* (query-string) - Data format for response.
5525 /// * *callback* (query-string) - JSONP
5526 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5527 /// * *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.
5528 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5529 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5530 /// * *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.
5531 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5532 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5533 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaRollbackCall<'a, C>
5534 where
5535 T: AsRef<str>,
5536 {
5537 self._additional_params
5538 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5539 self
5540 }
5541
5542 /// Identifies the authorization scope for the method you are building.
5543 ///
5544 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5545 /// [`Scope::CloudPlatform`].
5546 ///
5547 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5548 /// tokens for more than one scope.
5549 ///
5550 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5551 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5552 /// sufficient, a read-write scope will do as well.
5553 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaRollbackCall<'a, C>
5554 where
5555 St: AsRef<str>,
5556 {
5557 self._scopes.insert(String::from(scope.as_ref()));
5558 self
5559 }
5560 /// Identifies the authorization scope(s) for the method you are building.
5561 ///
5562 /// See [`Self::add_scope()`] for details.
5563 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaRollbackCall<'a, C>
5564 where
5565 I: IntoIterator<Item = St>,
5566 St: AsRef<str>,
5567 {
5568 self._scopes
5569 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5570 self
5571 }
5572
5573 /// Removes all scopes, and no default scope will be used either.
5574 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5575 /// for details).
5576 pub fn clear_scopes(mut self) -> ProjectSchemaRollbackCall<'a, C> {
5577 self._scopes.clear();
5578 self
5579 }
5580}
5581
5582/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
5583///
5584/// A builder for the *schemas.setIamPolicy* method supported by a *project* resource.
5585/// It is not used directly, but through a [`ProjectMethods`] instance.
5586///
5587/// # Example
5588///
5589/// Instantiate a resource method builder
5590///
5591/// ```test_harness,no_run
5592/// # extern crate hyper;
5593/// # extern crate hyper_rustls;
5594/// # extern crate google_pubsub1 as pubsub1;
5595/// use pubsub1::api::SetIamPolicyRequest;
5596/// # async fn dox() {
5597/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5598///
5599/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5600/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5601/// # .with_native_roots()
5602/// # .unwrap()
5603/// # .https_only()
5604/// # .enable_http2()
5605/// # .build();
5606///
5607/// # let executor = hyper_util::rt::TokioExecutor::new();
5608/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5609/// # secret,
5610/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5611/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5612/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5613/// # ),
5614/// # ).build().await.unwrap();
5615///
5616/// # let client = hyper_util::client::legacy::Client::builder(
5617/// # hyper_util::rt::TokioExecutor::new()
5618/// # )
5619/// # .build(
5620/// # hyper_rustls::HttpsConnectorBuilder::new()
5621/// # .with_native_roots()
5622/// # .unwrap()
5623/// # .https_or_http()
5624/// # .enable_http2()
5625/// # .build()
5626/// # );
5627/// # let mut hub = Pubsub::new(client, auth);
5628/// // As the method needs a request, you would usually fill it with the desired information
5629/// // into the respective structure. Some of the parts shown here might not be applicable !
5630/// // Values shown here are possibly random and not representative !
5631/// let mut req = SetIamPolicyRequest::default();
5632///
5633/// // You can configure optional parameters by calling the respective setters at will, and
5634/// // execute the final call using `doit()`.
5635/// // Values shown here are possibly random and not representative !
5636/// let result = hub.projects().schemas_set_iam_policy(req, "resource")
5637/// .doit().await;
5638/// # }
5639/// ```
5640pub struct ProjectSchemaSetIamPolicyCall<'a, C>
5641where
5642 C: 'a,
5643{
5644 hub: &'a Pubsub<C>,
5645 _request: SetIamPolicyRequest,
5646 _resource: String,
5647 _delegate: Option<&'a mut dyn common::Delegate>,
5648 _additional_params: HashMap<String, String>,
5649 _scopes: BTreeSet<String>,
5650}
5651
5652impl<'a, C> common::CallBuilder for ProjectSchemaSetIamPolicyCall<'a, C> {}
5653
5654impl<'a, C> ProjectSchemaSetIamPolicyCall<'a, C>
5655where
5656 C: common::Connector,
5657{
5658 /// Perform the operation you have build so far.
5659 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5660 use std::borrow::Cow;
5661 use std::io::{Read, Seek};
5662
5663 use common::{url::Params, ToParts};
5664 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5665
5666 let mut dd = common::DefaultDelegate;
5667 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5668 dlg.begin(common::MethodInfo {
5669 id: "pubsub.projects.schemas.setIamPolicy",
5670 http_method: hyper::Method::POST,
5671 });
5672
5673 for &field in ["alt", "resource"].iter() {
5674 if self._additional_params.contains_key(field) {
5675 dlg.finished(false);
5676 return Err(common::Error::FieldClash(field));
5677 }
5678 }
5679
5680 let mut params = Params::with_capacity(4 + self._additional_params.len());
5681 params.push("resource", self._resource);
5682
5683 params.extend(self._additional_params.iter());
5684
5685 params.push("alt", "json");
5686 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
5687 if self._scopes.is_empty() {
5688 self._scopes
5689 .insert(Scope::CloudPlatform.as_ref().to_string());
5690 }
5691
5692 #[allow(clippy::single_element_loop)]
5693 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5694 url = params.uri_replacement(url, param_name, find_this, true);
5695 }
5696 {
5697 let to_remove = ["resource"];
5698 params.remove_params(&to_remove);
5699 }
5700
5701 let url = params.parse_with_url(&url);
5702
5703 let mut json_mime_type = mime::APPLICATION_JSON;
5704 let mut request_value_reader = {
5705 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5706 common::remove_json_null_values(&mut value);
5707 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5708 serde_json::to_writer(&mut dst, &value).unwrap();
5709 dst
5710 };
5711 let request_size = request_value_reader
5712 .seek(std::io::SeekFrom::End(0))
5713 .unwrap();
5714 request_value_reader
5715 .seek(std::io::SeekFrom::Start(0))
5716 .unwrap();
5717
5718 loop {
5719 let token = match self
5720 .hub
5721 .auth
5722 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5723 .await
5724 {
5725 Ok(token) => token,
5726 Err(e) => match dlg.token(e) {
5727 Ok(token) => token,
5728 Err(e) => {
5729 dlg.finished(false);
5730 return Err(common::Error::MissingToken(e));
5731 }
5732 },
5733 };
5734 request_value_reader
5735 .seek(std::io::SeekFrom::Start(0))
5736 .unwrap();
5737 let mut req_result = {
5738 let client = &self.hub.client;
5739 dlg.pre_request();
5740 let mut req_builder = hyper::Request::builder()
5741 .method(hyper::Method::POST)
5742 .uri(url.as_str())
5743 .header(USER_AGENT, self.hub._user_agent.clone());
5744
5745 if let Some(token) = token.as_ref() {
5746 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5747 }
5748
5749 let request = req_builder
5750 .header(CONTENT_TYPE, json_mime_type.to_string())
5751 .header(CONTENT_LENGTH, request_size as u64)
5752 .body(common::to_body(
5753 request_value_reader.get_ref().clone().into(),
5754 ));
5755
5756 client.request(request.unwrap()).await
5757 };
5758
5759 match req_result {
5760 Err(err) => {
5761 if let common::Retry::After(d) = dlg.http_error(&err) {
5762 sleep(d).await;
5763 continue;
5764 }
5765 dlg.finished(false);
5766 return Err(common::Error::HttpError(err));
5767 }
5768 Ok(res) => {
5769 let (mut parts, body) = res.into_parts();
5770 let mut body = common::Body::new(body);
5771 if !parts.status.is_success() {
5772 let bytes = common::to_bytes(body).await.unwrap_or_default();
5773 let error = serde_json::from_str(&common::to_string(&bytes));
5774 let response = common::to_response(parts, bytes.into());
5775
5776 if let common::Retry::After(d) =
5777 dlg.http_failure(&response, error.as_ref().ok())
5778 {
5779 sleep(d).await;
5780 continue;
5781 }
5782
5783 dlg.finished(false);
5784
5785 return Err(match error {
5786 Ok(value) => common::Error::BadRequest(value),
5787 _ => common::Error::Failure(response),
5788 });
5789 }
5790 let response = {
5791 let bytes = common::to_bytes(body).await.unwrap_or_default();
5792 let encoded = common::to_string(&bytes);
5793 match serde_json::from_str(&encoded) {
5794 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5795 Err(error) => {
5796 dlg.response_json_decode_error(&encoded, &error);
5797 return Err(common::Error::JsonDecodeError(
5798 encoded.to_string(),
5799 error,
5800 ));
5801 }
5802 }
5803 };
5804
5805 dlg.finished(true);
5806 return Ok(response);
5807 }
5808 }
5809 }
5810 }
5811
5812 ///
5813 /// Sets the *request* property to the given value.
5814 ///
5815 /// Even though the property as already been set when instantiating this call,
5816 /// we provide this method for API completeness.
5817 pub fn request(
5818 mut self,
5819 new_value: SetIamPolicyRequest,
5820 ) -> ProjectSchemaSetIamPolicyCall<'a, C> {
5821 self._request = new_value;
5822 self
5823 }
5824 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
5825 ///
5826 /// Sets the *resource* path property to the given value.
5827 ///
5828 /// Even though the property as already been set when instantiating this call,
5829 /// we provide this method for API completeness.
5830 pub fn resource(mut self, new_value: &str) -> ProjectSchemaSetIamPolicyCall<'a, C> {
5831 self._resource = new_value.to_string();
5832 self
5833 }
5834 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5835 /// while executing the actual API request.
5836 ///
5837 /// ````text
5838 /// It should be used to handle progress information, and to implement a certain level of resilience.
5839 /// ````
5840 ///
5841 /// Sets the *delegate* property to the given value.
5842 pub fn delegate(
5843 mut self,
5844 new_value: &'a mut dyn common::Delegate,
5845 ) -> ProjectSchemaSetIamPolicyCall<'a, C> {
5846 self._delegate = Some(new_value);
5847 self
5848 }
5849
5850 /// Set any additional parameter of the query string used in the request.
5851 /// It should be used to set parameters which are not yet available through their own
5852 /// setters.
5853 ///
5854 /// Please note that this method must not be used to set any of the known parameters
5855 /// which have their own setter method. If done anyway, the request will fail.
5856 ///
5857 /// # Additional Parameters
5858 ///
5859 /// * *$.xgafv* (query-string) - V1 error format.
5860 /// * *access_token* (query-string) - OAuth access token.
5861 /// * *alt* (query-string) - Data format for response.
5862 /// * *callback* (query-string) - JSONP
5863 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5864 /// * *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.
5865 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5866 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5867 /// * *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.
5868 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5869 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5870 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaSetIamPolicyCall<'a, C>
5871 where
5872 T: AsRef<str>,
5873 {
5874 self._additional_params
5875 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5876 self
5877 }
5878
5879 /// Identifies the authorization scope for the method you are building.
5880 ///
5881 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5882 /// [`Scope::CloudPlatform`].
5883 ///
5884 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5885 /// tokens for more than one scope.
5886 ///
5887 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5888 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5889 /// sufficient, a read-write scope will do as well.
5890 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaSetIamPolicyCall<'a, C>
5891 where
5892 St: AsRef<str>,
5893 {
5894 self._scopes.insert(String::from(scope.as_ref()));
5895 self
5896 }
5897 /// Identifies the authorization scope(s) for the method you are building.
5898 ///
5899 /// See [`Self::add_scope()`] for details.
5900 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaSetIamPolicyCall<'a, C>
5901 where
5902 I: IntoIterator<Item = St>,
5903 St: AsRef<str>,
5904 {
5905 self._scopes
5906 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5907 self
5908 }
5909
5910 /// Removes all scopes, and no default scope will be used either.
5911 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5912 /// for details).
5913 pub fn clear_scopes(mut self) -> ProjectSchemaSetIamPolicyCall<'a, C> {
5914 self._scopes.clear();
5915 self
5916 }
5917}
5918
5919/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
5920///
5921/// A builder for the *schemas.testIamPermissions* method supported by a *project* resource.
5922/// It is not used directly, but through a [`ProjectMethods`] instance.
5923///
5924/// # Example
5925///
5926/// Instantiate a resource method builder
5927///
5928/// ```test_harness,no_run
5929/// # extern crate hyper;
5930/// # extern crate hyper_rustls;
5931/// # extern crate google_pubsub1 as pubsub1;
5932/// use pubsub1::api::TestIamPermissionsRequest;
5933/// # async fn dox() {
5934/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5935///
5936/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5937/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5938/// # .with_native_roots()
5939/// # .unwrap()
5940/// # .https_only()
5941/// # .enable_http2()
5942/// # .build();
5943///
5944/// # let executor = hyper_util::rt::TokioExecutor::new();
5945/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5946/// # secret,
5947/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5948/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5949/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5950/// # ),
5951/// # ).build().await.unwrap();
5952///
5953/// # let client = hyper_util::client::legacy::Client::builder(
5954/// # hyper_util::rt::TokioExecutor::new()
5955/// # )
5956/// # .build(
5957/// # hyper_rustls::HttpsConnectorBuilder::new()
5958/// # .with_native_roots()
5959/// # .unwrap()
5960/// # .https_or_http()
5961/// # .enable_http2()
5962/// # .build()
5963/// # );
5964/// # let mut hub = Pubsub::new(client, auth);
5965/// // As the method needs a request, you would usually fill it with the desired information
5966/// // into the respective structure. Some of the parts shown here might not be applicable !
5967/// // Values shown here are possibly random and not representative !
5968/// let mut req = TestIamPermissionsRequest::default();
5969///
5970/// // You can configure optional parameters by calling the respective setters at will, and
5971/// // execute the final call using `doit()`.
5972/// // Values shown here are possibly random and not representative !
5973/// let result = hub.projects().schemas_test_iam_permissions(req, "resource")
5974/// .doit().await;
5975/// # }
5976/// ```
5977pub struct ProjectSchemaTestIamPermissionCall<'a, C>
5978where
5979 C: 'a,
5980{
5981 hub: &'a Pubsub<C>,
5982 _request: TestIamPermissionsRequest,
5983 _resource: String,
5984 _delegate: Option<&'a mut dyn common::Delegate>,
5985 _additional_params: HashMap<String, String>,
5986 _scopes: BTreeSet<String>,
5987}
5988
5989impl<'a, C> common::CallBuilder for ProjectSchemaTestIamPermissionCall<'a, C> {}
5990
5991impl<'a, C> ProjectSchemaTestIamPermissionCall<'a, C>
5992where
5993 C: common::Connector,
5994{
5995 /// Perform the operation you have build so far.
5996 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
5997 use std::borrow::Cow;
5998 use std::io::{Read, Seek};
5999
6000 use common::{url::Params, ToParts};
6001 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6002
6003 let mut dd = common::DefaultDelegate;
6004 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6005 dlg.begin(common::MethodInfo {
6006 id: "pubsub.projects.schemas.testIamPermissions",
6007 http_method: hyper::Method::POST,
6008 });
6009
6010 for &field in ["alt", "resource"].iter() {
6011 if self._additional_params.contains_key(field) {
6012 dlg.finished(false);
6013 return Err(common::Error::FieldClash(field));
6014 }
6015 }
6016
6017 let mut params = Params::with_capacity(4 + self._additional_params.len());
6018 params.push("resource", self._resource);
6019
6020 params.extend(self._additional_params.iter());
6021
6022 params.push("alt", "json");
6023 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
6024 if self._scopes.is_empty() {
6025 self._scopes
6026 .insert(Scope::CloudPlatform.as_ref().to_string());
6027 }
6028
6029 #[allow(clippy::single_element_loop)]
6030 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6031 url = params.uri_replacement(url, param_name, find_this, true);
6032 }
6033 {
6034 let to_remove = ["resource"];
6035 params.remove_params(&to_remove);
6036 }
6037
6038 let url = params.parse_with_url(&url);
6039
6040 let mut json_mime_type = mime::APPLICATION_JSON;
6041 let mut request_value_reader = {
6042 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6043 common::remove_json_null_values(&mut value);
6044 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6045 serde_json::to_writer(&mut dst, &value).unwrap();
6046 dst
6047 };
6048 let request_size = request_value_reader
6049 .seek(std::io::SeekFrom::End(0))
6050 .unwrap();
6051 request_value_reader
6052 .seek(std::io::SeekFrom::Start(0))
6053 .unwrap();
6054
6055 loop {
6056 let token = match self
6057 .hub
6058 .auth
6059 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6060 .await
6061 {
6062 Ok(token) => token,
6063 Err(e) => match dlg.token(e) {
6064 Ok(token) => token,
6065 Err(e) => {
6066 dlg.finished(false);
6067 return Err(common::Error::MissingToken(e));
6068 }
6069 },
6070 };
6071 request_value_reader
6072 .seek(std::io::SeekFrom::Start(0))
6073 .unwrap();
6074 let mut req_result = {
6075 let client = &self.hub.client;
6076 dlg.pre_request();
6077 let mut req_builder = hyper::Request::builder()
6078 .method(hyper::Method::POST)
6079 .uri(url.as_str())
6080 .header(USER_AGENT, self.hub._user_agent.clone());
6081
6082 if let Some(token) = token.as_ref() {
6083 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6084 }
6085
6086 let request = req_builder
6087 .header(CONTENT_TYPE, json_mime_type.to_string())
6088 .header(CONTENT_LENGTH, request_size as u64)
6089 .body(common::to_body(
6090 request_value_reader.get_ref().clone().into(),
6091 ));
6092
6093 client.request(request.unwrap()).await
6094 };
6095
6096 match req_result {
6097 Err(err) => {
6098 if let common::Retry::After(d) = dlg.http_error(&err) {
6099 sleep(d).await;
6100 continue;
6101 }
6102 dlg.finished(false);
6103 return Err(common::Error::HttpError(err));
6104 }
6105 Ok(res) => {
6106 let (mut parts, body) = res.into_parts();
6107 let mut body = common::Body::new(body);
6108 if !parts.status.is_success() {
6109 let bytes = common::to_bytes(body).await.unwrap_or_default();
6110 let error = serde_json::from_str(&common::to_string(&bytes));
6111 let response = common::to_response(parts, bytes.into());
6112
6113 if let common::Retry::After(d) =
6114 dlg.http_failure(&response, error.as_ref().ok())
6115 {
6116 sleep(d).await;
6117 continue;
6118 }
6119
6120 dlg.finished(false);
6121
6122 return Err(match error {
6123 Ok(value) => common::Error::BadRequest(value),
6124 _ => common::Error::Failure(response),
6125 });
6126 }
6127 let response = {
6128 let bytes = common::to_bytes(body).await.unwrap_or_default();
6129 let encoded = common::to_string(&bytes);
6130 match serde_json::from_str(&encoded) {
6131 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6132 Err(error) => {
6133 dlg.response_json_decode_error(&encoded, &error);
6134 return Err(common::Error::JsonDecodeError(
6135 encoded.to_string(),
6136 error,
6137 ));
6138 }
6139 }
6140 };
6141
6142 dlg.finished(true);
6143 return Ok(response);
6144 }
6145 }
6146 }
6147 }
6148
6149 ///
6150 /// Sets the *request* property to the given value.
6151 ///
6152 /// Even though the property as already been set when instantiating this call,
6153 /// we provide this method for API completeness.
6154 pub fn request(
6155 mut self,
6156 new_value: TestIamPermissionsRequest,
6157 ) -> ProjectSchemaTestIamPermissionCall<'a, C> {
6158 self._request = new_value;
6159 self
6160 }
6161 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
6162 ///
6163 /// Sets the *resource* path property to the given value.
6164 ///
6165 /// Even though the property as already been set when instantiating this call,
6166 /// we provide this method for API completeness.
6167 pub fn resource(mut self, new_value: &str) -> ProjectSchemaTestIamPermissionCall<'a, C> {
6168 self._resource = new_value.to_string();
6169 self
6170 }
6171 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6172 /// while executing the actual API request.
6173 ///
6174 /// ````text
6175 /// It should be used to handle progress information, and to implement a certain level of resilience.
6176 /// ````
6177 ///
6178 /// Sets the *delegate* property to the given value.
6179 pub fn delegate(
6180 mut self,
6181 new_value: &'a mut dyn common::Delegate,
6182 ) -> ProjectSchemaTestIamPermissionCall<'a, C> {
6183 self._delegate = Some(new_value);
6184 self
6185 }
6186
6187 /// Set any additional parameter of the query string used in the request.
6188 /// It should be used to set parameters which are not yet available through their own
6189 /// setters.
6190 ///
6191 /// Please note that this method must not be used to set any of the known parameters
6192 /// which have their own setter method. If done anyway, the request will fail.
6193 ///
6194 /// # Additional Parameters
6195 ///
6196 /// * *$.xgafv* (query-string) - V1 error format.
6197 /// * *access_token* (query-string) - OAuth access token.
6198 /// * *alt* (query-string) - Data format for response.
6199 /// * *callback* (query-string) - JSONP
6200 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6201 /// * *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.
6202 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6203 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6204 /// * *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.
6205 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6206 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6207 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaTestIamPermissionCall<'a, C>
6208 where
6209 T: AsRef<str>,
6210 {
6211 self._additional_params
6212 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6213 self
6214 }
6215
6216 /// Identifies the authorization scope for the method you are building.
6217 ///
6218 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6219 /// [`Scope::CloudPlatform`].
6220 ///
6221 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6222 /// tokens for more than one scope.
6223 ///
6224 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6225 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6226 /// sufficient, a read-write scope will do as well.
6227 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaTestIamPermissionCall<'a, C>
6228 where
6229 St: AsRef<str>,
6230 {
6231 self._scopes.insert(String::from(scope.as_ref()));
6232 self
6233 }
6234 /// Identifies the authorization scope(s) for the method you are building.
6235 ///
6236 /// See [`Self::add_scope()`] for details.
6237 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaTestIamPermissionCall<'a, C>
6238 where
6239 I: IntoIterator<Item = St>,
6240 St: AsRef<str>,
6241 {
6242 self._scopes
6243 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6244 self
6245 }
6246
6247 /// Removes all scopes, and no default scope will be used either.
6248 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6249 /// for details).
6250 pub fn clear_scopes(mut self) -> ProjectSchemaTestIamPermissionCall<'a, C> {
6251 self._scopes.clear();
6252 self
6253 }
6254}
6255
6256/// Validates a schema.
6257///
6258/// A builder for the *schemas.validate* method supported by a *project* resource.
6259/// It is not used directly, but through a [`ProjectMethods`] instance.
6260///
6261/// # Example
6262///
6263/// Instantiate a resource method builder
6264///
6265/// ```test_harness,no_run
6266/// # extern crate hyper;
6267/// # extern crate hyper_rustls;
6268/// # extern crate google_pubsub1 as pubsub1;
6269/// use pubsub1::api::ValidateSchemaRequest;
6270/// # async fn dox() {
6271/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6272///
6273/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6274/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6275/// # .with_native_roots()
6276/// # .unwrap()
6277/// # .https_only()
6278/// # .enable_http2()
6279/// # .build();
6280///
6281/// # let executor = hyper_util::rt::TokioExecutor::new();
6282/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6283/// # secret,
6284/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6285/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6286/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6287/// # ),
6288/// # ).build().await.unwrap();
6289///
6290/// # let client = hyper_util::client::legacy::Client::builder(
6291/// # hyper_util::rt::TokioExecutor::new()
6292/// # )
6293/// # .build(
6294/// # hyper_rustls::HttpsConnectorBuilder::new()
6295/// # .with_native_roots()
6296/// # .unwrap()
6297/// # .https_or_http()
6298/// # .enable_http2()
6299/// # .build()
6300/// # );
6301/// # let mut hub = Pubsub::new(client, auth);
6302/// // As the method needs a request, you would usually fill it with the desired information
6303/// // into the respective structure. Some of the parts shown here might not be applicable !
6304/// // Values shown here are possibly random and not representative !
6305/// let mut req = ValidateSchemaRequest::default();
6306///
6307/// // You can configure optional parameters by calling the respective setters at will, and
6308/// // execute the final call using `doit()`.
6309/// // Values shown here are possibly random and not representative !
6310/// let result = hub.projects().schemas_validate(req, "parent")
6311/// .doit().await;
6312/// # }
6313/// ```
6314pub struct ProjectSchemaValidateCall<'a, C>
6315where
6316 C: 'a,
6317{
6318 hub: &'a Pubsub<C>,
6319 _request: ValidateSchemaRequest,
6320 _parent: String,
6321 _delegate: Option<&'a mut dyn common::Delegate>,
6322 _additional_params: HashMap<String, String>,
6323 _scopes: BTreeSet<String>,
6324}
6325
6326impl<'a, C> common::CallBuilder for ProjectSchemaValidateCall<'a, C> {}
6327
6328impl<'a, C> ProjectSchemaValidateCall<'a, C>
6329where
6330 C: common::Connector,
6331{
6332 /// Perform the operation you have build so far.
6333 pub async fn doit(mut self) -> common::Result<(common::Response, ValidateSchemaResponse)> {
6334 use std::borrow::Cow;
6335 use std::io::{Read, Seek};
6336
6337 use common::{url::Params, ToParts};
6338 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6339
6340 let mut dd = common::DefaultDelegate;
6341 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6342 dlg.begin(common::MethodInfo {
6343 id: "pubsub.projects.schemas.validate",
6344 http_method: hyper::Method::POST,
6345 });
6346
6347 for &field in ["alt", "parent"].iter() {
6348 if self._additional_params.contains_key(field) {
6349 dlg.finished(false);
6350 return Err(common::Error::FieldClash(field));
6351 }
6352 }
6353
6354 let mut params = Params::with_capacity(4 + self._additional_params.len());
6355 params.push("parent", self._parent);
6356
6357 params.extend(self._additional_params.iter());
6358
6359 params.push("alt", "json");
6360 let mut url = self.hub._base_url.clone() + "v1/{+parent}/schemas:validate";
6361 if self._scopes.is_empty() {
6362 self._scopes
6363 .insert(Scope::CloudPlatform.as_ref().to_string());
6364 }
6365
6366 #[allow(clippy::single_element_loop)]
6367 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6368 url = params.uri_replacement(url, param_name, find_this, true);
6369 }
6370 {
6371 let to_remove = ["parent"];
6372 params.remove_params(&to_remove);
6373 }
6374
6375 let url = params.parse_with_url(&url);
6376
6377 let mut json_mime_type = mime::APPLICATION_JSON;
6378 let mut request_value_reader = {
6379 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6380 common::remove_json_null_values(&mut value);
6381 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6382 serde_json::to_writer(&mut dst, &value).unwrap();
6383 dst
6384 };
6385 let request_size = request_value_reader
6386 .seek(std::io::SeekFrom::End(0))
6387 .unwrap();
6388 request_value_reader
6389 .seek(std::io::SeekFrom::Start(0))
6390 .unwrap();
6391
6392 loop {
6393 let token = match self
6394 .hub
6395 .auth
6396 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6397 .await
6398 {
6399 Ok(token) => token,
6400 Err(e) => match dlg.token(e) {
6401 Ok(token) => token,
6402 Err(e) => {
6403 dlg.finished(false);
6404 return Err(common::Error::MissingToken(e));
6405 }
6406 },
6407 };
6408 request_value_reader
6409 .seek(std::io::SeekFrom::Start(0))
6410 .unwrap();
6411 let mut req_result = {
6412 let client = &self.hub.client;
6413 dlg.pre_request();
6414 let mut req_builder = hyper::Request::builder()
6415 .method(hyper::Method::POST)
6416 .uri(url.as_str())
6417 .header(USER_AGENT, self.hub._user_agent.clone());
6418
6419 if let Some(token) = token.as_ref() {
6420 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6421 }
6422
6423 let request = req_builder
6424 .header(CONTENT_TYPE, json_mime_type.to_string())
6425 .header(CONTENT_LENGTH, request_size as u64)
6426 .body(common::to_body(
6427 request_value_reader.get_ref().clone().into(),
6428 ));
6429
6430 client.request(request.unwrap()).await
6431 };
6432
6433 match req_result {
6434 Err(err) => {
6435 if let common::Retry::After(d) = dlg.http_error(&err) {
6436 sleep(d).await;
6437 continue;
6438 }
6439 dlg.finished(false);
6440 return Err(common::Error::HttpError(err));
6441 }
6442 Ok(res) => {
6443 let (mut parts, body) = res.into_parts();
6444 let mut body = common::Body::new(body);
6445 if !parts.status.is_success() {
6446 let bytes = common::to_bytes(body).await.unwrap_or_default();
6447 let error = serde_json::from_str(&common::to_string(&bytes));
6448 let response = common::to_response(parts, bytes.into());
6449
6450 if let common::Retry::After(d) =
6451 dlg.http_failure(&response, error.as_ref().ok())
6452 {
6453 sleep(d).await;
6454 continue;
6455 }
6456
6457 dlg.finished(false);
6458
6459 return Err(match error {
6460 Ok(value) => common::Error::BadRequest(value),
6461 _ => common::Error::Failure(response),
6462 });
6463 }
6464 let response = {
6465 let bytes = common::to_bytes(body).await.unwrap_or_default();
6466 let encoded = common::to_string(&bytes);
6467 match serde_json::from_str(&encoded) {
6468 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6469 Err(error) => {
6470 dlg.response_json_decode_error(&encoded, &error);
6471 return Err(common::Error::JsonDecodeError(
6472 encoded.to_string(),
6473 error,
6474 ));
6475 }
6476 }
6477 };
6478
6479 dlg.finished(true);
6480 return Ok(response);
6481 }
6482 }
6483 }
6484 }
6485
6486 ///
6487 /// Sets the *request* property to the given value.
6488 ///
6489 /// Even though the property as already been set when instantiating this call,
6490 /// we provide this method for API completeness.
6491 pub fn request(mut self, new_value: ValidateSchemaRequest) -> ProjectSchemaValidateCall<'a, C> {
6492 self._request = new_value;
6493 self
6494 }
6495 /// Required. The name of the project in which to validate schemas. Format is `projects/{project-id}`.
6496 ///
6497 /// Sets the *parent* path property to the given value.
6498 ///
6499 /// Even though the property as already been set when instantiating this call,
6500 /// we provide this method for API completeness.
6501 pub fn parent(mut self, new_value: &str) -> ProjectSchemaValidateCall<'a, C> {
6502 self._parent = new_value.to_string();
6503 self
6504 }
6505 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6506 /// while executing the actual API request.
6507 ///
6508 /// ````text
6509 /// It should be used to handle progress information, and to implement a certain level of resilience.
6510 /// ````
6511 ///
6512 /// Sets the *delegate* property to the given value.
6513 pub fn delegate(
6514 mut self,
6515 new_value: &'a mut dyn common::Delegate,
6516 ) -> ProjectSchemaValidateCall<'a, C> {
6517 self._delegate = Some(new_value);
6518 self
6519 }
6520
6521 /// Set any additional parameter of the query string used in the request.
6522 /// It should be used to set parameters which are not yet available through their own
6523 /// setters.
6524 ///
6525 /// Please note that this method must not be used to set any of the known parameters
6526 /// which have their own setter method. If done anyway, the request will fail.
6527 ///
6528 /// # Additional Parameters
6529 ///
6530 /// * *$.xgafv* (query-string) - V1 error format.
6531 /// * *access_token* (query-string) - OAuth access token.
6532 /// * *alt* (query-string) - Data format for response.
6533 /// * *callback* (query-string) - JSONP
6534 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6535 /// * *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.
6536 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6537 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6538 /// * *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.
6539 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6540 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6541 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaValidateCall<'a, C>
6542 where
6543 T: AsRef<str>,
6544 {
6545 self._additional_params
6546 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6547 self
6548 }
6549
6550 /// Identifies the authorization scope for the method you are building.
6551 ///
6552 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6553 /// [`Scope::CloudPlatform`].
6554 ///
6555 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6556 /// tokens for more than one scope.
6557 ///
6558 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6559 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6560 /// sufficient, a read-write scope will do as well.
6561 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaValidateCall<'a, C>
6562 where
6563 St: AsRef<str>,
6564 {
6565 self._scopes.insert(String::from(scope.as_ref()));
6566 self
6567 }
6568 /// Identifies the authorization scope(s) for the method you are building.
6569 ///
6570 /// See [`Self::add_scope()`] for details.
6571 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaValidateCall<'a, C>
6572 where
6573 I: IntoIterator<Item = St>,
6574 St: AsRef<str>,
6575 {
6576 self._scopes
6577 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6578 self
6579 }
6580
6581 /// Removes all scopes, and no default scope will be used either.
6582 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6583 /// for details).
6584 pub fn clear_scopes(mut self) -> ProjectSchemaValidateCall<'a, C> {
6585 self._scopes.clear();
6586 self
6587 }
6588}
6589
6590/// Validates a message against a schema.
6591///
6592/// A builder for the *schemas.validateMessage* method supported by a *project* resource.
6593/// It is not used directly, but through a [`ProjectMethods`] instance.
6594///
6595/// # Example
6596///
6597/// Instantiate a resource method builder
6598///
6599/// ```test_harness,no_run
6600/// # extern crate hyper;
6601/// # extern crate hyper_rustls;
6602/// # extern crate google_pubsub1 as pubsub1;
6603/// use pubsub1::api::ValidateMessageRequest;
6604/// # async fn dox() {
6605/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6606///
6607/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6608/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6609/// # .with_native_roots()
6610/// # .unwrap()
6611/// # .https_only()
6612/// # .enable_http2()
6613/// # .build();
6614///
6615/// # let executor = hyper_util::rt::TokioExecutor::new();
6616/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6617/// # secret,
6618/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6619/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6620/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6621/// # ),
6622/// # ).build().await.unwrap();
6623///
6624/// # let client = hyper_util::client::legacy::Client::builder(
6625/// # hyper_util::rt::TokioExecutor::new()
6626/// # )
6627/// # .build(
6628/// # hyper_rustls::HttpsConnectorBuilder::new()
6629/// # .with_native_roots()
6630/// # .unwrap()
6631/// # .https_or_http()
6632/// # .enable_http2()
6633/// # .build()
6634/// # );
6635/// # let mut hub = Pubsub::new(client, auth);
6636/// // As the method needs a request, you would usually fill it with the desired information
6637/// // into the respective structure. Some of the parts shown here might not be applicable !
6638/// // Values shown here are possibly random and not representative !
6639/// let mut req = ValidateMessageRequest::default();
6640///
6641/// // You can configure optional parameters by calling the respective setters at will, and
6642/// // execute the final call using `doit()`.
6643/// // Values shown here are possibly random and not representative !
6644/// let result = hub.projects().schemas_validate_message(req, "parent")
6645/// .doit().await;
6646/// # }
6647/// ```
6648pub struct ProjectSchemaValidateMessageCall<'a, C>
6649where
6650 C: 'a,
6651{
6652 hub: &'a Pubsub<C>,
6653 _request: ValidateMessageRequest,
6654 _parent: String,
6655 _delegate: Option<&'a mut dyn common::Delegate>,
6656 _additional_params: HashMap<String, String>,
6657 _scopes: BTreeSet<String>,
6658}
6659
6660impl<'a, C> common::CallBuilder for ProjectSchemaValidateMessageCall<'a, C> {}
6661
6662impl<'a, C> ProjectSchemaValidateMessageCall<'a, C>
6663where
6664 C: common::Connector,
6665{
6666 /// Perform the operation you have build so far.
6667 pub async fn doit(mut self) -> common::Result<(common::Response, ValidateMessageResponse)> {
6668 use std::borrow::Cow;
6669 use std::io::{Read, Seek};
6670
6671 use common::{url::Params, ToParts};
6672 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6673
6674 let mut dd = common::DefaultDelegate;
6675 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6676 dlg.begin(common::MethodInfo {
6677 id: "pubsub.projects.schemas.validateMessage",
6678 http_method: hyper::Method::POST,
6679 });
6680
6681 for &field in ["alt", "parent"].iter() {
6682 if self._additional_params.contains_key(field) {
6683 dlg.finished(false);
6684 return Err(common::Error::FieldClash(field));
6685 }
6686 }
6687
6688 let mut params = Params::with_capacity(4 + self._additional_params.len());
6689 params.push("parent", self._parent);
6690
6691 params.extend(self._additional_params.iter());
6692
6693 params.push("alt", "json");
6694 let mut url = self.hub._base_url.clone() + "v1/{+parent}/schemas:validateMessage";
6695 if self._scopes.is_empty() {
6696 self._scopes
6697 .insert(Scope::CloudPlatform.as_ref().to_string());
6698 }
6699
6700 #[allow(clippy::single_element_loop)]
6701 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6702 url = params.uri_replacement(url, param_name, find_this, true);
6703 }
6704 {
6705 let to_remove = ["parent"];
6706 params.remove_params(&to_remove);
6707 }
6708
6709 let url = params.parse_with_url(&url);
6710
6711 let mut json_mime_type = mime::APPLICATION_JSON;
6712 let mut request_value_reader = {
6713 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6714 common::remove_json_null_values(&mut value);
6715 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6716 serde_json::to_writer(&mut dst, &value).unwrap();
6717 dst
6718 };
6719 let request_size = request_value_reader
6720 .seek(std::io::SeekFrom::End(0))
6721 .unwrap();
6722 request_value_reader
6723 .seek(std::io::SeekFrom::Start(0))
6724 .unwrap();
6725
6726 loop {
6727 let token = match self
6728 .hub
6729 .auth
6730 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6731 .await
6732 {
6733 Ok(token) => token,
6734 Err(e) => match dlg.token(e) {
6735 Ok(token) => token,
6736 Err(e) => {
6737 dlg.finished(false);
6738 return Err(common::Error::MissingToken(e));
6739 }
6740 },
6741 };
6742 request_value_reader
6743 .seek(std::io::SeekFrom::Start(0))
6744 .unwrap();
6745 let mut req_result = {
6746 let client = &self.hub.client;
6747 dlg.pre_request();
6748 let mut req_builder = hyper::Request::builder()
6749 .method(hyper::Method::POST)
6750 .uri(url.as_str())
6751 .header(USER_AGENT, self.hub._user_agent.clone());
6752
6753 if let Some(token) = token.as_ref() {
6754 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6755 }
6756
6757 let request = req_builder
6758 .header(CONTENT_TYPE, json_mime_type.to_string())
6759 .header(CONTENT_LENGTH, request_size as u64)
6760 .body(common::to_body(
6761 request_value_reader.get_ref().clone().into(),
6762 ));
6763
6764 client.request(request.unwrap()).await
6765 };
6766
6767 match req_result {
6768 Err(err) => {
6769 if let common::Retry::After(d) = dlg.http_error(&err) {
6770 sleep(d).await;
6771 continue;
6772 }
6773 dlg.finished(false);
6774 return Err(common::Error::HttpError(err));
6775 }
6776 Ok(res) => {
6777 let (mut parts, body) = res.into_parts();
6778 let mut body = common::Body::new(body);
6779 if !parts.status.is_success() {
6780 let bytes = common::to_bytes(body).await.unwrap_or_default();
6781 let error = serde_json::from_str(&common::to_string(&bytes));
6782 let response = common::to_response(parts, bytes.into());
6783
6784 if let common::Retry::After(d) =
6785 dlg.http_failure(&response, error.as_ref().ok())
6786 {
6787 sleep(d).await;
6788 continue;
6789 }
6790
6791 dlg.finished(false);
6792
6793 return Err(match error {
6794 Ok(value) => common::Error::BadRequest(value),
6795 _ => common::Error::Failure(response),
6796 });
6797 }
6798 let response = {
6799 let bytes = common::to_bytes(body).await.unwrap_or_default();
6800 let encoded = common::to_string(&bytes);
6801 match serde_json::from_str(&encoded) {
6802 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6803 Err(error) => {
6804 dlg.response_json_decode_error(&encoded, &error);
6805 return Err(common::Error::JsonDecodeError(
6806 encoded.to_string(),
6807 error,
6808 ));
6809 }
6810 }
6811 };
6812
6813 dlg.finished(true);
6814 return Ok(response);
6815 }
6816 }
6817 }
6818 }
6819
6820 ///
6821 /// Sets the *request* property to the given value.
6822 ///
6823 /// Even though the property as already been set when instantiating this call,
6824 /// we provide this method for API completeness.
6825 pub fn request(
6826 mut self,
6827 new_value: ValidateMessageRequest,
6828 ) -> ProjectSchemaValidateMessageCall<'a, C> {
6829 self._request = new_value;
6830 self
6831 }
6832 /// Required. The name of the project in which to validate schemas. Format is `projects/{project-id}`.
6833 ///
6834 /// Sets the *parent* path property to the given value.
6835 ///
6836 /// Even though the property as already been set when instantiating this call,
6837 /// we provide this method for API completeness.
6838 pub fn parent(mut self, new_value: &str) -> ProjectSchemaValidateMessageCall<'a, C> {
6839 self._parent = new_value.to_string();
6840 self
6841 }
6842 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6843 /// while executing the actual API request.
6844 ///
6845 /// ````text
6846 /// It should be used to handle progress information, and to implement a certain level of resilience.
6847 /// ````
6848 ///
6849 /// Sets the *delegate* property to the given value.
6850 pub fn delegate(
6851 mut self,
6852 new_value: &'a mut dyn common::Delegate,
6853 ) -> ProjectSchemaValidateMessageCall<'a, C> {
6854 self._delegate = Some(new_value);
6855 self
6856 }
6857
6858 /// Set any additional parameter of the query string used in the request.
6859 /// It should be used to set parameters which are not yet available through their own
6860 /// setters.
6861 ///
6862 /// Please note that this method must not be used to set any of the known parameters
6863 /// which have their own setter method. If done anyway, the request will fail.
6864 ///
6865 /// # Additional Parameters
6866 ///
6867 /// * *$.xgafv* (query-string) - V1 error format.
6868 /// * *access_token* (query-string) - OAuth access token.
6869 /// * *alt* (query-string) - Data format for response.
6870 /// * *callback* (query-string) - JSONP
6871 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6872 /// * *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.
6873 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6874 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6875 /// * *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.
6876 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6877 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6878 pub fn param<T>(mut self, name: T, value: T) -> ProjectSchemaValidateMessageCall<'a, C>
6879 where
6880 T: AsRef<str>,
6881 {
6882 self._additional_params
6883 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6884 self
6885 }
6886
6887 /// Identifies the authorization scope for the method you are building.
6888 ///
6889 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6890 /// [`Scope::CloudPlatform`].
6891 ///
6892 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6893 /// tokens for more than one scope.
6894 ///
6895 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6896 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6897 /// sufficient, a read-write scope will do as well.
6898 pub fn add_scope<St>(mut self, scope: St) -> ProjectSchemaValidateMessageCall<'a, C>
6899 where
6900 St: AsRef<str>,
6901 {
6902 self._scopes.insert(String::from(scope.as_ref()));
6903 self
6904 }
6905 /// Identifies the authorization scope(s) for the method you are building.
6906 ///
6907 /// See [`Self::add_scope()`] for details.
6908 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSchemaValidateMessageCall<'a, C>
6909 where
6910 I: IntoIterator<Item = St>,
6911 St: AsRef<str>,
6912 {
6913 self._scopes
6914 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6915 self
6916 }
6917
6918 /// Removes all scopes, and no default scope will be used either.
6919 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6920 /// for details).
6921 pub fn clear_scopes(mut self) -> ProjectSchemaValidateMessageCall<'a, C> {
6922 self._scopes.clear();
6923 self
6924 }
6925}
6926
6927/// Creates a snapshot from the requested subscription. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. If the snapshot already exists, returns `ALREADY_EXISTS`. If the requested subscription doesn't exist, returns `NOT_FOUND`. If the backlog in the subscription is too old -- and the resulting snapshot would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned. See also the `Snapshot.expire_time` field. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription, conforming to the [resource name format] (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). The generated name is populated in the returned Snapshot object. Note that for REST API requests, you must specify a name in the request.
6928///
6929/// A builder for the *snapshots.create* method supported by a *project* resource.
6930/// It is not used directly, but through a [`ProjectMethods`] instance.
6931///
6932/// # Example
6933///
6934/// Instantiate a resource method builder
6935///
6936/// ```test_harness,no_run
6937/// # extern crate hyper;
6938/// # extern crate hyper_rustls;
6939/// # extern crate google_pubsub1 as pubsub1;
6940/// use pubsub1::api::CreateSnapshotRequest;
6941/// # async fn dox() {
6942/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6943///
6944/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6945/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6946/// # .with_native_roots()
6947/// # .unwrap()
6948/// # .https_only()
6949/// # .enable_http2()
6950/// # .build();
6951///
6952/// # let executor = hyper_util::rt::TokioExecutor::new();
6953/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6954/// # secret,
6955/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6956/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6957/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6958/// # ),
6959/// # ).build().await.unwrap();
6960///
6961/// # let client = hyper_util::client::legacy::Client::builder(
6962/// # hyper_util::rt::TokioExecutor::new()
6963/// # )
6964/// # .build(
6965/// # hyper_rustls::HttpsConnectorBuilder::new()
6966/// # .with_native_roots()
6967/// # .unwrap()
6968/// # .https_or_http()
6969/// # .enable_http2()
6970/// # .build()
6971/// # );
6972/// # let mut hub = Pubsub::new(client, auth);
6973/// // As the method needs a request, you would usually fill it with the desired information
6974/// // into the respective structure. Some of the parts shown here might not be applicable !
6975/// // Values shown here are possibly random and not representative !
6976/// let mut req = CreateSnapshotRequest::default();
6977///
6978/// // You can configure optional parameters by calling the respective setters at will, and
6979/// // execute the final call using `doit()`.
6980/// // Values shown here are possibly random and not representative !
6981/// let result = hub.projects().snapshots_create(req, "name")
6982/// .doit().await;
6983/// # }
6984/// ```
6985pub struct ProjectSnapshotCreateCall<'a, C>
6986where
6987 C: 'a,
6988{
6989 hub: &'a Pubsub<C>,
6990 _request: CreateSnapshotRequest,
6991 _name: String,
6992 _delegate: Option<&'a mut dyn common::Delegate>,
6993 _additional_params: HashMap<String, String>,
6994 _scopes: BTreeSet<String>,
6995}
6996
6997impl<'a, C> common::CallBuilder for ProjectSnapshotCreateCall<'a, C> {}
6998
6999impl<'a, C> ProjectSnapshotCreateCall<'a, C>
7000where
7001 C: common::Connector,
7002{
7003 /// Perform the operation you have build so far.
7004 pub async fn doit(mut self) -> common::Result<(common::Response, Snapshot)> {
7005 use std::borrow::Cow;
7006 use std::io::{Read, Seek};
7007
7008 use common::{url::Params, ToParts};
7009 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7010
7011 let mut dd = common::DefaultDelegate;
7012 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7013 dlg.begin(common::MethodInfo {
7014 id: "pubsub.projects.snapshots.create",
7015 http_method: hyper::Method::PUT,
7016 });
7017
7018 for &field in ["alt", "name"].iter() {
7019 if self._additional_params.contains_key(field) {
7020 dlg.finished(false);
7021 return Err(common::Error::FieldClash(field));
7022 }
7023 }
7024
7025 let mut params = Params::with_capacity(4 + self._additional_params.len());
7026 params.push("name", self._name);
7027
7028 params.extend(self._additional_params.iter());
7029
7030 params.push("alt", "json");
7031 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7032 if self._scopes.is_empty() {
7033 self._scopes
7034 .insert(Scope::CloudPlatform.as_ref().to_string());
7035 }
7036
7037 #[allow(clippy::single_element_loop)]
7038 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7039 url = params.uri_replacement(url, param_name, find_this, true);
7040 }
7041 {
7042 let to_remove = ["name"];
7043 params.remove_params(&to_remove);
7044 }
7045
7046 let url = params.parse_with_url(&url);
7047
7048 let mut json_mime_type = mime::APPLICATION_JSON;
7049 let mut request_value_reader = {
7050 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7051 common::remove_json_null_values(&mut value);
7052 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7053 serde_json::to_writer(&mut dst, &value).unwrap();
7054 dst
7055 };
7056 let request_size = request_value_reader
7057 .seek(std::io::SeekFrom::End(0))
7058 .unwrap();
7059 request_value_reader
7060 .seek(std::io::SeekFrom::Start(0))
7061 .unwrap();
7062
7063 loop {
7064 let token = match self
7065 .hub
7066 .auth
7067 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7068 .await
7069 {
7070 Ok(token) => token,
7071 Err(e) => match dlg.token(e) {
7072 Ok(token) => token,
7073 Err(e) => {
7074 dlg.finished(false);
7075 return Err(common::Error::MissingToken(e));
7076 }
7077 },
7078 };
7079 request_value_reader
7080 .seek(std::io::SeekFrom::Start(0))
7081 .unwrap();
7082 let mut req_result = {
7083 let client = &self.hub.client;
7084 dlg.pre_request();
7085 let mut req_builder = hyper::Request::builder()
7086 .method(hyper::Method::PUT)
7087 .uri(url.as_str())
7088 .header(USER_AGENT, self.hub._user_agent.clone());
7089
7090 if let Some(token) = token.as_ref() {
7091 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7092 }
7093
7094 let request = req_builder
7095 .header(CONTENT_TYPE, json_mime_type.to_string())
7096 .header(CONTENT_LENGTH, request_size as u64)
7097 .body(common::to_body(
7098 request_value_reader.get_ref().clone().into(),
7099 ));
7100
7101 client.request(request.unwrap()).await
7102 };
7103
7104 match req_result {
7105 Err(err) => {
7106 if let common::Retry::After(d) = dlg.http_error(&err) {
7107 sleep(d).await;
7108 continue;
7109 }
7110 dlg.finished(false);
7111 return Err(common::Error::HttpError(err));
7112 }
7113 Ok(res) => {
7114 let (mut parts, body) = res.into_parts();
7115 let mut body = common::Body::new(body);
7116 if !parts.status.is_success() {
7117 let bytes = common::to_bytes(body).await.unwrap_or_default();
7118 let error = serde_json::from_str(&common::to_string(&bytes));
7119 let response = common::to_response(parts, bytes.into());
7120
7121 if let common::Retry::After(d) =
7122 dlg.http_failure(&response, error.as_ref().ok())
7123 {
7124 sleep(d).await;
7125 continue;
7126 }
7127
7128 dlg.finished(false);
7129
7130 return Err(match error {
7131 Ok(value) => common::Error::BadRequest(value),
7132 _ => common::Error::Failure(response),
7133 });
7134 }
7135 let response = {
7136 let bytes = common::to_bytes(body).await.unwrap_or_default();
7137 let encoded = common::to_string(&bytes);
7138 match serde_json::from_str(&encoded) {
7139 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7140 Err(error) => {
7141 dlg.response_json_decode_error(&encoded, &error);
7142 return Err(common::Error::JsonDecodeError(
7143 encoded.to_string(),
7144 error,
7145 ));
7146 }
7147 }
7148 };
7149
7150 dlg.finished(true);
7151 return Ok(response);
7152 }
7153 }
7154 }
7155 }
7156
7157 ///
7158 /// Sets the *request* property to the given value.
7159 ///
7160 /// Even though the property as already been set when instantiating this call,
7161 /// we provide this method for API completeness.
7162 pub fn request(mut self, new_value: CreateSnapshotRequest) -> ProjectSnapshotCreateCall<'a, C> {
7163 self._request = new_value;
7164 self
7165 }
7166 /// Required. Identifier. User-provided name for this snapshot. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription. Note that for REST API requests, you must specify a name. See the [resource name rules](https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). Format is `projects/{project}/snapshots/{snap}`.
7167 ///
7168 /// Sets the *name* path property to the given value.
7169 ///
7170 /// Even though the property as already been set when instantiating this call,
7171 /// we provide this method for API completeness.
7172 pub fn name(mut self, new_value: &str) -> ProjectSnapshotCreateCall<'a, C> {
7173 self._name = new_value.to_string();
7174 self
7175 }
7176 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7177 /// while executing the actual API request.
7178 ///
7179 /// ````text
7180 /// It should be used to handle progress information, and to implement a certain level of resilience.
7181 /// ````
7182 ///
7183 /// Sets the *delegate* property to the given value.
7184 pub fn delegate(
7185 mut self,
7186 new_value: &'a mut dyn common::Delegate,
7187 ) -> ProjectSnapshotCreateCall<'a, C> {
7188 self._delegate = Some(new_value);
7189 self
7190 }
7191
7192 /// Set any additional parameter of the query string used in the request.
7193 /// It should be used to set parameters which are not yet available through their own
7194 /// setters.
7195 ///
7196 /// Please note that this method must not be used to set any of the known parameters
7197 /// which have their own setter method. If done anyway, the request will fail.
7198 ///
7199 /// # Additional Parameters
7200 ///
7201 /// * *$.xgafv* (query-string) - V1 error format.
7202 /// * *access_token* (query-string) - OAuth access token.
7203 /// * *alt* (query-string) - Data format for response.
7204 /// * *callback* (query-string) - JSONP
7205 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7206 /// * *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.
7207 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7208 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7209 /// * *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.
7210 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7211 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7212 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnapshotCreateCall<'a, C>
7213 where
7214 T: AsRef<str>,
7215 {
7216 self._additional_params
7217 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7218 self
7219 }
7220
7221 /// Identifies the authorization scope for the method you are building.
7222 ///
7223 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7224 /// [`Scope::CloudPlatform`].
7225 ///
7226 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7227 /// tokens for more than one scope.
7228 ///
7229 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7230 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7231 /// sufficient, a read-write scope will do as well.
7232 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnapshotCreateCall<'a, C>
7233 where
7234 St: AsRef<str>,
7235 {
7236 self._scopes.insert(String::from(scope.as_ref()));
7237 self
7238 }
7239 /// Identifies the authorization scope(s) for the method you are building.
7240 ///
7241 /// See [`Self::add_scope()`] for details.
7242 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnapshotCreateCall<'a, C>
7243 where
7244 I: IntoIterator<Item = St>,
7245 St: AsRef<str>,
7246 {
7247 self._scopes
7248 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7249 self
7250 }
7251
7252 /// Removes all scopes, and no default scope will be used either.
7253 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7254 /// for details).
7255 pub fn clear_scopes(mut self) -> ProjectSnapshotCreateCall<'a, C> {
7256 self._scopes.clear();
7257 self
7258 }
7259}
7260
7261/// Removes an existing snapshot. Snapshots are used in [Seek] (https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. When the snapshot is deleted, all messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new one may be created with the same name, but the new one has no association with the old snapshot or its subscription, unless the same subscription is specified.
7262///
7263/// A builder for the *snapshots.delete* method supported by a *project* resource.
7264/// It is not used directly, but through a [`ProjectMethods`] instance.
7265///
7266/// # Example
7267///
7268/// Instantiate a resource method builder
7269///
7270/// ```test_harness,no_run
7271/// # extern crate hyper;
7272/// # extern crate hyper_rustls;
7273/// # extern crate google_pubsub1 as pubsub1;
7274/// # async fn dox() {
7275/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7276///
7277/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7278/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7279/// # .with_native_roots()
7280/// # .unwrap()
7281/// # .https_only()
7282/// # .enable_http2()
7283/// # .build();
7284///
7285/// # let executor = hyper_util::rt::TokioExecutor::new();
7286/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7287/// # secret,
7288/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7289/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7290/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7291/// # ),
7292/// # ).build().await.unwrap();
7293///
7294/// # let client = hyper_util::client::legacy::Client::builder(
7295/// # hyper_util::rt::TokioExecutor::new()
7296/// # )
7297/// # .build(
7298/// # hyper_rustls::HttpsConnectorBuilder::new()
7299/// # .with_native_roots()
7300/// # .unwrap()
7301/// # .https_or_http()
7302/// # .enable_http2()
7303/// # .build()
7304/// # );
7305/// # let mut hub = Pubsub::new(client, auth);
7306/// // You can configure optional parameters by calling the respective setters at will, and
7307/// // execute the final call using `doit()`.
7308/// // Values shown here are possibly random and not representative !
7309/// let result = hub.projects().snapshots_delete("snapshot")
7310/// .doit().await;
7311/// # }
7312/// ```
7313pub struct ProjectSnapshotDeleteCall<'a, C>
7314where
7315 C: 'a,
7316{
7317 hub: &'a Pubsub<C>,
7318 _snapshot: String,
7319 _delegate: Option<&'a mut dyn common::Delegate>,
7320 _additional_params: HashMap<String, String>,
7321 _scopes: BTreeSet<String>,
7322}
7323
7324impl<'a, C> common::CallBuilder for ProjectSnapshotDeleteCall<'a, C> {}
7325
7326impl<'a, C> ProjectSnapshotDeleteCall<'a, C>
7327where
7328 C: common::Connector,
7329{
7330 /// Perform the operation you have build so far.
7331 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7332 use std::borrow::Cow;
7333 use std::io::{Read, Seek};
7334
7335 use common::{url::Params, ToParts};
7336 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7337
7338 let mut dd = common::DefaultDelegate;
7339 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7340 dlg.begin(common::MethodInfo {
7341 id: "pubsub.projects.snapshots.delete",
7342 http_method: hyper::Method::DELETE,
7343 });
7344
7345 for &field in ["alt", "snapshot"].iter() {
7346 if self._additional_params.contains_key(field) {
7347 dlg.finished(false);
7348 return Err(common::Error::FieldClash(field));
7349 }
7350 }
7351
7352 let mut params = Params::with_capacity(3 + self._additional_params.len());
7353 params.push("snapshot", self._snapshot);
7354
7355 params.extend(self._additional_params.iter());
7356
7357 params.push("alt", "json");
7358 let mut url = self.hub._base_url.clone() + "v1/{+snapshot}";
7359 if self._scopes.is_empty() {
7360 self._scopes
7361 .insert(Scope::CloudPlatform.as_ref().to_string());
7362 }
7363
7364 #[allow(clippy::single_element_loop)]
7365 for &(find_this, param_name) in [("{+snapshot}", "snapshot")].iter() {
7366 url = params.uri_replacement(url, param_name, find_this, true);
7367 }
7368 {
7369 let to_remove = ["snapshot"];
7370 params.remove_params(&to_remove);
7371 }
7372
7373 let url = params.parse_with_url(&url);
7374
7375 loop {
7376 let token = match self
7377 .hub
7378 .auth
7379 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7380 .await
7381 {
7382 Ok(token) => token,
7383 Err(e) => match dlg.token(e) {
7384 Ok(token) => token,
7385 Err(e) => {
7386 dlg.finished(false);
7387 return Err(common::Error::MissingToken(e));
7388 }
7389 },
7390 };
7391 let mut req_result = {
7392 let client = &self.hub.client;
7393 dlg.pre_request();
7394 let mut req_builder = hyper::Request::builder()
7395 .method(hyper::Method::DELETE)
7396 .uri(url.as_str())
7397 .header(USER_AGENT, self.hub._user_agent.clone());
7398
7399 if let Some(token) = token.as_ref() {
7400 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7401 }
7402
7403 let request = req_builder
7404 .header(CONTENT_LENGTH, 0_u64)
7405 .body(common::to_body::<String>(None));
7406
7407 client.request(request.unwrap()).await
7408 };
7409
7410 match req_result {
7411 Err(err) => {
7412 if let common::Retry::After(d) = dlg.http_error(&err) {
7413 sleep(d).await;
7414 continue;
7415 }
7416 dlg.finished(false);
7417 return Err(common::Error::HttpError(err));
7418 }
7419 Ok(res) => {
7420 let (mut parts, body) = res.into_parts();
7421 let mut body = common::Body::new(body);
7422 if !parts.status.is_success() {
7423 let bytes = common::to_bytes(body).await.unwrap_or_default();
7424 let error = serde_json::from_str(&common::to_string(&bytes));
7425 let response = common::to_response(parts, bytes.into());
7426
7427 if let common::Retry::After(d) =
7428 dlg.http_failure(&response, error.as_ref().ok())
7429 {
7430 sleep(d).await;
7431 continue;
7432 }
7433
7434 dlg.finished(false);
7435
7436 return Err(match error {
7437 Ok(value) => common::Error::BadRequest(value),
7438 _ => common::Error::Failure(response),
7439 });
7440 }
7441 let response = {
7442 let bytes = common::to_bytes(body).await.unwrap_or_default();
7443 let encoded = common::to_string(&bytes);
7444 match serde_json::from_str(&encoded) {
7445 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7446 Err(error) => {
7447 dlg.response_json_decode_error(&encoded, &error);
7448 return Err(common::Error::JsonDecodeError(
7449 encoded.to_string(),
7450 error,
7451 ));
7452 }
7453 }
7454 };
7455
7456 dlg.finished(true);
7457 return Ok(response);
7458 }
7459 }
7460 }
7461 }
7462
7463 /// Required. Identifier. The name of the snapshot to delete. Format is `projects/{project}/snapshots/{snap}`.
7464 ///
7465 /// Sets the *snapshot* path property to the given value.
7466 ///
7467 /// Even though the property as already been set when instantiating this call,
7468 /// we provide this method for API completeness.
7469 pub fn snapshot(mut self, new_value: &str) -> ProjectSnapshotDeleteCall<'a, C> {
7470 self._snapshot = new_value.to_string();
7471 self
7472 }
7473 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7474 /// while executing the actual API request.
7475 ///
7476 /// ````text
7477 /// It should be used to handle progress information, and to implement a certain level of resilience.
7478 /// ````
7479 ///
7480 /// Sets the *delegate* property to the given value.
7481 pub fn delegate(
7482 mut self,
7483 new_value: &'a mut dyn common::Delegate,
7484 ) -> ProjectSnapshotDeleteCall<'a, C> {
7485 self._delegate = Some(new_value);
7486 self
7487 }
7488
7489 /// Set any additional parameter of the query string used in the request.
7490 /// It should be used to set parameters which are not yet available through their own
7491 /// setters.
7492 ///
7493 /// Please note that this method must not be used to set any of the known parameters
7494 /// which have their own setter method. If done anyway, the request will fail.
7495 ///
7496 /// # Additional Parameters
7497 ///
7498 /// * *$.xgafv* (query-string) - V1 error format.
7499 /// * *access_token* (query-string) - OAuth access token.
7500 /// * *alt* (query-string) - Data format for response.
7501 /// * *callback* (query-string) - JSONP
7502 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7503 /// * *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.
7504 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7505 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7506 /// * *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.
7507 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7508 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7509 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnapshotDeleteCall<'a, C>
7510 where
7511 T: AsRef<str>,
7512 {
7513 self._additional_params
7514 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7515 self
7516 }
7517
7518 /// Identifies the authorization scope for the method you are building.
7519 ///
7520 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7521 /// [`Scope::CloudPlatform`].
7522 ///
7523 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7524 /// tokens for more than one scope.
7525 ///
7526 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7527 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7528 /// sufficient, a read-write scope will do as well.
7529 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnapshotDeleteCall<'a, C>
7530 where
7531 St: AsRef<str>,
7532 {
7533 self._scopes.insert(String::from(scope.as_ref()));
7534 self
7535 }
7536 /// Identifies the authorization scope(s) for the method you are building.
7537 ///
7538 /// See [`Self::add_scope()`] for details.
7539 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnapshotDeleteCall<'a, C>
7540 where
7541 I: IntoIterator<Item = St>,
7542 St: AsRef<str>,
7543 {
7544 self._scopes
7545 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7546 self
7547 }
7548
7549 /// Removes all scopes, and no default scope will be used either.
7550 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7551 /// for details).
7552 pub fn clear_scopes(mut self) -> ProjectSnapshotDeleteCall<'a, C> {
7553 self._scopes.clear();
7554 self
7555 }
7556}
7557
7558/// Gets the configuration details of a snapshot. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
7559///
7560/// A builder for the *snapshots.get* method supported by a *project* resource.
7561/// It is not used directly, but through a [`ProjectMethods`] instance.
7562///
7563/// # Example
7564///
7565/// Instantiate a resource method builder
7566///
7567/// ```test_harness,no_run
7568/// # extern crate hyper;
7569/// # extern crate hyper_rustls;
7570/// # extern crate google_pubsub1 as pubsub1;
7571/// # async fn dox() {
7572/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7573///
7574/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7575/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7576/// # .with_native_roots()
7577/// # .unwrap()
7578/// # .https_only()
7579/// # .enable_http2()
7580/// # .build();
7581///
7582/// # let executor = hyper_util::rt::TokioExecutor::new();
7583/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7584/// # secret,
7585/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7586/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7587/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7588/// # ),
7589/// # ).build().await.unwrap();
7590///
7591/// # let client = hyper_util::client::legacy::Client::builder(
7592/// # hyper_util::rt::TokioExecutor::new()
7593/// # )
7594/// # .build(
7595/// # hyper_rustls::HttpsConnectorBuilder::new()
7596/// # .with_native_roots()
7597/// # .unwrap()
7598/// # .https_or_http()
7599/// # .enable_http2()
7600/// # .build()
7601/// # );
7602/// # let mut hub = Pubsub::new(client, auth);
7603/// // You can configure optional parameters by calling the respective setters at will, and
7604/// // execute the final call using `doit()`.
7605/// // Values shown here are possibly random and not representative !
7606/// let result = hub.projects().snapshots_get("snapshot")
7607/// .doit().await;
7608/// # }
7609/// ```
7610pub struct ProjectSnapshotGetCall<'a, C>
7611where
7612 C: 'a,
7613{
7614 hub: &'a Pubsub<C>,
7615 _snapshot: String,
7616 _delegate: Option<&'a mut dyn common::Delegate>,
7617 _additional_params: HashMap<String, String>,
7618 _scopes: BTreeSet<String>,
7619}
7620
7621impl<'a, C> common::CallBuilder for ProjectSnapshotGetCall<'a, C> {}
7622
7623impl<'a, C> ProjectSnapshotGetCall<'a, C>
7624where
7625 C: common::Connector,
7626{
7627 /// Perform the operation you have build so far.
7628 pub async fn doit(mut self) -> common::Result<(common::Response, Snapshot)> {
7629 use std::borrow::Cow;
7630 use std::io::{Read, Seek};
7631
7632 use common::{url::Params, ToParts};
7633 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7634
7635 let mut dd = common::DefaultDelegate;
7636 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7637 dlg.begin(common::MethodInfo {
7638 id: "pubsub.projects.snapshots.get",
7639 http_method: hyper::Method::GET,
7640 });
7641
7642 for &field in ["alt", "snapshot"].iter() {
7643 if self._additional_params.contains_key(field) {
7644 dlg.finished(false);
7645 return Err(common::Error::FieldClash(field));
7646 }
7647 }
7648
7649 let mut params = Params::with_capacity(3 + self._additional_params.len());
7650 params.push("snapshot", self._snapshot);
7651
7652 params.extend(self._additional_params.iter());
7653
7654 params.push("alt", "json");
7655 let mut url = self.hub._base_url.clone() + "v1/{+snapshot}";
7656 if self._scopes.is_empty() {
7657 self._scopes
7658 .insert(Scope::CloudPlatform.as_ref().to_string());
7659 }
7660
7661 #[allow(clippy::single_element_loop)]
7662 for &(find_this, param_name) in [("{+snapshot}", "snapshot")].iter() {
7663 url = params.uri_replacement(url, param_name, find_this, true);
7664 }
7665 {
7666 let to_remove = ["snapshot"];
7667 params.remove_params(&to_remove);
7668 }
7669
7670 let url = params.parse_with_url(&url);
7671
7672 loop {
7673 let token = match self
7674 .hub
7675 .auth
7676 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7677 .await
7678 {
7679 Ok(token) => token,
7680 Err(e) => match dlg.token(e) {
7681 Ok(token) => token,
7682 Err(e) => {
7683 dlg.finished(false);
7684 return Err(common::Error::MissingToken(e));
7685 }
7686 },
7687 };
7688 let mut req_result = {
7689 let client = &self.hub.client;
7690 dlg.pre_request();
7691 let mut req_builder = hyper::Request::builder()
7692 .method(hyper::Method::GET)
7693 .uri(url.as_str())
7694 .header(USER_AGENT, self.hub._user_agent.clone());
7695
7696 if let Some(token) = token.as_ref() {
7697 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7698 }
7699
7700 let request = req_builder
7701 .header(CONTENT_LENGTH, 0_u64)
7702 .body(common::to_body::<String>(None));
7703
7704 client.request(request.unwrap()).await
7705 };
7706
7707 match req_result {
7708 Err(err) => {
7709 if let common::Retry::After(d) = dlg.http_error(&err) {
7710 sleep(d).await;
7711 continue;
7712 }
7713 dlg.finished(false);
7714 return Err(common::Error::HttpError(err));
7715 }
7716 Ok(res) => {
7717 let (mut parts, body) = res.into_parts();
7718 let mut body = common::Body::new(body);
7719 if !parts.status.is_success() {
7720 let bytes = common::to_bytes(body).await.unwrap_or_default();
7721 let error = serde_json::from_str(&common::to_string(&bytes));
7722 let response = common::to_response(parts, bytes.into());
7723
7724 if let common::Retry::After(d) =
7725 dlg.http_failure(&response, error.as_ref().ok())
7726 {
7727 sleep(d).await;
7728 continue;
7729 }
7730
7731 dlg.finished(false);
7732
7733 return Err(match error {
7734 Ok(value) => common::Error::BadRequest(value),
7735 _ => common::Error::Failure(response),
7736 });
7737 }
7738 let response = {
7739 let bytes = common::to_bytes(body).await.unwrap_or_default();
7740 let encoded = common::to_string(&bytes);
7741 match serde_json::from_str(&encoded) {
7742 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7743 Err(error) => {
7744 dlg.response_json_decode_error(&encoded, &error);
7745 return Err(common::Error::JsonDecodeError(
7746 encoded.to_string(),
7747 error,
7748 ));
7749 }
7750 }
7751 };
7752
7753 dlg.finished(true);
7754 return Ok(response);
7755 }
7756 }
7757 }
7758 }
7759
7760 /// Required. Identifier. The name of the snapshot to get. Format is `projects/{project}/snapshots/{snap}`.
7761 ///
7762 /// Sets the *snapshot* path property to the given value.
7763 ///
7764 /// Even though the property as already been set when instantiating this call,
7765 /// we provide this method for API completeness.
7766 pub fn snapshot(mut self, new_value: &str) -> ProjectSnapshotGetCall<'a, C> {
7767 self._snapshot = new_value.to_string();
7768 self
7769 }
7770 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7771 /// while executing the actual API request.
7772 ///
7773 /// ````text
7774 /// It should be used to handle progress information, and to implement a certain level of resilience.
7775 /// ````
7776 ///
7777 /// Sets the *delegate* property to the given value.
7778 pub fn delegate(
7779 mut self,
7780 new_value: &'a mut dyn common::Delegate,
7781 ) -> ProjectSnapshotGetCall<'a, C> {
7782 self._delegate = Some(new_value);
7783 self
7784 }
7785
7786 /// Set any additional parameter of the query string used in the request.
7787 /// It should be used to set parameters which are not yet available through their own
7788 /// setters.
7789 ///
7790 /// Please note that this method must not be used to set any of the known parameters
7791 /// which have their own setter method. If done anyway, the request will fail.
7792 ///
7793 /// # Additional Parameters
7794 ///
7795 /// * *$.xgafv* (query-string) - V1 error format.
7796 /// * *access_token* (query-string) - OAuth access token.
7797 /// * *alt* (query-string) - Data format for response.
7798 /// * *callback* (query-string) - JSONP
7799 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7800 /// * *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.
7801 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7802 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7803 /// * *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.
7804 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7805 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7806 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnapshotGetCall<'a, C>
7807 where
7808 T: AsRef<str>,
7809 {
7810 self._additional_params
7811 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7812 self
7813 }
7814
7815 /// Identifies the authorization scope for the method you are building.
7816 ///
7817 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7818 /// [`Scope::CloudPlatform`].
7819 ///
7820 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7821 /// tokens for more than one scope.
7822 ///
7823 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7824 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7825 /// sufficient, a read-write scope will do as well.
7826 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnapshotGetCall<'a, C>
7827 where
7828 St: AsRef<str>,
7829 {
7830 self._scopes.insert(String::from(scope.as_ref()));
7831 self
7832 }
7833 /// Identifies the authorization scope(s) for the method you are building.
7834 ///
7835 /// See [`Self::add_scope()`] for details.
7836 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnapshotGetCall<'a, C>
7837 where
7838 I: IntoIterator<Item = St>,
7839 St: AsRef<str>,
7840 {
7841 self._scopes
7842 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7843 self
7844 }
7845
7846 /// Removes all scopes, and no default scope will be used either.
7847 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7848 /// for details).
7849 pub fn clear_scopes(mut self) -> ProjectSnapshotGetCall<'a, C> {
7850 self._scopes.clear();
7851 self
7852 }
7853}
7854
7855/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
7856///
7857/// A builder for the *snapshots.getIamPolicy* method supported by a *project* resource.
7858/// It is not used directly, but through a [`ProjectMethods`] instance.
7859///
7860/// # Example
7861///
7862/// Instantiate a resource method builder
7863///
7864/// ```test_harness,no_run
7865/// # extern crate hyper;
7866/// # extern crate hyper_rustls;
7867/// # extern crate google_pubsub1 as pubsub1;
7868/// # async fn dox() {
7869/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7870///
7871/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7872/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7873/// # .with_native_roots()
7874/// # .unwrap()
7875/// # .https_only()
7876/// # .enable_http2()
7877/// # .build();
7878///
7879/// # let executor = hyper_util::rt::TokioExecutor::new();
7880/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7881/// # secret,
7882/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7883/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7884/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7885/// # ),
7886/// # ).build().await.unwrap();
7887///
7888/// # let client = hyper_util::client::legacy::Client::builder(
7889/// # hyper_util::rt::TokioExecutor::new()
7890/// # )
7891/// # .build(
7892/// # hyper_rustls::HttpsConnectorBuilder::new()
7893/// # .with_native_roots()
7894/// # .unwrap()
7895/// # .https_or_http()
7896/// # .enable_http2()
7897/// # .build()
7898/// # );
7899/// # let mut hub = Pubsub::new(client, auth);
7900/// // You can configure optional parameters by calling the respective setters at will, and
7901/// // execute the final call using `doit()`.
7902/// // Values shown here are possibly random and not representative !
7903/// let result = hub.projects().snapshots_get_iam_policy("resource")
7904/// .options_requested_policy_version(-17)
7905/// .doit().await;
7906/// # }
7907/// ```
7908pub struct ProjectSnapshotGetIamPolicyCall<'a, C>
7909where
7910 C: 'a,
7911{
7912 hub: &'a Pubsub<C>,
7913 _resource: String,
7914 _options_requested_policy_version: Option<i32>,
7915 _delegate: Option<&'a mut dyn common::Delegate>,
7916 _additional_params: HashMap<String, String>,
7917 _scopes: BTreeSet<String>,
7918}
7919
7920impl<'a, C> common::CallBuilder for ProjectSnapshotGetIamPolicyCall<'a, C> {}
7921
7922impl<'a, C> ProjectSnapshotGetIamPolicyCall<'a, C>
7923where
7924 C: common::Connector,
7925{
7926 /// Perform the operation you have build so far.
7927 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7928 use std::borrow::Cow;
7929 use std::io::{Read, Seek};
7930
7931 use common::{url::Params, ToParts};
7932 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7933
7934 let mut dd = common::DefaultDelegate;
7935 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7936 dlg.begin(common::MethodInfo {
7937 id: "pubsub.projects.snapshots.getIamPolicy",
7938 http_method: hyper::Method::GET,
7939 });
7940
7941 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
7942 if self._additional_params.contains_key(field) {
7943 dlg.finished(false);
7944 return Err(common::Error::FieldClash(field));
7945 }
7946 }
7947
7948 let mut params = Params::with_capacity(4 + self._additional_params.len());
7949 params.push("resource", self._resource);
7950 if let Some(value) = self._options_requested_policy_version.as_ref() {
7951 params.push("options.requestedPolicyVersion", value.to_string());
7952 }
7953
7954 params.extend(self._additional_params.iter());
7955
7956 params.push("alt", "json");
7957 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
7958 if self._scopes.is_empty() {
7959 self._scopes
7960 .insert(Scope::CloudPlatform.as_ref().to_string());
7961 }
7962
7963 #[allow(clippy::single_element_loop)]
7964 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7965 url = params.uri_replacement(url, param_name, find_this, true);
7966 }
7967 {
7968 let to_remove = ["resource"];
7969 params.remove_params(&to_remove);
7970 }
7971
7972 let url = params.parse_with_url(&url);
7973
7974 loop {
7975 let token = match self
7976 .hub
7977 .auth
7978 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7979 .await
7980 {
7981 Ok(token) => token,
7982 Err(e) => match dlg.token(e) {
7983 Ok(token) => token,
7984 Err(e) => {
7985 dlg.finished(false);
7986 return Err(common::Error::MissingToken(e));
7987 }
7988 },
7989 };
7990 let mut req_result = {
7991 let client = &self.hub.client;
7992 dlg.pre_request();
7993 let mut req_builder = hyper::Request::builder()
7994 .method(hyper::Method::GET)
7995 .uri(url.as_str())
7996 .header(USER_AGENT, self.hub._user_agent.clone());
7997
7998 if let Some(token) = token.as_ref() {
7999 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8000 }
8001
8002 let request = req_builder
8003 .header(CONTENT_LENGTH, 0_u64)
8004 .body(common::to_body::<String>(None));
8005
8006 client.request(request.unwrap()).await
8007 };
8008
8009 match req_result {
8010 Err(err) => {
8011 if let common::Retry::After(d) = dlg.http_error(&err) {
8012 sleep(d).await;
8013 continue;
8014 }
8015 dlg.finished(false);
8016 return Err(common::Error::HttpError(err));
8017 }
8018 Ok(res) => {
8019 let (mut parts, body) = res.into_parts();
8020 let mut body = common::Body::new(body);
8021 if !parts.status.is_success() {
8022 let bytes = common::to_bytes(body).await.unwrap_or_default();
8023 let error = serde_json::from_str(&common::to_string(&bytes));
8024 let response = common::to_response(parts, bytes.into());
8025
8026 if let common::Retry::After(d) =
8027 dlg.http_failure(&response, error.as_ref().ok())
8028 {
8029 sleep(d).await;
8030 continue;
8031 }
8032
8033 dlg.finished(false);
8034
8035 return Err(match error {
8036 Ok(value) => common::Error::BadRequest(value),
8037 _ => common::Error::Failure(response),
8038 });
8039 }
8040 let response = {
8041 let bytes = common::to_bytes(body).await.unwrap_or_default();
8042 let encoded = common::to_string(&bytes);
8043 match serde_json::from_str(&encoded) {
8044 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8045 Err(error) => {
8046 dlg.response_json_decode_error(&encoded, &error);
8047 return Err(common::Error::JsonDecodeError(
8048 encoded.to_string(),
8049 error,
8050 ));
8051 }
8052 }
8053 };
8054
8055 dlg.finished(true);
8056 return Ok(response);
8057 }
8058 }
8059 }
8060 }
8061
8062 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8063 ///
8064 /// Sets the *resource* path property to the given value.
8065 ///
8066 /// Even though the property as already been set when instantiating this call,
8067 /// we provide this method for API completeness.
8068 pub fn resource(mut self, new_value: &str) -> ProjectSnapshotGetIamPolicyCall<'a, C> {
8069 self._resource = new_value.to_string();
8070 self
8071 }
8072 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
8073 ///
8074 /// Sets the *options.requested policy version* query property to the given value.
8075 pub fn options_requested_policy_version(
8076 mut self,
8077 new_value: i32,
8078 ) -> ProjectSnapshotGetIamPolicyCall<'a, C> {
8079 self._options_requested_policy_version = Some(new_value);
8080 self
8081 }
8082 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8083 /// while executing the actual API request.
8084 ///
8085 /// ````text
8086 /// It should be used to handle progress information, and to implement a certain level of resilience.
8087 /// ````
8088 ///
8089 /// Sets the *delegate* property to the given value.
8090 pub fn delegate(
8091 mut self,
8092 new_value: &'a mut dyn common::Delegate,
8093 ) -> ProjectSnapshotGetIamPolicyCall<'a, C> {
8094 self._delegate = Some(new_value);
8095 self
8096 }
8097
8098 /// Set any additional parameter of the query string used in the request.
8099 /// It should be used to set parameters which are not yet available through their own
8100 /// setters.
8101 ///
8102 /// Please note that this method must not be used to set any of the known parameters
8103 /// which have their own setter method. If done anyway, the request will fail.
8104 ///
8105 /// # Additional Parameters
8106 ///
8107 /// * *$.xgafv* (query-string) - V1 error format.
8108 /// * *access_token* (query-string) - OAuth access token.
8109 /// * *alt* (query-string) - Data format for response.
8110 /// * *callback* (query-string) - JSONP
8111 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8112 /// * *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.
8113 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8114 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8115 /// * *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.
8116 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8117 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8118 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnapshotGetIamPolicyCall<'a, C>
8119 where
8120 T: AsRef<str>,
8121 {
8122 self._additional_params
8123 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8124 self
8125 }
8126
8127 /// Identifies the authorization scope for the method you are building.
8128 ///
8129 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8130 /// [`Scope::CloudPlatform`].
8131 ///
8132 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8133 /// tokens for more than one scope.
8134 ///
8135 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8136 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8137 /// sufficient, a read-write scope will do as well.
8138 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnapshotGetIamPolicyCall<'a, C>
8139 where
8140 St: AsRef<str>,
8141 {
8142 self._scopes.insert(String::from(scope.as_ref()));
8143 self
8144 }
8145 /// Identifies the authorization scope(s) for the method you are building.
8146 ///
8147 /// See [`Self::add_scope()`] for details.
8148 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnapshotGetIamPolicyCall<'a, C>
8149 where
8150 I: IntoIterator<Item = St>,
8151 St: AsRef<str>,
8152 {
8153 self._scopes
8154 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8155 self
8156 }
8157
8158 /// Removes all scopes, and no default scope will be used either.
8159 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8160 /// for details).
8161 pub fn clear_scopes(mut self) -> ProjectSnapshotGetIamPolicyCall<'a, C> {
8162 self._scopes.clear();
8163 self
8164 }
8165}
8166
8167/// Lists the existing snapshots. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
8168///
8169/// A builder for the *snapshots.list* method supported by a *project* resource.
8170/// It is not used directly, but through a [`ProjectMethods`] instance.
8171///
8172/// # Example
8173///
8174/// Instantiate a resource method builder
8175///
8176/// ```test_harness,no_run
8177/// # extern crate hyper;
8178/// # extern crate hyper_rustls;
8179/// # extern crate google_pubsub1 as pubsub1;
8180/// # async fn dox() {
8181/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8182///
8183/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8184/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8185/// # .with_native_roots()
8186/// # .unwrap()
8187/// # .https_only()
8188/// # .enable_http2()
8189/// # .build();
8190///
8191/// # let executor = hyper_util::rt::TokioExecutor::new();
8192/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8193/// # secret,
8194/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8195/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8196/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8197/// # ),
8198/// # ).build().await.unwrap();
8199///
8200/// # let client = hyper_util::client::legacy::Client::builder(
8201/// # hyper_util::rt::TokioExecutor::new()
8202/// # )
8203/// # .build(
8204/// # hyper_rustls::HttpsConnectorBuilder::new()
8205/// # .with_native_roots()
8206/// # .unwrap()
8207/// # .https_or_http()
8208/// # .enable_http2()
8209/// # .build()
8210/// # );
8211/// # let mut hub = Pubsub::new(client, auth);
8212/// // You can configure optional parameters by calling the respective setters at will, and
8213/// // execute the final call using `doit()`.
8214/// // Values shown here are possibly random and not representative !
8215/// let result = hub.projects().snapshots_list("project")
8216/// .page_token("Lorem")
8217/// .page_size(-25)
8218/// .doit().await;
8219/// # }
8220/// ```
8221pub struct ProjectSnapshotListCall<'a, C>
8222where
8223 C: 'a,
8224{
8225 hub: &'a Pubsub<C>,
8226 _project: String,
8227 _page_token: Option<String>,
8228 _page_size: Option<i32>,
8229 _delegate: Option<&'a mut dyn common::Delegate>,
8230 _additional_params: HashMap<String, String>,
8231 _scopes: BTreeSet<String>,
8232}
8233
8234impl<'a, C> common::CallBuilder for ProjectSnapshotListCall<'a, C> {}
8235
8236impl<'a, C> ProjectSnapshotListCall<'a, C>
8237where
8238 C: common::Connector,
8239{
8240 /// Perform the operation you have build so far.
8241 pub async fn doit(mut self) -> common::Result<(common::Response, ListSnapshotsResponse)> {
8242 use std::borrow::Cow;
8243 use std::io::{Read, Seek};
8244
8245 use common::{url::Params, ToParts};
8246 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8247
8248 let mut dd = common::DefaultDelegate;
8249 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8250 dlg.begin(common::MethodInfo {
8251 id: "pubsub.projects.snapshots.list",
8252 http_method: hyper::Method::GET,
8253 });
8254
8255 for &field in ["alt", "project", "pageToken", "pageSize"].iter() {
8256 if self._additional_params.contains_key(field) {
8257 dlg.finished(false);
8258 return Err(common::Error::FieldClash(field));
8259 }
8260 }
8261
8262 let mut params = Params::with_capacity(5 + self._additional_params.len());
8263 params.push("project", self._project);
8264 if let Some(value) = self._page_token.as_ref() {
8265 params.push("pageToken", value);
8266 }
8267 if let Some(value) = self._page_size.as_ref() {
8268 params.push("pageSize", value.to_string());
8269 }
8270
8271 params.extend(self._additional_params.iter());
8272
8273 params.push("alt", "json");
8274 let mut url = self.hub._base_url.clone() + "v1/{+project}/snapshots";
8275 if self._scopes.is_empty() {
8276 self._scopes
8277 .insert(Scope::CloudPlatform.as_ref().to_string());
8278 }
8279
8280 #[allow(clippy::single_element_loop)]
8281 for &(find_this, param_name) in [("{+project}", "project")].iter() {
8282 url = params.uri_replacement(url, param_name, find_this, true);
8283 }
8284 {
8285 let to_remove = ["project"];
8286 params.remove_params(&to_remove);
8287 }
8288
8289 let url = params.parse_with_url(&url);
8290
8291 loop {
8292 let token = match self
8293 .hub
8294 .auth
8295 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8296 .await
8297 {
8298 Ok(token) => token,
8299 Err(e) => match dlg.token(e) {
8300 Ok(token) => token,
8301 Err(e) => {
8302 dlg.finished(false);
8303 return Err(common::Error::MissingToken(e));
8304 }
8305 },
8306 };
8307 let mut req_result = {
8308 let client = &self.hub.client;
8309 dlg.pre_request();
8310 let mut req_builder = hyper::Request::builder()
8311 .method(hyper::Method::GET)
8312 .uri(url.as_str())
8313 .header(USER_AGENT, self.hub._user_agent.clone());
8314
8315 if let Some(token) = token.as_ref() {
8316 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8317 }
8318
8319 let request = req_builder
8320 .header(CONTENT_LENGTH, 0_u64)
8321 .body(common::to_body::<String>(None));
8322
8323 client.request(request.unwrap()).await
8324 };
8325
8326 match req_result {
8327 Err(err) => {
8328 if let common::Retry::After(d) = dlg.http_error(&err) {
8329 sleep(d).await;
8330 continue;
8331 }
8332 dlg.finished(false);
8333 return Err(common::Error::HttpError(err));
8334 }
8335 Ok(res) => {
8336 let (mut parts, body) = res.into_parts();
8337 let mut body = common::Body::new(body);
8338 if !parts.status.is_success() {
8339 let bytes = common::to_bytes(body).await.unwrap_or_default();
8340 let error = serde_json::from_str(&common::to_string(&bytes));
8341 let response = common::to_response(parts, bytes.into());
8342
8343 if let common::Retry::After(d) =
8344 dlg.http_failure(&response, error.as_ref().ok())
8345 {
8346 sleep(d).await;
8347 continue;
8348 }
8349
8350 dlg.finished(false);
8351
8352 return Err(match error {
8353 Ok(value) => common::Error::BadRequest(value),
8354 _ => common::Error::Failure(response),
8355 });
8356 }
8357 let response = {
8358 let bytes = common::to_bytes(body).await.unwrap_or_default();
8359 let encoded = common::to_string(&bytes);
8360 match serde_json::from_str(&encoded) {
8361 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8362 Err(error) => {
8363 dlg.response_json_decode_error(&encoded, &error);
8364 return Err(common::Error::JsonDecodeError(
8365 encoded.to_string(),
8366 error,
8367 ));
8368 }
8369 }
8370 };
8371
8372 dlg.finished(true);
8373 return Ok(response);
8374 }
8375 }
8376 }
8377 }
8378
8379 /// Required. Identifier. The name of the project in which to list snapshots. Format is `projects/{project-id}`.
8380 ///
8381 /// Sets the *project* path property to the given value.
8382 ///
8383 /// Even though the property as already been set when instantiating this call,
8384 /// we provide this method for API completeness.
8385 pub fn project(mut self, new_value: &str) -> ProjectSnapshotListCall<'a, C> {
8386 self._project = new_value.to_string();
8387 self
8388 }
8389 /// Optional. The value returned by the last `ListSnapshotsResponse`; indicates that this is a continuation of a prior `ListSnapshots` call, and that the system should return the next page of data.
8390 ///
8391 /// Sets the *page token* query property to the given value.
8392 pub fn page_token(mut self, new_value: &str) -> ProjectSnapshotListCall<'a, C> {
8393 self._page_token = Some(new_value.to_string());
8394 self
8395 }
8396 /// Optional. Maximum number of snapshots to return.
8397 ///
8398 /// Sets the *page size* query property to the given value.
8399 pub fn page_size(mut self, new_value: i32) -> ProjectSnapshotListCall<'a, C> {
8400 self._page_size = Some(new_value);
8401 self
8402 }
8403 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8404 /// while executing the actual API request.
8405 ///
8406 /// ````text
8407 /// It should be used to handle progress information, and to implement a certain level of resilience.
8408 /// ````
8409 ///
8410 /// Sets the *delegate* property to the given value.
8411 pub fn delegate(
8412 mut self,
8413 new_value: &'a mut dyn common::Delegate,
8414 ) -> ProjectSnapshotListCall<'a, C> {
8415 self._delegate = Some(new_value);
8416 self
8417 }
8418
8419 /// Set any additional parameter of the query string used in the request.
8420 /// It should be used to set parameters which are not yet available through their own
8421 /// setters.
8422 ///
8423 /// Please note that this method must not be used to set any of the known parameters
8424 /// which have their own setter method. If done anyway, the request will fail.
8425 ///
8426 /// # Additional Parameters
8427 ///
8428 /// * *$.xgafv* (query-string) - V1 error format.
8429 /// * *access_token* (query-string) - OAuth access token.
8430 /// * *alt* (query-string) - Data format for response.
8431 /// * *callback* (query-string) - JSONP
8432 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8433 /// * *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.
8434 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8435 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8436 /// * *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.
8437 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8438 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8439 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnapshotListCall<'a, C>
8440 where
8441 T: AsRef<str>,
8442 {
8443 self._additional_params
8444 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8445 self
8446 }
8447
8448 /// Identifies the authorization scope for the method you are building.
8449 ///
8450 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8451 /// [`Scope::CloudPlatform`].
8452 ///
8453 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8454 /// tokens for more than one scope.
8455 ///
8456 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8457 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8458 /// sufficient, a read-write scope will do as well.
8459 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnapshotListCall<'a, C>
8460 where
8461 St: AsRef<str>,
8462 {
8463 self._scopes.insert(String::from(scope.as_ref()));
8464 self
8465 }
8466 /// Identifies the authorization scope(s) for the method you are building.
8467 ///
8468 /// See [`Self::add_scope()`] for details.
8469 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnapshotListCall<'a, C>
8470 where
8471 I: IntoIterator<Item = St>,
8472 St: AsRef<str>,
8473 {
8474 self._scopes
8475 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8476 self
8477 }
8478
8479 /// Removes all scopes, and no default scope will be used either.
8480 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8481 /// for details).
8482 pub fn clear_scopes(mut self) -> ProjectSnapshotListCall<'a, C> {
8483 self._scopes.clear();
8484 self
8485 }
8486}
8487
8488/// Updates an existing snapshot by updating the fields specified in the update mask. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
8489///
8490/// A builder for the *snapshots.patch* method supported by a *project* resource.
8491/// It is not used directly, but through a [`ProjectMethods`] instance.
8492///
8493/// # Example
8494///
8495/// Instantiate a resource method builder
8496///
8497/// ```test_harness,no_run
8498/// # extern crate hyper;
8499/// # extern crate hyper_rustls;
8500/// # extern crate google_pubsub1 as pubsub1;
8501/// use pubsub1::api::UpdateSnapshotRequest;
8502/// # async fn dox() {
8503/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8504///
8505/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8506/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8507/// # .with_native_roots()
8508/// # .unwrap()
8509/// # .https_only()
8510/// # .enable_http2()
8511/// # .build();
8512///
8513/// # let executor = hyper_util::rt::TokioExecutor::new();
8514/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8515/// # secret,
8516/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8517/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8518/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8519/// # ),
8520/// # ).build().await.unwrap();
8521///
8522/// # let client = hyper_util::client::legacy::Client::builder(
8523/// # hyper_util::rt::TokioExecutor::new()
8524/// # )
8525/// # .build(
8526/// # hyper_rustls::HttpsConnectorBuilder::new()
8527/// # .with_native_roots()
8528/// # .unwrap()
8529/// # .https_or_http()
8530/// # .enable_http2()
8531/// # .build()
8532/// # );
8533/// # let mut hub = Pubsub::new(client, auth);
8534/// // As the method needs a request, you would usually fill it with the desired information
8535/// // into the respective structure. Some of the parts shown here might not be applicable !
8536/// // Values shown here are possibly random and not representative !
8537/// let mut req = UpdateSnapshotRequest::default();
8538///
8539/// // You can configure optional parameters by calling the respective setters at will, and
8540/// // execute the final call using `doit()`.
8541/// // Values shown here are possibly random and not representative !
8542/// let result = hub.projects().snapshots_patch(req, "name")
8543/// .doit().await;
8544/// # }
8545/// ```
8546pub struct ProjectSnapshotPatchCall<'a, C>
8547where
8548 C: 'a,
8549{
8550 hub: &'a Pubsub<C>,
8551 _request: UpdateSnapshotRequest,
8552 _name: String,
8553 _delegate: Option<&'a mut dyn common::Delegate>,
8554 _additional_params: HashMap<String, String>,
8555 _scopes: BTreeSet<String>,
8556}
8557
8558impl<'a, C> common::CallBuilder for ProjectSnapshotPatchCall<'a, C> {}
8559
8560impl<'a, C> ProjectSnapshotPatchCall<'a, C>
8561where
8562 C: common::Connector,
8563{
8564 /// Perform the operation you have build so far.
8565 pub async fn doit(mut self) -> common::Result<(common::Response, Snapshot)> {
8566 use std::borrow::Cow;
8567 use std::io::{Read, Seek};
8568
8569 use common::{url::Params, ToParts};
8570 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8571
8572 let mut dd = common::DefaultDelegate;
8573 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8574 dlg.begin(common::MethodInfo {
8575 id: "pubsub.projects.snapshots.patch",
8576 http_method: hyper::Method::PATCH,
8577 });
8578
8579 for &field in ["alt", "name"].iter() {
8580 if self._additional_params.contains_key(field) {
8581 dlg.finished(false);
8582 return Err(common::Error::FieldClash(field));
8583 }
8584 }
8585
8586 let mut params = Params::with_capacity(4 + self._additional_params.len());
8587 params.push("name", self._name);
8588
8589 params.extend(self._additional_params.iter());
8590
8591 params.push("alt", "json");
8592 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8593 if self._scopes.is_empty() {
8594 self._scopes
8595 .insert(Scope::CloudPlatform.as_ref().to_string());
8596 }
8597
8598 #[allow(clippy::single_element_loop)]
8599 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8600 url = params.uri_replacement(url, param_name, find_this, true);
8601 }
8602 {
8603 let to_remove = ["name"];
8604 params.remove_params(&to_remove);
8605 }
8606
8607 let url = params.parse_with_url(&url);
8608
8609 let mut json_mime_type = mime::APPLICATION_JSON;
8610 let mut request_value_reader = {
8611 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8612 common::remove_json_null_values(&mut value);
8613 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8614 serde_json::to_writer(&mut dst, &value).unwrap();
8615 dst
8616 };
8617 let request_size = request_value_reader
8618 .seek(std::io::SeekFrom::End(0))
8619 .unwrap();
8620 request_value_reader
8621 .seek(std::io::SeekFrom::Start(0))
8622 .unwrap();
8623
8624 loop {
8625 let token = match self
8626 .hub
8627 .auth
8628 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8629 .await
8630 {
8631 Ok(token) => token,
8632 Err(e) => match dlg.token(e) {
8633 Ok(token) => token,
8634 Err(e) => {
8635 dlg.finished(false);
8636 return Err(common::Error::MissingToken(e));
8637 }
8638 },
8639 };
8640 request_value_reader
8641 .seek(std::io::SeekFrom::Start(0))
8642 .unwrap();
8643 let mut req_result = {
8644 let client = &self.hub.client;
8645 dlg.pre_request();
8646 let mut req_builder = hyper::Request::builder()
8647 .method(hyper::Method::PATCH)
8648 .uri(url.as_str())
8649 .header(USER_AGENT, self.hub._user_agent.clone());
8650
8651 if let Some(token) = token.as_ref() {
8652 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8653 }
8654
8655 let request = req_builder
8656 .header(CONTENT_TYPE, json_mime_type.to_string())
8657 .header(CONTENT_LENGTH, request_size as u64)
8658 .body(common::to_body(
8659 request_value_reader.get_ref().clone().into(),
8660 ));
8661
8662 client.request(request.unwrap()).await
8663 };
8664
8665 match req_result {
8666 Err(err) => {
8667 if let common::Retry::After(d) = dlg.http_error(&err) {
8668 sleep(d).await;
8669 continue;
8670 }
8671 dlg.finished(false);
8672 return Err(common::Error::HttpError(err));
8673 }
8674 Ok(res) => {
8675 let (mut parts, body) = res.into_parts();
8676 let mut body = common::Body::new(body);
8677 if !parts.status.is_success() {
8678 let bytes = common::to_bytes(body).await.unwrap_or_default();
8679 let error = serde_json::from_str(&common::to_string(&bytes));
8680 let response = common::to_response(parts, bytes.into());
8681
8682 if let common::Retry::After(d) =
8683 dlg.http_failure(&response, error.as_ref().ok())
8684 {
8685 sleep(d).await;
8686 continue;
8687 }
8688
8689 dlg.finished(false);
8690
8691 return Err(match error {
8692 Ok(value) => common::Error::BadRequest(value),
8693 _ => common::Error::Failure(response),
8694 });
8695 }
8696 let response = {
8697 let bytes = common::to_bytes(body).await.unwrap_or_default();
8698 let encoded = common::to_string(&bytes);
8699 match serde_json::from_str(&encoded) {
8700 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8701 Err(error) => {
8702 dlg.response_json_decode_error(&encoded, &error);
8703 return Err(common::Error::JsonDecodeError(
8704 encoded.to_string(),
8705 error,
8706 ));
8707 }
8708 }
8709 };
8710
8711 dlg.finished(true);
8712 return Ok(response);
8713 }
8714 }
8715 }
8716 }
8717
8718 ///
8719 /// Sets the *request* property to the given value.
8720 ///
8721 /// Even though the property as already been set when instantiating this call,
8722 /// we provide this method for API completeness.
8723 pub fn request(mut self, new_value: UpdateSnapshotRequest) -> ProjectSnapshotPatchCall<'a, C> {
8724 self._request = new_value;
8725 self
8726 }
8727 /// Optional. The name of the snapshot.
8728 ///
8729 /// Sets the *name* path property to the given value.
8730 ///
8731 /// Even though the property as already been set when instantiating this call,
8732 /// we provide this method for API completeness.
8733 pub fn name(mut self, new_value: &str) -> ProjectSnapshotPatchCall<'a, C> {
8734 self._name = new_value.to_string();
8735 self
8736 }
8737 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8738 /// while executing the actual API request.
8739 ///
8740 /// ````text
8741 /// It should be used to handle progress information, and to implement a certain level of resilience.
8742 /// ````
8743 ///
8744 /// Sets the *delegate* property to the given value.
8745 pub fn delegate(
8746 mut self,
8747 new_value: &'a mut dyn common::Delegate,
8748 ) -> ProjectSnapshotPatchCall<'a, C> {
8749 self._delegate = Some(new_value);
8750 self
8751 }
8752
8753 /// Set any additional parameter of the query string used in the request.
8754 /// It should be used to set parameters which are not yet available through their own
8755 /// setters.
8756 ///
8757 /// Please note that this method must not be used to set any of the known parameters
8758 /// which have their own setter method. If done anyway, the request will fail.
8759 ///
8760 /// # Additional Parameters
8761 ///
8762 /// * *$.xgafv* (query-string) - V1 error format.
8763 /// * *access_token* (query-string) - OAuth access token.
8764 /// * *alt* (query-string) - Data format for response.
8765 /// * *callback* (query-string) - JSONP
8766 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8767 /// * *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.
8768 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8769 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8770 /// * *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.
8771 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8772 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8773 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnapshotPatchCall<'a, C>
8774 where
8775 T: AsRef<str>,
8776 {
8777 self._additional_params
8778 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8779 self
8780 }
8781
8782 /// Identifies the authorization scope for the method you are building.
8783 ///
8784 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8785 /// [`Scope::CloudPlatform`].
8786 ///
8787 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8788 /// tokens for more than one scope.
8789 ///
8790 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8791 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8792 /// sufficient, a read-write scope will do as well.
8793 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnapshotPatchCall<'a, C>
8794 where
8795 St: AsRef<str>,
8796 {
8797 self._scopes.insert(String::from(scope.as_ref()));
8798 self
8799 }
8800 /// Identifies the authorization scope(s) for the method you are building.
8801 ///
8802 /// See [`Self::add_scope()`] for details.
8803 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnapshotPatchCall<'a, C>
8804 where
8805 I: IntoIterator<Item = St>,
8806 St: AsRef<str>,
8807 {
8808 self._scopes
8809 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8810 self
8811 }
8812
8813 /// Removes all scopes, and no default scope will be used either.
8814 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8815 /// for details).
8816 pub fn clear_scopes(mut self) -> ProjectSnapshotPatchCall<'a, C> {
8817 self._scopes.clear();
8818 self
8819 }
8820}
8821
8822/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
8823///
8824/// A builder for the *snapshots.setIamPolicy* method supported by a *project* resource.
8825/// It is not used directly, but through a [`ProjectMethods`] instance.
8826///
8827/// # Example
8828///
8829/// Instantiate a resource method builder
8830///
8831/// ```test_harness,no_run
8832/// # extern crate hyper;
8833/// # extern crate hyper_rustls;
8834/// # extern crate google_pubsub1 as pubsub1;
8835/// use pubsub1::api::SetIamPolicyRequest;
8836/// # async fn dox() {
8837/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8838///
8839/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8840/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8841/// # .with_native_roots()
8842/// # .unwrap()
8843/// # .https_only()
8844/// # .enable_http2()
8845/// # .build();
8846///
8847/// # let executor = hyper_util::rt::TokioExecutor::new();
8848/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8849/// # secret,
8850/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8851/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8852/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8853/// # ),
8854/// # ).build().await.unwrap();
8855///
8856/// # let client = hyper_util::client::legacy::Client::builder(
8857/// # hyper_util::rt::TokioExecutor::new()
8858/// # )
8859/// # .build(
8860/// # hyper_rustls::HttpsConnectorBuilder::new()
8861/// # .with_native_roots()
8862/// # .unwrap()
8863/// # .https_or_http()
8864/// # .enable_http2()
8865/// # .build()
8866/// # );
8867/// # let mut hub = Pubsub::new(client, auth);
8868/// // As the method needs a request, you would usually fill it with the desired information
8869/// // into the respective structure. Some of the parts shown here might not be applicable !
8870/// // Values shown here are possibly random and not representative !
8871/// let mut req = SetIamPolicyRequest::default();
8872///
8873/// // You can configure optional parameters by calling the respective setters at will, and
8874/// // execute the final call using `doit()`.
8875/// // Values shown here are possibly random and not representative !
8876/// let result = hub.projects().snapshots_set_iam_policy(req, "resource")
8877/// .doit().await;
8878/// # }
8879/// ```
8880pub struct ProjectSnapshotSetIamPolicyCall<'a, C>
8881where
8882 C: 'a,
8883{
8884 hub: &'a Pubsub<C>,
8885 _request: SetIamPolicyRequest,
8886 _resource: String,
8887 _delegate: Option<&'a mut dyn common::Delegate>,
8888 _additional_params: HashMap<String, String>,
8889 _scopes: BTreeSet<String>,
8890}
8891
8892impl<'a, C> common::CallBuilder for ProjectSnapshotSetIamPolicyCall<'a, C> {}
8893
8894impl<'a, C> ProjectSnapshotSetIamPolicyCall<'a, C>
8895where
8896 C: common::Connector,
8897{
8898 /// Perform the operation you have build so far.
8899 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8900 use std::borrow::Cow;
8901 use std::io::{Read, Seek};
8902
8903 use common::{url::Params, ToParts};
8904 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8905
8906 let mut dd = common::DefaultDelegate;
8907 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8908 dlg.begin(common::MethodInfo {
8909 id: "pubsub.projects.snapshots.setIamPolicy",
8910 http_method: hyper::Method::POST,
8911 });
8912
8913 for &field in ["alt", "resource"].iter() {
8914 if self._additional_params.contains_key(field) {
8915 dlg.finished(false);
8916 return Err(common::Error::FieldClash(field));
8917 }
8918 }
8919
8920 let mut params = Params::with_capacity(4 + self._additional_params.len());
8921 params.push("resource", self._resource);
8922
8923 params.extend(self._additional_params.iter());
8924
8925 params.push("alt", "json");
8926 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
8927 if self._scopes.is_empty() {
8928 self._scopes
8929 .insert(Scope::CloudPlatform.as_ref().to_string());
8930 }
8931
8932 #[allow(clippy::single_element_loop)]
8933 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8934 url = params.uri_replacement(url, param_name, find_this, true);
8935 }
8936 {
8937 let to_remove = ["resource"];
8938 params.remove_params(&to_remove);
8939 }
8940
8941 let url = params.parse_with_url(&url);
8942
8943 let mut json_mime_type = mime::APPLICATION_JSON;
8944 let mut request_value_reader = {
8945 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8946 common::remove_json_null_values(&mut value);
8947 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8948 serde_json::to_writer(&mut dst, &value).unwrap();
8949 dst
8950 };
8951 let request_size = request_value_reader
8952 .seek(std::io::SeekFrom::End(0))
8953 .unwrap();
8954 request_value_reader
8955 .seek(std::io::SeekFrom::Start(0))
8956 .unwrap();
8957
8958 loop {
8959 let token = match self
8960 .hub
8961 .auth
8962 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8963 .await
8964 {
8965 Ok(token) => token,
8966 Err(e) => match dlg.token(e) {
8967 Ok(token) => token,
8968 Err(e) => {
8969 dlg.finished(false);
8970 return Err(common::Error::MissingToken(e));
8971 }
8972 },
8973 };
8974 request_value_reader
8975 .seek(std::io::SeekFrom::Start(0))
8976 .unwrap();
8977 let mut req_result = {
8978 let client = &self.hub.client;
8979 dlg.pre_request();
8980 let mut req_builder = hyper::Request::builder()
8981 .method(hyper::Method::POST)
8982 .uri(url.as_str())
8983 .header(USER_AGENT, self.hub._user_agent.clone());
8984
8985 if let Some(token) = token.as_ref() {
8986 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8987 }
8988
8989 let request = req_builder
8990 .header(CONTENT_TYPE, json_mime_type.to_string())
8991 .header(CONTENT_LENGTH, request_size as u64)
8992 .body(common::to_body(
8993 request_value_reader.get_ref().clone().into(),
8994 ));
8995
8996 client.request(request.unwrap()).await
8997 };
8998
8999 match req_result {
9000 Err(err) => {
9001 if let common::Retry::After(d) = dlg.http_error(&err) {
9002 sleep(d).await;
9003 continue;
9004 }
9005 dlg.finished(false);
9006 return Err(common::Error::HttpError(err));
9007 }
9008 Ok(res) => {
9009 let (mut parts, body) = res.into_parts();
9010 let mut body = common::Body::new(body);
9011 if !parts.status.is_success() {
9012 let bytes = common::to_bytes(body).await.unwrap_or_default();
9013 let error = serde_json::from_str(&common::to_string(&bytes));
9014 let response = common::to_response(parts, bytes.into());
9015
9016 if let common::Retry::After(d) =
9017 dlg.http_failure(&response, error.as_ref().ok())
9018 {
9019 sleep(d).await;
9020 continue;
9021 }
9022
9023 dlg.finished(false);
9024
9025 return Err(match error {
9026 Ok(value) => common::Error::BadRequest(value),
9027 _ => common::Error::Failure(response),
9028 });
9029 }
9030 let response = {
9031 let bytes = common::to_bytes(body).await.unwrap_or_default();
9032 let encoded = common::to_string(&bytes);
9033 match serde_json::from_str(&encoded) {
9034 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9035 Err(error) => {
9036 dlg.response_json_decode_error(&encoded, &error);
9037 return Err(common::Error::JsonDecodeError(
9038 encoded.to_string(),
9039 error,
9040 ));
9041 }
9042 }
9043 };
9044
9045 dlg.finished(true);
9046 return Ok(response);
9047 }
9048 }
9049 }
9050 }
9051
9052 ///
9053 /// Sets the *request* property to the given value.
9054 ///
9055 /// Even though the property as already been set when instantiating this call,
9056 /// we provide this method for API completeness.
9057 pub fn request(
9058 mut self,
9059 new_value: SetIamPolicyRequest,
9060 ) -> ProjectSnapshotSetIamPolicyCall<'a, C> {
9061 self._request = new_value;
9062 self
9063 }
9064 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
9065 ///
9066 /// Sets the *resource* path property to the given value.
9067 ///
9068 /// Even though the property as already been set when instantiating this call,
9069 /// we provide this method for API completeness.
9070 pub fn resource(mut self, new_value: &str) -> ProjectSnapshotSetIamPolicyCall<'a, C> {
9071 self._resource = new_value.to_string();
9072 self
9073 }
9074 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9075 /// while executing the actual API request.
9076 ///
9077 /// ````text
9078 /// It should be used to handle progress information, and to implement a certain level of resilience.
9079 /// ````
9080 ///
9081 /// Sets the *delegate* property to the given value.
9082 pub fn delegate(
9083 mut self,
9084 new_value: &'a mut dyn common::Delegate,
9085 ) -> ProjectSnapshotSetIamPolicyCall<'a, C> {
9086 self._delegate = Some(new_value);
9087 self
9088 }
9089
9090 /// Set any additional parameter of the query string used in the request.
9091 /// It should be used to set parameters which are not yet available through their own
9092 /// setters.
9093 ///
9094 /// Please note that this method must not be used to set any of the known parameters
9095 /// which have their own setter method. If done anyway, the request will fail.
9096 ///
9097 /// # Additional Parameters
9098 ///
9099 /// * *$.xgafv* (query-string) - V1 error format.
9100 /// * *access_token* (query-string) - OAuth access token.
9101 /// * *alt* (query-string) - Data format for response.
9102 /// * *callback* (query-string) - JSONP
9103 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9104 /// * *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.
9105 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9106 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9107 /// * *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.
9108 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9109 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9110 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnapshotSetIamPolicyCall<'a, C>
9111 where
9112 T: AsRef<str>,
9113 {
9114 self._additional_params
9115 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9116 self
9117 }
9118
9119 /// Identifies the authorization scope for the method you are building.
9120 ///
9121 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9122 /// [`Scope::CloudPlatform`].
9123 ///
9124 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9125 /// tokens for more than one scope.
9126 ///
9127 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9128 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9129 /// sufficient, a read-write scope will do as well.
9130 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnapshotSetIamPolicyCall<'a, C>
9131 where
9132 St: AsRef<str>,
9133 {
9134 self._scopes.insert(String::from(scope.as_ref()));
9135 self
9136 }
9137 /// Identifies the authorization scope(s) for the method you are building.
9138 ///
9139 /// See [`Self::add_scope()`] for details.
9140 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnapshotSetIamPolicyCall<'a, C>
9141 where
9142 I: IntoIterator<Item = St>,
9143 St: AsRef<str>,
9144 {
9145 self._scopes
9146 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9147 self
9148 }
9149
9150 /// Removes all scopes, and no default scope will be used either.
9151 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9152 /// for details).
9153 pub fn clear_scopes(mut self) -> ProjectSnapshotSetIamPolicyCall<'a, C> {
9154 self._scopes.clear();
9155 self
9156 }
9157}
9158
9159/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
9160///
9161/// A builder for the *snapshots.testIamPermissions* method supported by a *project* resource.
9162/// It is not used directly, but through a [`ProjectMethods`] instance.
9163///
9164/// # Example
9165///
9166/// Instantiate a resource method builder
9167///
9168/// ```test_harness,no_run
9169/// # extern crate hyper;
9170/// # extern crate hyper_rustls;
9171/// # extern crate google_pubsub1 as pubsub1;
9172/// use pubsub1::api::TestIamPermissionsRequest;
9173/// # async fn dox() {
9174/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9175///
9176/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9177/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9178/// # .with_native_roots()
9179/// # .unwrap()
9180/// # .https_only()
9181/// # .enable_http2()
9182/// # .build();
9183///
9184/// # let executor = hyper_util::rt::TokioExecutor::new();
9185/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9186/// # secret,
9187/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9188/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9189/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9190/// # ),
9191/// # ).build().await.unwrap();
9192///
9193/// # let client = hyper_util::client::legacy::Client::builder(
9194/// # hyper_util::rt::TokioExecutor::new()
9195/// # )
9196/// # .build(
9197/// # hyper_rustls::HttpsConnectorBuilder::new()
9198/// # .with_native_roots()
9199/// # .unwrap()
9200/// # .https_or_http()
9201/// # .enable_http2()
9202/// # .build()
9203/// # );
9204/// # let mut hub = Pubsub::new(client, auth);
9205/// // As the method needs a request, you would usually fill it with the desired information
9206/// // into the respective structure. Some of the parts shown here might not be applicable !
9207/// // Values shown here are possibly random and not representative !
9208/// let mut req = TestIamPermissionsRequest::default();
9209///
9210/// // You can configure optional parameters by calling the respective setters at will, and
9211/// // execute the final call using `doit()`.
9212/// // Values shown here are possibly random and not representative !
9213/// let result = hub.projects().snapshots_test_iam_permissions(req, "resource")
9214/// .doit().await;
9215/// # }
9216/// ```
9217pub struct ProjectSnapshotTestIamPermissionCall<'a, C>
9218where
9219 C: 'a,
9220{
9221 hub: &'a Pubsub<C>,
9222 _request: TestIamPermissionsRequest,
9223 _resource: String,
9224 _delegate: Option<&'a mut dyn common::Delegate>,
9225 _additional_params: HashMap<String, String>,
9226 _scopes: BTreeSet<String>,
9227}
9228
9229impl<'a, C> common::CallBuilder for ProjectSnapshotTestIamPermissionCall<'a, C> {}
9230
9231impl<'a, C> ProjectSnapshotTestIamPermissionCall<'a, C>
9232where
9233 C: common::Connector,
9234{
9235 /// Perform the operation you have build so far.
9236 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
9237 use std::borrow::Cow;
9238 use std::io::{Read, Seek};
9239
9240 use common::{url::Params, ToParts};
9241 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9242
9243 let mut dd = common::DefaultDelegate;
9244 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9245 dlg.begin(common::MethodInfo {
9246 id: "pubsub.projects.snapshots.testIamPermissions",
9247 http_method: hyper::Method::POST,
9248 });
9249
9250 for &field in ["alt", "resource"].iter() {
9251 if self._additional_params.contains_key(field) {
9252 dlg.finished(false);
9253 return Err(common::Error::FieldClash(field));
9254 }
9255 }
9256
9257 let mut params = Params::with_capacity(4 + self._additional_params.len());
9258 params.push("resource", self._resource);
9259
9260 params.extend(self._additional_params.iter());
9261
9262 params.push("alt", "json");
9263 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
9264 if self._scopes.is_empty() {
9265 self._scopes
9266 .insert(Scope::CloudPlatform.as_ref().to_string());
9267 }
9268
9269 #[allow(clippy::single_element_loop)]
9270 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9271 url = params.uri_replacement(url, param_name, find_this, true);
9272 }
9273 {
9274 let to_remove = ["resource"];
9275 params.remove_params(&to_remove);
9276 }
9277
9278 let url = params.parse_with_url(&url);
9279
9280 let mut json_mime_type = mime::APPLICATION_JSON;
9281 let mut request_value_reader = {
9282 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9283 common::remove_json_null_values(&mut value);
9284 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9285 serde_json::to_writer(&mut dst, &value).unwrap();
9286 dst
9287 };
9288 let request_size = request_value_reader
9289 .seek(std::io::SeekFrom::End(0))
9290 .unwrap();
9291 request_value_reader
9292 .seek(std::io::SeekFrom::Start(0))
9293 .unwrap();
9294
9295 loop {
9296 let token = match self
9297 .hub
9298 .auth
9299 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9300 .await
9301 {
9302 Ok(token) => token,
9303 Err(e) => match dlg.token(e) {
9304 Ok(token) => token,
9305 Err(e) => {
9306 dlg.finished(false);
9307 return Err(common::Error::MissingToken(e));
9308 }
9309 },
9310 };
9311 request_value_reader
9312 .seek(std::io::SeekFrom::Start(0))
9313 .unwrap();
9314 let mut req_result = {
9315 let client = &self.hub.client;
9316 dlg.pre_request();
9317 let mut req_builder = hyper::Request::builder()
9318 .method(hyper::Method::POST)
9319 .uri(url.as_str())
9320 .header(USER_AGENT, self.hub._user_agent.clone());
9321
9322 if let Some(token) = token.as_ref() {
9323 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9324 }
9325
9326 let request = req_builder
9327 .header(CONTENT_TYPE, json_mime_type.to_string())
9328 .header(CONTENT_LENGTH, request_size as u64)
9329 .body(common::to_body(
9330 request_value_reader.get_ref().clone().into(),
9331 ));
9332
9333 client.request(request.unwrap()).await
9334 };
9335
9336 match req_result {
9337 Err(err) => {
9338 if let common::Retry::After(d) = dlg.http_error(&err) {
9339 sleep(d).await;
9340 continue;
9341 }
9342 dlg.finished(false);
9343 return Err(common::Error::HttpError(err));
9344 }
9345 Ok(res) => {
9346 let (mut parts, body) = res.into_parts();
9347 let mut body = common::Body::new(body);
9348 if !parts.status.is_success() {
9349 let bytes = common::to_bytes(body).await.unwrap_or_default();
9350 let error = serde_json::from_str(&common::to_string(&bytes));
9351 let response = common::to_response(parts, bytes.into());
9352
9353 if let common::Retry::After(d) =
9354 dlg.http_failure(&response, error.as_ref().ok())
9355 {
9356 sleep(d).await;
9357 continue;
9358 }
9359
9360 dlg.finished(false);
9361
9362 return Err(match error {
9363 Ok(value) => common::Error::BadRequest(value),
9364 _ => common::Error::Failure(response),
9365 });
9366 }
9367 let response = {
9368 let bytes = common::to_bytes(body).await.unwrap_or_default();
9369 let encoded = common::to_string(&bytes);
9370 match serde_json::from_str(&encoded) {
9371 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9372 Err(error) => {
9373 dlg.response_json_decode_error(&encoded, &error);
9374 return Err(common::Error::JsonDecodeError(
9375 encoded.to_string(),
9376 error,
9377 ));
9378 }
9379 }
9380 };
9381
9382 dlg.finished(true);
9383 return Ok(response);
9384 }
9385 }
9386 }
9387 }
9388
9389 ///
9390 /// Sets the *request* property to the given value.
9391 ///
9392 /// Even though the property as already been set when instantiating this call,
9393 /// we provide this method for API completeness.
9394 pub fn request(
9395 mut self,
9396 new_value: TestIamPermissionsRequest,
9397 ) -> ProjectSnapshotTestIamPermissionCall<'a, C> {
9398 self._request = new_value;
9399 self
9400 }
9401 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
9402 ///
9403 /// Sets the *resource* path property to the given value.
9404 ///
9405 /// Even though the property as already been set when instantiating this call,
9406 /// we provide this method for API completeness.
9407 pub fn resource(mut self, new_value: &str) -> ProjectSnapshotTestIamPermissionCall<'a, C> {
9408 self._resource = new_value.to_string();
9409 self
9410 }
9411 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9412 /// while executing the actual API request.
9413 ///
9414 /// ````text
9415 /// It should be used to handle progress information, and to implement a certain level of resilience.
9416 /// ````
9417 ///
9418 /// Sets the *delegate* property to the given value.
9419 pub fn delegate(
9420 mut self,
9421 new_value: &'a mut dyn common::Delegate,
9422 ) -> ProjectSnapshotTestIamPermissionCall<'a, C> {
9423 self._delegate = Some(new_value);
9424 self
9425 }
9426
9427 /// Set any additional parameter of the query string used in the request.
9428 /// It should be used to set parameters which are not yet available through their own
9429 /// setters.
9430 ///
9431 /// Please note that this method must not be used to set any of the known parameters
9432 /// which have their own setter method. If done anyway, the request will fail.
9433 ///
9434 /// # Additional Parameters
9435 ///
9436 /// * *$.xgafv* (query-string) - V1 error format.
9437 /// * *access_token* (query-string) - OAuth access token.
9438 /// * *alt* (query-string) - Data format for response.
9439 /// * *callback* (query-string) - JSONP
9440 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9441 /// * *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.
9442 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9443 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9444 /// * *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.
9445 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9446 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9447 pub fn param<T>(mut self, name: T, value: T) -> ProjectSnapshotTestIamPermissionCall<'a, C>
9448 where
9449 T: AsRef<str>,
9450 {
9451 self._additional_params
9452 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9453 self
9454 }
9455
9456 /// Identifies the authorization scope for the method you are building.
9457 ///
9458 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9459 /// [`Scope::CloudPlatform`].
9460 ///
9461 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9462 /// tokens for more than one scope.
9463 ///
9464 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9465 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9466 /// sufficient, a read-write scope will do as well.
9467 pub fn add_scope<St>(mut self, scope: St) -> ProjectSnapshotTestIamPermissionCall<'a, C>
9468 where
9469 St: AsRef<str>,
9470 {
9471 self._scopes.insert(String::from(scope.as_ref()));
9472 self
9473 }
9474 /// Identifies the authorization scope(s) for the method you are building.
9475 ///
9476 /// See [`Self::add_scope()`] for details.
9477 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSnapshotTestIamPermissionCall<'a, C>
9478 where
9479 I: IntoIterator<Item = St>,
9480 St: AsRef<str>,
9481 {
9482 self._scopes
9483 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9484 self
9485 }
9486
9487 /// Removes all scopes, and no default scope will be used either.
9488 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9489 /// for details).
9490 pub fn clear_scopes(mut self) -> ProjectSnapshotTestIamPermissionCall<'a, C> {
9491 self._scopes.clear();
9492 self
9493 }
9494}
9495
9496/// Acknowledges the messages associated with the `ack_ids` in the `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages from the subscription. Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.
9497///
9498/// A builder for the *subscriptions.acknowledge* method supported by a *project* resource.
9499/// It is not used directly, but through a [`ProjectMethods`] instance.
9500///
9501/// # Example
9502///
9503/// Instantiate a resource method builder
9504///
9505/// ```test_harness,no_run
9506/// # extern crate hyper;
9507/// # extern crate hyper_rustls;
9508/// # extern crate google_pubsub1 as pubsub1;
9509/// use pubsub1::api::AcknowledgeRequest;
9510/// # async fn dox() {
9511/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9512///
9513/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9514/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9515/// # .with_native_roots()
9516/// # .unwrap()
9517/// # .https_only()
9518/// # .enable_http2()
9519/// # .build();
9520///
9521/// # let executor = hyper_util::rt::TokioExecutor::new();
9522/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9523/// # secret,
9524/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9525/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9526/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9527/// # ),
9528/// # ).build().await.unwrap();
9529///
9530/// # let client = hyper_util::client::legacy::Client::builder(
9531/// # hyper_util::rt::TokioExecutor::new()
9532/// # )
9533/// # .build(
9534/// # hyper_rustls::HttpsConnectorBuilder::new()
9535/// # .with_native_roots()
9536/// # .unwrap()
9537/// # .https_or_http()
9538/// # .enable_http2()
9539/// # .build()
9540/// # );
9541/// # let mut hub = Pubsub::new(client, auth);
9542/// // As the method needs a request, you would usually fill it with the desired information
9543/// // into the respective structure. Some of the parts shown here might not be applicable !
9544/// // Values shown here are possibly random and not representative !
9545/// let mut req = AcknowledgeRequest::default();
9546///
9547/// // You can configure optional parameters by calling the respective setters at will, and
9548/// // execute the final call using `doit()`.
9549/// // Values shown here are possibly random and not representative !
9550/// let result = hub.projects().subscriptions_acknowledge(req, "subscription")
9551/// .doit().await;
9552/// # }
9553/// ```
9554pub struct ProjectSubscriptionAcknowledgeCall<'a, C>
9555where
9556 C: 'a,
9557{
9558 hub: &'a Pubsub<C>,
9559 _request: AcknowledgeRequest,
9560 _subscription: String,
9561 _delegate: Option<&'a mut dyn common::Delegate>,
9562 _additional_params: HashMap<String, String>,
9563 _scopes: BTreeSet<String>,
9564}
9565
9566impl<'a, C> common::CallBuilder for ProjectSubscriptionAcknowledgeCall<'a, C> {}
9567
9568impl<'a, C> ProjectSubscriptionAcknowledgeCall<'a, C>
9569where
9570 C: common::Connector,
9571{
9572 /// Perform the operation you have build so far.
9573 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9574 use std::borrow::Cow;
9575 use std::io::{Read, Seek};
9576
9577 use common::{url::Params, ToParts};
9578 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9579
9580 let mut dd = common::DefaultDelegate;
9581 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9582 dlg.begin(common::MethodInfo {
9583 id: "pubsub.projects.subscriptions.acknowledge",
9584 http_method: hyper::Method::POST,
9585 });
9586
9587 for &field in ["alt", "subscription"].iter() {
9588 if self._additional_params.contains_key(field) {
9589 dlg.finished(false);
9590 return Err(common::Error::FieldClash(field));
9591 }
9592 }
9593
9594 let mut params = Params::with_capacity(4 + self._additional_params.len());
9595 params.push("subscription", self._subscription);
9596
9597 params.extend(self._additional_params.iter());
9598
9599 params.push("alt", "json");
9600 let mut url = self.hub._base_url.clone() + "v1/{+subscription}:acknowledge";
9601 if self._scopes.is_empty() {
9602 self._scopes
9603 .insert(Scope::CloudPlatform.as_ref().to_string());
9604 }
9605
9606 #[allow(clippy::single_element_loop)]
9607 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
9608 url = params.uri_replacement(url, param_name, find_this, true);
9609 }
9610 {
9611 let to_remove = ["subscription"];
9612 params.remove_params(&to_remove);
9613 }
9614
9615 let url = params.parse_with_url(&url);
9616
9617 let mut json_mime_type = mime::APPLICATION_JSON;
9618 let mut request_value_reader = {
9619 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9620 common::remove_json_null_values(&mut value);
9621 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9622 serde_json::to_writer(&mut dst, &value).unwrap();
9623 dst
9624 };
9625 let request_size = request_value_reader
9626 .seek(std::io::SeekFrom::End(0))
9627 .unwrap();
9628 request_value_reader
9629 .seek(std::io::SeekFrom::Start(0))
9630 .unwrap();
9631
9632 loop {
9633 let token = match self
9634 .hub
9635 .auth
9636 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9637 .await
9638 {
9639 Ok(token) => token,
9640 Err(e) => match dlg.token(e) {
9641 Ok(token) => token,
9642 Err(e) => {
9643 dlg.finished(false);
9644 return Err(common::Error::MissingToken(e));
9645 }
9646 },
9647 };
9648 request_value_reader
9649 .seek(std::io::SeekFrom::Start(0))
9650 .unwrap();
9651 let mut req_result = {
9652 let client = &self.hub.client;
9653 dlg.pre_request();
9654 let mut req_builder = hyper::Request::builder()
9655 .method(hyper::Method::POST)
9656 .uri(url.as_str())
9657 .header(USER_AGENT, self.hub._user_agent.clone());
9658
9659 if let Some(token) = token.as_ref() {
9660 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9661 }
9662
9663 let request = req_builder
9664 .header(CONTENT_TYPE, json_mime_type.to_string())
9665 .header(CONTENT_LENGTH, request_size as u64)
9666 .body(common::to_body(
9667 request_value_reader.get_ref().clone().into(),
9668 ));
9669
9670 client.request(request.unwrap()).await
9671 };
9672
9673 match req_result {
9674 Err(err) => {
9675 if let common::Retry::After(d) = dlg.http_error(&err) {
9676 sleep(d).await;
9677 continue;
9678 }
9679 dlg.finished(false);
9680 return Err(common::Error::HttpError(err));
9681 }
9682 Ok(res) => {
9683 let (mut parts, body) = res.into_parts();
9684 let mut body = common::Body::new(body);
9685 if !parts.status.is_success() {
9686 let bytes = common::to_bytes(body).await.unwrap_or_default();
9687 let error = serde_json::from_str(&common::to_string(&bytes));
9688 let response = common::to_response(parts, bytes.into());
9689
9690 if let common::Retry::After(d) =
9691 dlg.http_failure(&response, error.as_ref().ok())
9692 {
9693 sleep(d).await;
9694 continue;
9695 }
9696
9697 dlg.finished(false);
9698
9699 return Err(match error {
9700 Ok(value) => common::Error::BadRequest(value),
9701 _ => common::Error::Failure(response),
9702 });
9703 }
9704 let response = {
9705 let bytes = common::to_bytes(body).await.unwrap_or_default();
9706 let encoded = common::to_string(&bytes);
9707 match serde_json::from_str(&encoded) {
9708 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9709 Err(error) => {
9710 dlg.response_json_decode_error(&encoded, &error);
9711 return Err(common::Error::JsonDecodeError(
9712 encoded.to_string(),
9713 error,
9714 ));
9715 }
9716 }
9717 };
9718
9719 dlg.finished(true);
9720 return Ok(response);
9721 }
9722 }
9723 }
9724 }
9725
9726 ///
9727 /// Sets the *request* property to the given value.
9728 ///
9729 /// Even though the property as already been set when instantiating this call,
9730 /// we provide this method for API completeness.
9731 pub fn request(
9732 mut self,
9733 new_value: AcknowledgeRequest,
9734 ) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
9735 self._request = new_value;
9736 self
9737 }
9738 /// Required. The subscription whose message is being acknowledged. Format is `projects/{project}/subscriptions/{sub}`.
9739 ///
9740 /// Sets the *subscription* path property to the given value.
9741 ///
9742 /// Even though the property as already been set when instantiating this call,
9743 /// we provide this method for API completeness.
9744 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
9745 self._subscription = new_value.to_string();
9746 self
9747 }
9748 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9749 /// while executing the actual API request.
9750 ///
9751 /// ````text
9752 /// It should be used to handle progress information, and to implement a certain level of resilience.
9753 /// ````
9754 ///
9755 /// Sets the *delegate* property to the given value.
9756 pub fn delegate(
9757 mut self,
9758 new_value: &'a mut dyn common::Delegate,
9759 ) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
9760 self._delegate = Some(new_value);
9761 self
9762 }
9763
9764 /// Set any additional parameter of the query string used in the request.
9765 /// It should be used to set parameters which are not yet available through their own
9766 /// setters.
9767 ///
9768 /// Please note that this method must not be used to set any of the known parameters
9769 /// which have their own setter method. If done anyway, the request will fail.
9770 ///
9771 /// # Additional Parameters
9772 ///
9773 /// * *$.xgafv* (query-string) - V1 error format.
9774 /// * *access_token* (query-string) - OAuth access token.
9775 /// * *alt* (query-string) - Data format for response.
9776 /// * *callback* (query-string) - JSONP
9777 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9778 /// * *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.
9779 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9780 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9781 /// * *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.
9782 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9783 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9784 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionAcknowledgeCall<'a, C>
9785 where
9786 T: AsRef<str>,
9787 {
9788 self._additional_params
9789 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9790 self
9791 }
9792
9793 /// Identifies the authorization scope for the method you are building.
9794 ///
9795 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9796 /// [`Scope::CloudPlatform`].
9797 ///
9798 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9799 /// tokens for more than one scope.
9800 ///
9801 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9802 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9803 /// sufficient, a read-write scope will do as well.
9804 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionAcknowledgeCall<'a, C>
9805 where
9806 St: AsRef<str>,
9807 {
9808 self._scopes.insert(String::from(scope.as_ref()));
9809 self
9810 }
9811 /// Identifies the authorization scope(s) for the method you are building.
9812 ///
9813 /// See [`Self::add_scope()`] for details.
9814 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionAcknowledgeCall<'a, C>
9815 where
9816 I: IntoIterator<Item = St>,
9817 St: AsRef<str>,
9818 {
9819 self._scopes
9820 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9821 self
9822 }
9823
9824 /// Removes all scopes, and no default scope will be used either.
9825 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9826 /// for details).
9827 pub fn clear_scopes(mut self) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
9828 self._scopes.clear();
9829 self
9830 }
9831}
9832
9833/// Creates a subscription to a given topic. See the [resource name rules] (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). If the subscription already exists, returns `ALREADY_EXISTS`. If the corresponding topic doesn't exist, returns `NOT_FOUND`. If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic, conforming to the [resource name format] (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). The generated name is populated in the returned Subscription object. Note that for REST API requests, you must specify a name in the request.
9834///
9835/// A builder for the *subscriptions.create* method supported by a *project* resource.
9836/// It is not used directly, but through a [`ProjectMethods`] instance.
9837///
9838/// # Example
9839///
9840/// Instantiate a resource method builder
9841///
9842/// ```test_harness,no_run
9843/// # extern crate hyper;
9844/// # extern crate hyper_rustls;
9845/// # extern crate google_pubsub1 as pubsub1;
9846/// use pubsub1::api::Subscription;
9847/// # async fn dox() {
9848/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9849///
9850/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9851/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9852/// # .with_native_roots()
9853/// # .unwrap()
9854/// # .https_only()
9855/// # .enable_http2()
9856/// # .build();
9857///
9858/// # let executor = hyper_util::rt::TokioExecutor::new();
9859/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9860/// # secret,
9861/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9862/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9863/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9864/// # ),
9865/// # ).build().await.unwrap();
9866///
9867/// # let client = hyper_util::client::legacy::Client::builder(
9868/// # hyper_util::rt::TokioExecutor::new()
9869/// # )
9870/// # .build(
9871/// # hyper_rustls::HttpsConnectorBuilder::new()
9872/// # .with_native_roots()
9873/// # .unwrap()
9874/// # .https_or_http()
9875/// # .enable_http2()
9876/// # .build()
9877/// # );
9878/// # let mut hub = Pubsub::new(client, auth);
9879/// // As the method needs a request, you would usually fill it with the desired information
9880/// // into the respective structure. Some of the parts shown here might not be applicable !
9881/// // Values shown here are possibly random and not representative !
9882/// let mut req = Subscription::default();
9883///
9884/// // You can configure optional parameters by calling the respective setters at will, and
9885/// // execute the final call using `doit()`.
9886/// // Values shown here are possibly random and not representative !
9887/// let result = hub.projects().subscriptions_create(req, "name")
9888/// .doit().await;
9889/// # }
9890/// ```
9891pub struct ProjectSubscriptionCreateCall<'a, C>
9892where
9893 C: 'a,
9894{
9895 hub: &'a Pubsub<C>,
9896 _request: Subscription,
9897 _name: String,
9898 _delegate: Option<&'a mut dyn common::Delegate>,
9899 _additional_params: HashMap<String, String>,
9900 _scopes: BTreeSet<String>,
9901}
9902
9903impl<'a, C> common::CallBuilder for ProjectSubscriptionCreateCall<'a, C> {}
9904
9905impl<'a, C> ProjectSubscriptionCreateCall<'a, C>
9906where
9907 C: common::Connector,
9908{
9909 /// Perform the operation you have build so far.
9910 pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
9911 use std::borrow::Cow;
9912 use std::io::{Read, Seek};
9913
9914 use common::{url::Params, ToParts};
9915 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9916
9917 let mut dd = common::DefaultDelegate;
9918 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9919 dlg.begin(common::MethodInfo {
9920 id: "pubsub.projects.subscriptions.create",
9921 http_method: hyper::Method::PUT,
9922 });
9923
9924 for &field in ["alt", "name"].iter() {
9925 if self._additional_params.contains_key(field) {
9926 dlg.finished(false);
9927 return Err(common::Error::FieldClash(field));
9928 }
9929 }
9930
9931 let mut params = Params::with_capacity(4 + self._additional_params.len());
9932 params.push("name", self._name);
9933
9934 params.extend(self._additional_params.iter());
9935
9936 params.push("alt", "json");
9937 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9938 if self._scopes.is_empty() {
9939 self._scopes
9940 .insert(Scope::CloudPlatform.as_ref().to_string());
9941 }
9942
9943 #[allow(clippy::single_element_loop)]
9944 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9945 url = params.uri_replacement(url, param_name, find_this, true);
9946 }
9947 {
9948 let to_remove = ["name"];
9949 params.remove_params(&to_remove);
9950 }
9951
9952 let url = params.parse_with_url(&url);
9953
9954 let mut json_mime_type = mime::APPLICATION_JSON;
9955 let mut request_value_reader = {
9956 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9957 common::remove_json_null_values(&mut value);
9958 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9959 serde_json::to_writer(&mut dst, &value).unwrap();
9960 dst
9961 };
9962 let request_size = request_value_reader
9963 .seek(std::io::SeekFrom::End(0))
9964 .unwrap();
9965 request_value_reader
9966 .seek(std::io::SeekFrom::Start(0))
9967 .unwrap();
9968
9969 loop {
9970 let token = match self
9971 .hub
9972 .auth
9973 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9974 .await
9975 {
9976 Ok(token) => token,
9977 Err(e) => match dlg.token(e) {
9978 Ok(token) => token,
9979 Err(e) => {
9980 dlg.finished(false);
9981 return Err(common::Error::MissingToken(e));
9982 }
9983 },
9984 };
9985 request_value_reader
9986 .seek(std::io::SeekFrom::Start(0))
9987 .unwrap();
9988 let mut req_result = {
9989 let client = &self.hub.client;
9990 dlg.pre_request();
9991 let mut req_builder = hyper::Request::builder()
9992 .method(hyper::Method::PUT)
9993 .uri(url.as_str())
9994 .header(USER_AGENT, self.hub._user_agent.clone());
9995
9996 if let Some(token) = token.as_ref() {
9997 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9998 }
9999
10000 let request = req_builder
10001 .header(CONTENT_TYPE, json_mime_type.to_string())
10002 .header(CONTENT_LENGTH, request_size as u64)
10003 .body(common::to_body(
10004 request_value_reader.get_ref().clone().into(),
10005 ));
10006
10007 client.request(request.unwrap()).await
10008 };
10009
10010 match req_result {
10011 Err(err) => {
10012 if let common::Retry::After(d) = dlg.http_error(&err) {
10013 sleep(d).await;
10014 continue;
10015 }
10016 dlg.finished(false);
10017 return Err(common::Error::HttpError(err));
10018 }
10019 Ok(res) => {
10020 let (mut parts, body) = res.into_parts();
10021 let mut body = common::Body::new(body);
10022 if !parts.status.is_success() {
10023 let bytes = common::to_bytes(body).await.unwrap_or_default();
10024 let error = serde_json::from_str(&common::to_string(&bytes));
10025 let response = common::to_response(parts, bytes.into());
10026
10027 if let common::Retry::After(d) =
10028 dlg.http_failure(&response, error.as_ref().ok())
10029 {
10030 sleep(d).await;
10031 continue;
10032 }
10033
10034 dlg.finished(false);
10035
10036 return Err(match error {
10037 Ok(value) => common::Error::BadRequest(value),
10038 _ => common::Error::Failure(response),
10039 });
10040 }
10041 let response = {
10042 let bytes = common::to_bytes(body).await.unwrap_or_default();
10043 let encoded = common::to_string(&bytes);
10044 match serde_json::from_str(&encoded) {
10045 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10046 Err(error) => {
10047 dlg.response_json_decode_error(&encoded, &error);
10048 return Err(common::Error::JsonDecodeError(
10049 encoded.to_string(),
10050 error,
10051 ));
10052 }
10053 }
10054 };
10055
10056 dlg.finished(true);
10057 return Ok(response);
10058 }
10059 }
10060 }
10061 }
10062
10063 ///
10064 /// Sets the *request* property to the given value.
10065 ///
10066 /// Even though the property as already been set when instantiating this call,
10067 /// we provide this method for API completeness.
10068 pub fn request(mut self, new_value: Subscription) -> ProjectSubscriptionCreateCall<'a, C> {
10069 self._request = new_value;
10070 self
10071 }
10072 /// Required. Identifier. The name of the subscription. It must have the format `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
10073 ///
10074 /// Sets the *name* path property to the given value.
10075 ///
10076 /// Even though the property as already been set when instantiating this call,
10077 /// we provide this method for API completeness.
10078 pub fn name(mut self, new_value: &str) -> ProjectSubscriptionCreateCall<'a, C> {
10079 self._name = new_value.to_string();
10080 self
10081 }
10082 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10083 /// while executing the actual API request.
10084 ///
10085 /// ````text
10086 /// It should be used to handle progress information, and to implement a certain level of resilience.
10087 /// ````
10088 ///
10089 /// Sets the *delegate* property to the given value.
10090 pub fn delegate(
10091 mut self,
10092 new_value: &'a mut dyn common::Delegate,
10093 ) -> ProjectSubscriptionCreateCall<'a, C> {
10094 self._delegate = Some(new_value);
10095 self
10096 }
10097
10098 /// Set any additional parameter of the query string used in the request.
10099 /// It should be used to set parameters which are not yet available through their own
10100 /// setters.
10101 ///
10102 /// Please note that this method must not be used to set any of the known parameters
10103 /// which have their own setter method. If done anyway, the request will fail.
10104 ///
10105 /// # Additional Parameters
10106 ///
10107 /// * *$.xgafv* (query-string) - V1 error format.
10108 /// * *access_token* (query-string) - OAuth access token.
10109 /// * *alt* (query-string) - Data format for response.
10110 /// * *callback* (query-string) - JSONP
10111 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10112 /// * *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.
10113 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10114 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10115 /// * *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.
10116 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10117 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10118 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionCreateCall<'a, C>
10119 where
10120 T: AsRef<str>,
10121 {
10122 self._additional_params
10123 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10124 self
10125 }
10126
10127 /// Identifies the authorization scope for the method you are building.
10128 ///
10129 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10130 /// [`Scope::CloudPlatform`].
10131 ///
10132 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10133 /// tokens for more than one scope.
10134 ///
10135 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10136 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10137 /// sufficient, a read-write scope will do as well.
10138 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionCreateCall<'a, C>
10139 where
10140 St: AsRef<str>,
10141 {
10142 self._scopes.insert(String::from(scope.as_ref()));
10143 self
10144 }
10145 /// Identifies the authorization scope(s) for the method you are building.
10146 ///
10147 /// See [`Self::add_scope()`] for details.
10148 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionCreateCall<'a, C>
10149 where
10150 I: IntoIterator<Item = St>,
10151 St: AsRef<str>,
10152 {
10153 self._scopes
10154 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10155 self
10156 }
10157
10158 /// Removes all scopes, and no default scope will be used either.
10159 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10160 /// for details).
10161 pub fn clear_scopes(mut self) -> ProjectSubscriptionCreateCall<'a, C> {
10162 self._scopes.clear();
10163 self
10164 }
10165}
10166
10167/// Deletes an existing subscription. All messages retained in the subscription are immediately dropped. Calls to `Pull` after deletion will return `NOT_FOUND`. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription or its topic unless the same topic is specified.
10168///
10169/// A builder for the *subscriptions.delete* method supported by a *project* resource.
10170/// It is not used directly, but through a [`ProjectMethods`] instance.
10171///
10172/// # Example
10173///
10174/// Instantiate a resource method builder
10175///
10176/// ```test_harness,no_run
10177/// # extern crate hyper;
10178/// # extern crate hyper_rustls;
10179/// # extern crate google_pubsub1 as pubsub1;
10180/// # async fn dox() {
10181/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10182///
10183/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10184/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10185/// # .with_native_roots()
10186/// # .unwrap()
10187/// # .https_only()
10188/// # .enable_http2()
10189/// # .build();
10190///
10191/// # let executor = hyper_util::rt::TokioExecutor::new();
10192/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10193/// # secret,
10194/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10195/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10196/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10197/// # ),
10198/// # ).build().await.unwrap();
10199///
10200/// # let client = hyper_util::client::legacy::Client::builder(
10201/// # hyper_util::rt::TokioExecutor::new()
10202/// # )
10203/// # .build(
10204/// # hyper_rustls::HttpsConnectorBuilder::new()
10205/// # .with_native_roots()
10206/// # .unwrap()
10207/// # .https_or_http()
10208/// # .enable_http2()
10209/// # .build()
10210/// # );
10211/// # let mut hub = Pubsub::new(client, auth);
10212/// // You can configure optional parameters by calling the respective setters at will, and
10213/// // execute the final call using `doit()`.
10214/// // Values shown here are possibly random and not representative !
10215/// let result = hub.projects().subscriptions_delete("subscription")
10216/// .doit().await;
10217/// # }
10218/// ```
10219pub struct ProjectSubscriptionDeleteCall<'a, C>
10220where
10221 C: 'a,
10222{
10223 hub: &'a Pubsub<C>,
10224 _subscription: String,
10225 _delegate: Option<&'a mut dyn common::Delegate>,
10226 _additional_params: HashMap<String, String>,
10227 _scopes: BTreeSet<String>,
10228}
10229
10230impl<'a, C> common::CallBuilder for ProjectSubscriptionDeleteCall<'a, C> {}
10231
10232impl<'a, C> ProjectSubscriptionDeleteCall<'a, C>
10233where
10234 C: common::Connector,
10235{
10236 /// Perform the operation you have build so far.
10237 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
10238 use std::borrow::Cow;
10239 use std::io::{Read, Seek};
10240
10241 use common::{url::Params, ToParts};
10242 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10243
10244 let mut dd = common::DefaultDelegate;
10245 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10246 dlg.begin(common::MethodInfo {
10247 id: "pubsub.projects.subscriptions.delete",
10248 http_method: hyper::Method::DELETE,
10249 });
10250
10251 for &field in ["alt", "subscription"].iter() {
10252 if self._additional_params.contains_key(field) {
10253 dlg.finished(false);
10254 return Err(common::Error::FieldClash(field));
10255 }
10256 }
10257
10258 let mut params = Params::with_capacity(3 + self._additional_params.len());
10259 params.push("subscription", self._subscription);
10260
10261 params.extend(self._additional_params.iter());
10262
10263 params.push("alt", "json");
10264 let mut url = self.hub._base_url.clone() + "v1/{+subscription}";
10265 if self._scopes.is_empty() {
10266 self._scopes
10267 .insert(Scope::CloudPlatform.as_ref().to_string());
10268 }
10269
10270 #[allow(clippy::single_element_loop)]
10271 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
10272 url = params.uri_replacement(url, param_name, find_this, true);
10273 }
10274 {
10275 let to_remove = ["subscription"];
10276 params.remove_params(&to_remove);
10277 }
10278
10279 let url = params.parse_with_url(&url);
10280
10281 loop {
10282 let token = match self
10283 .hub
10284 .auth
10285 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10286 .await
10287 {
10288 Ok(token) => token,
10289 Err(e) => match dlg.token(e) {
10290 Ok(token) => token,
10291 Err(e) => {
10292 dlg.finished(false);
10293 return Err(common::Error::MissingToken(e));
10294 }
10295 },
10296 };
10297 let mut req_result = {
10298 let client = &self.hub.client;
10299 dlg.pre_request();
10300 let mut req_builder = hyper::Request::builder()
10301 .method(hyper::Method::DELETE)
10302 .uri(url.as_str())
10303 .header(USER_AGENT, self.hub._user_agent.clone());
10304
10305 if let Some(token) = token.as_ref() {
10306 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10307 }
10308
10309 let request = req_builder
10310 .header(CONTENT_LENGTH, 0_u64)
10311 .body(common::to_body::<String>(None));
10312
10313 client.request(request.unwrap()).await
10314 };
10315
10316 match req_result {
10317 Err(err) => {
10318 if let common::Retry::After(d) = dlg.http_error(&err) {
10319 sleep(d).await;
10320 continue;
10321 }
10322 dlg.finished(false);
10323 return Err(common::Error::HttpError(err));
10324 }
10325 Ok(res) => {
10326 let (mut parts, body) = res.into_parts();
10327 let mut body = common::Body::new(body);
10328 if !parts.status.is_success() {
10329 let bytes = common::to_bytes(body).await.unwrap_or_default();
10330 let error = serde_json::from_str(&common::to_string(&bytes));
10331 let response = common::to_response(parts, bytes.into());
10332
10333 if let common::Retry::After(d) =
10334 dlg.http_failure(&response, error.as_ref().ok())
10335 {
10336 sleep(d).await;
10337 continue;
10338 }
10339
10340 dlg.finished(false);
10341
10342 return Err(match error {
10343 Ok(value) => common::Error::BadRequest(value),
10344 _ => common::Error::Failure(response),
10345 });
10346 }
10347 let response = {
10348 let bytes = common::to_bytes(body).await.unwrap_or_default();
10349 let encoded = common::to_string(&bytes);
10350 match serde_json::from_str(&encoded) {
10351 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10352 Err(error) => {
10353 dlg.response_json_decode_error(&encoded, &error);
10354 return Err(common::Error::JsonDecodeError(
10355 encoded.to_string(),
10356 error,
10357 ));
10358 }
10359 }
10360 };
10361
10362 dlg.finished(true);
10363 return Ok(response);
10364 }
10365 }
10366 }
10367 }
10368
10369 /// Required. Identifier. The subscription to delete. Format is `projects/{project}/subscriptions/{sub}`.
10370 ///
10371 /// Sets the *subscription* path property to the given value.
10372 ///
10373 /// Even though the property as already been set when instantiating this call,
10374 /// we provide this method for API completeness.
10375 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionDeleteCall<'a, C> {
10376 self._subscription = new_value.to_string();
10377 self
10378 }
10379 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10380 /// while executing the actual API request.
10381 ///
10382 /// ````text
10383 /// It should be used to handle progress information, and to implement a certain level of resilience.
10384 /// ````
10385 ///
10386 /// Sets the *delegate* property to the given value.
10387 pub fn delegate(
10388 mut self,
10389 new_value: &'a mut dyn common::Delegate,
10390 ) -> ProjectSubscriptionDeleteCall<'a, C> {
10391 self._delegate = Some(new_value);
10392 self
10393 }
10394
10395 /// Set any additional parameter of the query string used in the request.
10396 /// It should be used to set parameters which are not yet available through their own
10397 /// setters.
10398 ///
10399 /// Please note that this method must not be used to set any of the known parameters
10400 /// which have their own setter method. If done anyway, the request will fail.
10401 ///
10402 /// # Additional Parameters
10403 ///
10404 /// * *$.xgafv* (query-string) - V1 error format.
10405 /// * *access_token* (query-string) - OAuth access token.
10406 /// * *alt* (query-string) - Data format for response.
10407 /// * *callback* (query-string) - JSONP
10408 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10409 /// * *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.
10410 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10411 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10412 /// * *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.
10413 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10414 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10415 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionDeleteCall<'a, C>
10416 where
10417 T: AsRef<str>,
10418 {
10419 self._additional_params
10420 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10421 self
10422 }
10423
10424 /// Identifies the authorization scope for the method you are building.
10425 ///
10426 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10427 /// [`Scope::CloudPlatform`].
10428 ///
10429 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10430 /// tokens for more than one scope.
10431 ///
10432 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10433 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10434 /// sufficient, a read-write scope will do as well.
10435 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionDeleteCall<'a, C>
10436 where
10437 St: AsRef<str>,
10438 {
10439 self._scopes.insert(String::from(scope.as_ref()));
10440 self
10441 }
10442 /// Identifies the authorization scope(s) for the method you are building.
10443 ///
10444 /// See [`Self::add_scope()`] for details.
10445 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionDeleteCall<'a, C>
10446 where
10447 I: IntoIterator<Item = St>,
10448 St: AsRef<str>,
10449 {
10450 self._scopes
10451 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10452 self
10453 }
10454
10455 /// Removes all scopes, and no default scope will be used either.
10456 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10457 /// for details).
10458 pub fn clear_scopes(mut self) -> ProjectSubscriptionDeleteCall<'a, C> {
10459 self._scopes.clear();
10460 self
10461 }
10462}
10463
10464/// Detaches a subscription from this topic. All messages retained in the subscription are dropped. Subsequent `Pull` and `StreamingPull` requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will stop.
10465///
10466/// A builder for the *subscriptions.detach* method supported by a *project* resource.
10467/// It is not used directly, but through a [`ProjectMethods`] instance.
10468///
10469/// # Example
10470///
10471/// Instantiate a resource method builder
10472///
10473/// ```test_harness,no_run
10474/// # extern crate hyper;
10475/// # extern crate hyper_rustls;
10476/// # extern crate google_pubsub1 as pubsub1;
10477/// # async fn dox() {
10478/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10479///
10480/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10481/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10482/// # .with_native_roots()
10483/// # .unwrap()
10484/// # .https_only()
10485/// # .enable_http2()
10486/// # .build();
10487///
10488/// # let executor = hyper_util::rt::TokioExecutor::new();
10489/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10490/// # secret,
10491/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10492/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10493/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10494/// # ),
10495/// # ).build().await.unwrap();
10496///
10497/// # let client = hyper_util::client::legacy::Client::builder(
10498/// # hyper_util::rt::TokioExecutor::new()
10499/// # )
10500/// # .build(
10501/// # hyper_rustls::HttpsConnectorBuilder::new()
10502/// # .with_native_roots()
10503/// # .unwrap()
10504/// # .https_or_http()
10505/// # .enable_http2()
10506/// # .build()
10507/// # );
10508/// # let mut hub = Pubsub::new(client, auth);
10509/// // You can configure optional parameters by calling the respective setters at will, and
10510/// // execute the final call using `doit()`.
10511/// // Values shown here are possibly random and not representative !
10512/// let result = hub.projects().subscriptions_detach("subscription")
10513/// .doit().await;
10514/// # }
10515/// ```
10516pub struct ProjectSubscriptionDetachCall<'a, C>
10517where
10518 C: 'a,
10519{
10520 hub: &'a Pubsub<C>,
10521 _subscription: String,
10522 _delegate: Option<&'a mut dyn common::Delegate>,
10523 _additional_params: HashMap<String, String>,
10524 _scopes: BTreeSet<String>,
10525}
10526
10527impl<'a, C> common::CallBuilder for ProjectSubscriptionDetachCall<'a, C> {}
10528
10529impl<'a, C> ProjectSubscriptionDetachCall<'a, C>
10530where
10531 C: common::Connector,
10532{
10533 /// Perform the operation you have build so far.
10534 pub async fn doit(mut self) -> common::Result<(common::Response, DetachSubscriptionResponse)> {
10535 use std::borrow::Cow;
10536 use std::io::{Read, Seek};
10537
10538 use common::{url::Params, ToParts};
10539 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10540
10541 let mut dd = common::DefaultDelegate;
10542 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10543 dlg.begin(common::MethodInfo {
10544 id: "pubsub.projects.subscriptions.detach",
10545 http_method: hyper::Method::POST,
10546 });
10547
10548 for &field in ["alt", "subscription"].iter() {
10549 if self._additional_params.contains_key(field) {
10550 dlg.finished(false);
10551 return Err(common::Error::FieldClash(field));
10552 }
10553 }
10554
10555 let mut params = Params::with_capacity(3 + self._additional_params.len());
10556 params.push("subscription", self._subscription);
10557
10558 params.extend(self._additional_params.iter());
10559
10560 params.push("alt", "json");
10561 let mut url = self.hub._base_url.clone() + "v1/{+subscription}:detach";
10562 if self._scopes.is_empty() {
10563 self._scopes
10564 .insert(Scope::CloudPlatform.as_ref().to_string());
10565 }
10566
10567 #[allow(clippy::single_element_loop)]
10568 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
10569 url = params.uri_replacement(url, param_name, find_this, true);
10570 }
10571 {
10572 let to_remove = ["subscription"];
10573 params.remove_params(&to_remove);
10574 }
10575
10576 let url = params.parse_with_url(&url);
10577
10578 loop {
10579 let token = match self
10580 .hub
10581 .auth
10582 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10583 .await
10584 {
10585 Ok(token) => token,
10586 Err(e) => match dlg.token(e) {
10587 Ok(token) => token,
10588 Err(e) => {
10589 dlg.finished(false);
10590 return Err(common::Error::MissingToken(e));
10591 }
10592 },
10593 };
10594 let mut req_result = {
10595 let client = &self.hub.client;
10596 dlg.pre_request();
10597 let mut req_builder = hyper::Request::builder()
10598 .method(hyper::Method::POST)
10599 .uri(url.as_str())
10600 .header(USER_AGENT, self.hub._user_agent.clone());
10601
10602 if let Some(token) = token.as_ref() {
10603 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10604 }
10605
10606 let request = req_builder
10607 .header(CONTENT_LENGTH, 0_u64)
10608 .body(common::to_body::<String>(None));
10609
10610 client.request(request.unwrap()).await
10611 };
10612
10613 match req_result {
10614 Err(err) => {
10615 if let common::Retry::After(d) = dlg.http_error(&err) {
10616 sleep(d).await;
10617 continue;
10618 }
10619 dlg.finished(false);
10620 return Err(common::Error::HttpError(err));
10621 }
10622 Ok(res) => {
10623 let (mut parts, body) = res.into_parts();
10624 let mut body = common::Body::new(body);
10625 if !parts.status.is_success() {
10626 let bytes = common::to_bytes(body).await.unwrap_or_default();
10627 let error = serde_json::from_str(&common::to_string(&bytes));
10628 let response = common::to_response(parts, bytes.into());
10629
10630 if let common::Retry::After(d) =
10631 dlg.http_failure(&response, error.as_ref().ok())
10632 {
10633 sleep(d).await;
10634 continue;
10635 }
10636
10637 dlg.finished(false);
10638
10639 return Err(match error {
10640 Ok(value) => common::Error::BadRequest(value),
10641 _ => common::Error::Failure(response),
10642 });
10643 }
10644 let response = {
10645 let bytes = common::to_bytes(body).await.unwrap_or_default();
10646 let encoded = common::to_string(&bytes);
10647 match serde_json::from_str(&encoded) {
10648 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10649 Err(error) => {
10650 dlg.response_json_decode_error(&encoded, &error);
10651 return Err(common::Error::JsonDecodeError(
10652 encoded.to_string(),
10653 error,
10654 ));
10655 }
10656 }
10657 };
10658
10659 dlg.finished(true);
10660 return Ok(response);
10661 }
10662 }
10663 }
10664 }
10665
10666 /// Required. The subscription to detach. Format is `projects/{project}/subscriptions/{subscription}`.
10667 ///
10668 /// Sets the *subscription* path property to the given value.
10669 ///
10670 /// Even though the property as already been set when instantiating this call,
10671 /// we provide this method for API completeness.
10672 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionDetachCall<'a, C> {
10673 self._subscription = new_value.to_string();
10674 self
10675 }
10676 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10677 /// while executing the actual API request.
10678 ///
10679 /// ````text
10680 /// It should be used to handle progress information, and to implement a certain level of resilience.
10681 /// ````
10682 ///
10683 /// Sets the *delegate* property to the given value.
10684 pub fn delegate(
10685 mut self,
10686 new_value: &'a mut dyn common::Delegate,
10687 ) -> ProjectSubscriptionDetachCall<'a, C> {
10688 self._delegate = Some(new_value);
10689 self
10690 }
10691
10692 /// Set any additional parameter of the query string used in the request.
10693 /// It should be used to set parameters which are not yet available through their own
10694 /// setters.
10695 ///
10696 /// Please note that this method must not be used to set any of the known parameters
10697 /// which have their own setter method. If done anyway, the request will fail.
10698 ///
10699 /// # Additional Parameters
10700 ///
10701 /// * *$.xgafv* (query-string) - V1 error format.
10702 /// * *access_token* (query-string) - OAuth access token.
10703 /// * *alt* (query-string) - Data format for response.
10704 /// * *callback* (query-string) - JSONP
10705 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10706 /// * *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.
10707 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10708 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10709 /// * *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.
10710 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10711 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10712 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionDetachCall<'a, C>
10713 where
10714 T: AsRef<str>,
10715 {
10716 self._additional_params
10717 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10718 self
10719 }
10720
10721 /// Identifies the authorization scope for the method you are building.
10722 ///
10723 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10724 /// [`Scope::CloudPlatform`].
10725 ///
10726 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10727 /// tokens for more than one scope.
10728 ///
10729 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10730 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10731 /// sufficient, a read-write scope will do as well.
10732 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionDetachCall<'a, C>
10733 where
10734 St: AsRef<str>,
10735 {
10736 self._scopes.insert(String::from(scope.as_ref()));
10737 self
10738 }
10739 /// Identifies the authorization scope(s) for the method you are building.
10740 ///
10741 /// See [`Self::add_scope()`] for details.
10742 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionDetachCall<'a, C>
10743 where
10744 I: IntoIterator<Item = St>,
10745 St: AsRef<str>,
10746 {
10747 self._scopes
10748 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10749 self
10750 }
10751
10752 /// Removes all scopes, and no default scope will be used either.
10753 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10754 /// for details).
10755 pub fn clear_scopes(mut self) -> ProjectSubscriptionDetachCall<'a, C> {
10756 self._scopes.clear();
10757 self
10758 }
10759}
10760
10761/// Gets the configuration details of a subscription.
10762///
10763/// A builder for the *subscriptions.get* method supported by a *project* resource.
10764/// It is not used directly, but through a [`ProjectMethods`] instance.
10765///
10766/// # Example
10767///
10768/// Instantiate a resource method builder
10769///
10770/// ```test_harness,no_run
10771/// # extern crate hyper;
10772/// # extern crate hyper_rustls;
10773/// # extern crate google_pubsub1 as pubsub1;
10774/// # async fn dox() {
10775/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10776///
10777/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10778/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10779/// # .with_native_roots()
10780/// # .unwrap()
10781/// # .https_only()
10782/// # .enable_http2()
10783/// # .build();
10784///
10785/// # let executor = hyper_util::rt::TokioExecutor::new();
10786/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10787/// # secret,
10788/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10789/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10790/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10791/// # ),
10792/// # ).build().await.unwrap();
10793///
10794/// # let client = hyper_util::client::legacy::Client::builder(
10795/// # hyper_util::rt::TokioExecutor::new()
10796/// # )
10797/// # .build(
10798/// # hyper_rustls::HttpsConnectorBuilder::new()
10799/// # .with_native_roots()
10800/// # .unwrap()
10801/// # .https_or_http()
10802/// # .enable_http2()
10803/// # .build()
10804/// # );
10805/// # let mut hub = Pubsub::new(client, auth);
10806/// // You can configure optional parameters by calling the respective setters at will, and
10807/// // execute the final call using `doit()`.
10808/// // Values shown here are possibly random and not representative !
10809/// let result = hub.projects().subscriptions_get("subscription")
10810/// .doit().await;
10811/// # }
10812/// ```
10813pub struct ProjectSubscriptionGetCall<'a, C>
10814where
10815 C: 'a,
10816{
10817 hub: &'a Pubsub<C>,
10818 _subscription: String,
10819 _delegate: Option<&'a mut dyn common::Delegate>,
10820 _additional_params: HashMap<String, String>,
10821 _scopes: BTreeSet<String>,
10822}
10823
10824impl<'a, C> common::CallBuilder for ProjectSubscriptionGetCall<'a, C> {}
10825
10826impl<'a, C> ProjectSubscriptionGetCall<'a, C>
10827where
10828 C: common::Connector,
10829{
10830 /// Perform the operation you have build so far.
10831 pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
10832 use std::borrow::Cow;
10833 use std::io::{Read, Seek};
10834
10835 use common::{url::Params, ToParts};
10836 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10837
10838 let mut dd = common::DefaultDelegate;
10839 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10840 dlg.begin(common::MethodInfo {
10841 id: "pubsub.projects.subscriptions.get",
10842 http_method: hyper::Method::GET,
10843 });
10844
10845 for &field in ["alt", "subscription"].iter() {
10846 if self._additional_params.contains_key(field) {
10847 dlg.finished(false);
10848 return Err(common::Error::FieldClash(field));
10849 }
10850 }
10851
10852 let mut params = Params::with_capacity(3 + self._additional_params.len());
10853 params.push("subscription", self._subscription);
10854
10855 params.extend(self._additional_params.iter());
10856
10857 params.push("alt", "json");
10858 let mut url = self.hub._base_url.clone() + "v1/{+subscription}";
10859 if self._scopes.is_empty() {
10860 self._scopes
10861 .insert(Scope::CloudPlatform.as_ref().to_string());
10862 }
10863
10864 #[allow(clippy::single_element_loop)]
10865 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
10866 url = params.uri_replacement(url, param_name, find_this, true);
10867 }
10868 {
10869 let to_remove = ["subscription"];
10870 params.remove_params(&to_remove);
10871 }
10872
10873 let url = params.parse_with_url(&url);
10874
10875 loop {
10876 let token = match self
10877 .hub
10878 .auth
10879 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10880 .await
10881 {
10882 Ok(token) => token,
10883 Err(e) => match dlg.token(e) {
10884 Ok(token) => token,
10885 Err(e) => {
10886 dlg.finished(false);
10887 return Err(common::Error::MissingToken(e));
10888 }
10889 },
10890 };
10891 let mut req_result = {
10892 let client = &self.hub.client;
10893 dlg.pre_request();
10894 let mut req_builder = hyper::Request::builder()
10895 .method(hyper::Method::GET)
10896 .uri(url.as_str())
10897 .header(USER_AGENT, self.hub._user_agent.clone());
10898
10899 if let Some(token) = token.as_ref() {
10900 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10901 }
10902
10903 let request = req_builder
10904 .header(CONTENT_LENGTH, 0_u64)
10905 .body(common::to_body::<String>(None));
10906
10907 client.request(request.unwrap()).await
10908 };
10909
10910 match req_result {
10911 Err(err) => {
10912 if let common::Retry::After(d) = dlg.http_error(&err) {
10913 sleep(d).await;
10914 continue;
10915 }
10916 dlg.finished(false);
10917 return Err(common::Error::HttpError(err));
10918 }
10919 Ok(res) => {
10920 let (mut parts, body) = res.into_parts();
10921 let mut body = common::Body::new(body);
10922 if !parts.status.is_success() {
10923 let bytes = common::to_bytes(body).await.unwrap_or_default();
10924 let error = serde_json::from_str(&common::to_string(&bytes));
10925 let response = common::to_response(parts, bytes.into());
10926
10927 if let common::Retry::After(d) =
10928 dlg.http_failure(&response, error.as_ref().ok())
10929 {
10930 sleep(d).await;
10931 continue;
10932 }
10933
10934 dlg.finished(false);
10935
10936 return Err(match error {
10937 Ok(value) => common::Error::BadRequest(value),
10938 _ => common::Error::Failure(response),
10939 });
10940 }
10941 let response = {
10942 let bytes = common::to_bytes(body).await.unwrap_or_default();
10943 let encoded = common::to_string(&bytes);
10944 match serde_json::from_str(&encoded) {
10945 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10946 Err(error) => {
10947 dlg.response_json_decode_error(&encoded, &error);
10948 return Err(common::Error::JsonDecodeError(
10949 encoded.to_string(),
10950 error,
10951 ));
10952 }
10953 }
10954 };
10955
10956 dlg.finished(true);
10957 return Ok(response);
10958 }
10959 }
10960 }
10961 }
10962
10963 /// Required. Identifier. The name of the subscription to get. Format is `projects/{project}/subscriptions/{sub}`.
10964 ///
10965 /// Sets the *subscription* path property to the given value.
10966 ///
10967 /// Even though the property as already been set when instantiating this call,
10968 /// we provide this method for API completeness.
10969 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionGetCall<'a, C> {
10970 self._subscription = new_value.to_string();
10971 self
10972 }
10973 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10974 /// while executing the actual API request.
10975 ///
10976 /// ````text
10977 /// It should be used to handle progress information, and to implement a certain level of resilience.
10978 /// ````
10979 ///
10980 /// Sets the *delegate* property to the given value.
10981 pub fn delegate(
10982 mut self,
10983 new_value: &'a mut dyn common::Delegate,
10984 ) -> ProjectSubscriptionGetCall<'a, C> {
10985 self._delegate = Some(new_value);
10986 self
10987 }
10988
10989 /// Set any additional parameter of the query string used in the request.
10990 /// It should be used to set parameters which are not yet available through their own
10991 /// setters.
10992 ///
10993 /// Please note that this method must not be used to set any of the known parameters
10994 /// which have their own setter method. If done anyway, the request will fail.
10995 ///
10996 /// # Additional Parameters
10997 ///
10998 /// * *$.xgafv* (query-string) - V1 error format.
10999 /// * *access_token* (query-string) - OAuth access token.
11000 /// * *alt* (query-string) - Data format for response.
11001 /// * *callback* (query-string) - JSONP
11002 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11003 /// * *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.
11004 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11005 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11006 /// * *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.
11007 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11008 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11009 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionGetCall<'a, C>
11010 where
11011 T: AsRef<str>,
11012 {
11013 self._additional_params
11014 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11015 self
11016 }
11017
11018 /// Identifies the authorization scope for the method you are building.
11019 ///
11020 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11021 /// [`Scope::CloudPlatform`].
11022 ///
11023 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11024 /// tokens for more than one scope.
11025 ///
11026 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11027 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11028 /// sufficient, a read-write scope will do as well.
11029 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionGetCall<'a, C>
11030 where
11031 St: AsRef<str>,
11032 {
11033 self._scopes.insert(String::from(scope.as_ref()));
11034 self
11035 }
11036 /// Identifies the authorization scope(s) for the method you are building.
11037 ///
11038 /// See [`Self::add_scope()`] for details.
11039 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionGetCall<'a, C>
11040 where
11041 I: IntoIterator<Item = St>,
11042 St: AsRef<str>,
11043 {
11044 self._scopes
11045 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11046 self
11047 }
11048
11049 /// Removes all scopes, and no default scope will be used either.
11050 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11051 /// for details).
11052 pub fn clear_scopes(mut self) -> ProjectSubscriptionGetCall<'a, C> {
11053 self._scopes.clear();
11054 self
11055 }
11056}
11057
11058/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
11059///
11060/// A builder for the *subscriptions.getIamPolicy* method supported by a *project* resource.
11061/// It is not used directly, but through a [`ProjectMethods`] instance.
11062///
11063/// # Example
11064///
11065/// Instantiate a resource method builder
11066///
11067/// ```test_harness,no_run
11068/// # extern crate hyper;
11069/// # extern crate hyper_rustls;
11070/// # extern crate google_pubsub1 as pubsub1;
11071/// # async fn dox() {
11072/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11073///
11074/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11075/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11076/// # .with_native_roots()
11077/// # .unwrap()
11078/// # .https_only()
11079/// # .enable_http2()
11080/// # .build();
11081///
11082/// # let executor = hyper_util::rt::TokioExecutor::new();
11083/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11084/// # secret,
11085/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11086/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11087/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11088/// # ),
11089/// # ).build().await.unwrap();
11090///
11091/// # let client = hyper_util::client::legacy::Client::builder(
11092/// # hyper_util::rt::TokioExecutor::new()
11093/// # )
11094/// # .build(
11095/// # hyper_rustls::HttpsConnectorBuilder::new()
11096/// # .with_native_roots()
11097/// # .unwrap()
11098/// # .https_or_http()
11099/// # .enable_http2()
11100/// # .build()
11101/// # );
11102/// # let mut hub = Pubsub::new(client, auth);
11103/// // You can configure optional parameters by calling the respective setters at will, and
11104/// // execute the final call using `doit()`.
11105/// // Values shown here are possibly random and not representative !
11106/// let result = hub.projects().subscriptions_get_iam_policy("resource")
11107/// .options_requested_policy_version(-24)
11108/// .doit().await;
11109/// # }
11110/// ```
11111pub struct ProjectSubscriptionGetIamPolicyCall<'a, C>
11112where
11113 C: 'a,
11114{
11115 hub: &'a Pubsub<C>,
11116 _resource: String,
11117 _options_requested_policy_version: Option<i32>,
11118 _delegate: Option<&'a mut dyn common::Delegate>,
11119 _additional_params: HashMap<String, String>,
11120 _scopes: BTreeSet<String>,
11121}
11122
11123impl<'a, C> common::CallBuilder for ProjectSubscriptionGetIamPolicyCall<'a, C> {}
11124
11125impl<'a, C> ProjectSubscriptionGetIamPolicyCall<'a, C>
11126where
11127 C: common::Connector,
11128{
11129 /// Perform the operation you have build so far.
11130 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
11131 use std::borrow::Cow;
11132 use std::io::{Read, Seek};
11133
11134 use common::{url::Params, ToParts};
11135 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11136
11137 let mut dd = common::DefaultDelegate;
11138 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11139 dlg.begin(common::MethodInfo {
11140 id: "pubsub.projects.subscriptions.getIamPolicy",
11141 http_method: hyper::Method::GET,
11142 });
11143
11144 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
11145 if self._additional_params.contains_key(field) {
11146 dlg.finished(false);
11147 return Err(common::Error::FieldClash(field));
11148 }
11149 }
11150
11151 let mut params = Params::with_capacity(4 + self._additional_params.len());
11152 params.push("resource", self._resource);
11153 if let Some(value) = self._options_requested_policy_version.as_ref() {
11154 params.push("options.requestedPolicyVersion", value.to_string());
11155 }
11156
11157 params.extend(self._additional_params.iter());
11158
11159 params.push("alt", "json");
11160 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
11161 if self._scopes.is_empty() {
11162 self._scopes
11163 .insert(Scope::CloudPlatform.as_ref().to_string());
11164 }
11165
11166 #[allow(clippy::single_element_loop)]
11167 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11168 url = params.uri_replacement(url, param_name, find_this, true);
11169 }
11170 {
11171 let to_remove = ["resource"];
11172 params.remove_params(&to_remove);
11173 }
11174
11175 let url = params.parse_with_url(&url);
11176
11177 loop {
11178 let token = match self
11179 .hub
11180 .auth
11181 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11182 .await
11183 {
11184 Ok(token) => token,
11185 Err(e) => match dlg.token(e) {
11186 Ok(token) => token,
11187 Err(e) => {
11188 dlg.finished(false);
11189 return Err(common::Error::MissingToken(e));
11190 }
11191 },
11192 };
11193 let mut req_result = {
11194 let client = &self.hub.client;
11195 dlg.pre_request();
11196 let mut req_builder = hyper::Request::builder()
11197 .method(hyper::Method::GET)
11198 .uri(url.as_str())
11199 .header(USER_AGENT, self.hub._user_agent.clone());
11200
11201 if let Some(token) = token.as_ref() {
11202 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11203 }
11204
11205 let request = req_builder
11206 .header(CONTENT_LENGTH, 0_u64)
11207 .body(common::to_body::<String>(None));
11208
11209 client.request(request.unwrap()).await
11210 };
11211
11212 match req_result {
11213 Err(err) => {
11214 if let common::Retry::After(d) = dlg.http_error(&err) {
11215 sleep(d).await;
11216 continue;
11217 }
11218 dlg.finished(false);
11219 return Err(common::Error::HttpError(err));
11220 }
11221 Ok(res) => {
11222 let (mut parts, body) = res.into_parts();
11223 let mut body = common::Body::new(body);
11224 if !parts.status.is_success() {
11225 let bytes = common::to_bytes(body).await.unwrap_or_default();
11226 let error = serde_json::from_str(&common::to_string(&bytes));
11227 let response = common::to_response(parts, bytes.into());
11228
11229 if let common::Retry::After(d) =
11230 dlg.http_failure(&response, error.as_ref().ok())
11231 {
11232 sleep(d).await;
11233 continue;
11234 }
11235
11236 dlg.finished(false);
11237
11238 return Err(match error {
11239 Ok(value) => common::Error::BadRequest(value),
11240 _ => common::Error::Failure(response),
11241 });
11242 }
11243 let response = {
11244 let bytes = common::to_bytes(body).await.unwrap_or_default();
11245 let encoded = common::to_string(&bytes);
11246 match serde_json::from_str(&encoded) {
11247 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11248 Err(error) => {
11249 dlg.response_json_decode_error(&encoded, &error);
11250 return Err(common::Error::JsonDecodeError(
11251 encoded.to_string(),
11252 error,
11253 ));
11254 }
11255 }
11256 };
11257
11258 dlg.finished(true);
11259 return Ok(response);
11260 }
11261 }
11262 }
11263 }
11264
11265 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
11266 ///
11267 /// Sets the *resource* path property to the given value.
11268 ///
11269 /// Even though the property as already been set when instantiating this call,
11270 /// we provide this method for API completeness.
11271 pub fn resource(mut self, new_value: &str) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
11272 self._resource = new_value.to_string();
11273 self
11274 }
11275 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
11276 ///
11277 /// Sets the *options.requested policy version* query property to the given value.
11278 pub fn options_requested_policy_version(
11279 mut self,
11280 new_value: i32,
11281 ) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
11282 self._options_requested_policy_version = Some(new_value);
11283 self
11284 }
11285 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11286 /// while executing the actual API request.
11287 ///
11288 /// ````text
11289 /// It should be used to handle progress information, and to implement a certain level of resilience.
11290 /// ````
11291 ///
11292 /// Sets the *delegate* property to the given value.
11293 pub fn delegate(
11294 mut self,
11295 new_value: &'a mut dyn common::Delegate,
11296 ) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
11297 self._delegate = Some(new_value);
11298 self
11299 }
11300
11301 /// Set any additional parameter of the query string used in the request.
11302 /// It should be used to set parameters which are not yet available through their own
11303 /// setters.
11304 ///
11305 /// Please note that this method must not be used to set any of the known parameters
11306 /// which have their own setter method. If done anyway, the request will fail.
11307 ///
11308 /// # Additional Parameters
11309 ///
11310 /// * *$.xgafv* (query-string) - V1 error format.
11311 /// * *access_token* (query-string) - OAuth access token.
11312 /// * *alt* (query-string) - Data format for response.
11313 /// * *callback* (query-string) - JSONP
11314 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11315 /// * *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.
11316 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11317 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11318 /// * *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.
11319 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11320 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11321 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionGetIamPolicyCall<'a, C>
11322 where
11323 T: AsRef<str>,
11324 {
11325 self._additional_params
11326 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11327 self
11328 }
11329
11330 /// Identifies the authorization scope for the method you are building.
11331 ///
11332 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11333 /// [`Scope::CloudPlatform`].
11334 ///
11335 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11336 /// tokens for more than one scope.
11337 ///
11338 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11339 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11340 /// sufficient, a read-write scope will do as well.
11341 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionGetIamPolicyCall<'a, C>
11342 where
11343 St: AsRef<str>,
11344 {
11345 self._scopes.insert(String::from(scope.as_ref()));
11346 self
11347 }
11348 /// Identifies the authorization scope(s) for the method you are building.
11349 ///
11350 /// See [`Self::add_scope()`] for details.
11351 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionGetIamPolicyCall<'a, C>
11352 where
11353 I: IntoIterator<Item = St>,
11354 St: AsRef<str>,
11355 {
11356 self._scopes
11357 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11358 self
11359 }
11360
11361 /// Removes all scopes, and no default scope will be used either.
11362 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11363 /// for details).
11364 pub fn clear_scopes(mut self) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
11365 self._scopes.clear();
11366 self
11367 }
11368}
11369
11370/// Lists matching subscriptions.
11371///
11372/// A builder for the *subscriptions.list* method supported by a *project* resource.
11373/// It is not used directly, but through a [`ProjectMethods`] instance.
11374///
11375/// # Example
11376///
11377/// Instantiate a resource method builder
11378///
11379/// ```test_harness,no_run
11380/// # extern crate hyper;
11381/// # extern crate hyper_rustls;
11382/// # extern crate google_pubsub1 as pubsub1;
11383/// # async fn dox() {
11384/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11385///
11386/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11387/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11388/// # .with_native_roots()
11389/// # .unwrap()
11390/// # .https_only()
11391/// # .enable_http2()
11392/// # .build();
11393///
11394/// # let executor = hyper_util::rt::TokioExecutor::new();
11395/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11396/// # secret,
11397/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11398/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11399/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11400/// # ),
11401/// # ).build().await.unwrap();
11402///
11403/// # let client = hyper_util::client::legacy::Client::builder(
11404/// # hyper_util::rt::TokioExecutor::new()
11405/// # )
11406/// # .build(
11407/// # hyper_rustls::HttpsConnectorBuilder::new()
11408/// # .with_native_roots()
11409/// # .unwrap()
11410/// # .https_or_http()
11411/// # .enable_http2()
11412/// # .build()
11413/// # );
11414/// # let mut hub = Pubsub::new(client, auth);
11415/// // You can configure optional parameters by calling the respective setters at will, and
11416/// // execute the final call using `doit()`.
11417/// // Values shown here are possibly random and not representative !
11418/// let result = hub.projects().subscriptions_list("project")
11419/// .page_token("vero")
11420/// .page_size(-31)
11421/// .doit().await;
11422/// # }
11423/// ```
11424pub struct ProjectSubscriptionListCall<'a, C>
11425where
11426 C: 'a,
11427{
11428 hub: &'a Pubsub<C>,
11429 _project: String,
11430 _page_token: Option<String>,
11431 _page_size: Option<i32>,
11432 _delegate: Option<&'a mut dyn common::Delegate>,
11433 _additional_params: HashMap<String, String>,
11434 _scopes: BTreeSet<String>,
11435}
11436
11437impl<'a, C> common::CallBuilder for ProjectSubscriptionListCall<'a, C> {}
11438
11439impl<'a, C> ProjectSubscriptionListCall<'a, C>
11440where
11441 C: common::Connector,
11442{
11443 /// Perform the operation you have build so far.
11444 pub async fn doit(mut self) -> common::Result<(common::Response, ListSubscriptionsResponse)> {
11445 use std::borrow::Cow;
11446 use std::io::{Read, Seek};
11447
11448 use common::{url::Params, ToParts};
11449 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11450
11451 let mut dd = common::DefaultDelegate;
11452 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11453 dlg.begin(common::MethodInfo {
11454 id: "pubsub.projects.subscriptions.list",
11455 http_method: hyper::Method::GET,
11456 });
11457
11458 for &field in ["alt", "project", "pageToken", "pageSize"].iter() {
11459 if self._additional_params.contains_key(field) {
11460 dlg.finished(false);
11461 return Err(common::Error::FieldClash(field));
11462 }
11463 }
11464
11465 let mut params = Params::with_capacity(5 + self._additional_params.len());
11466 params.push("project", self._project);
11467 if let Some(value) = self._page_token.as_ref() {
11468 params.push("pageToken", value);
11469 }
11470 if let Some(value) = self._page_size.as_ref() {
11471 params.push("pageSize", value.to_string());
11472 }
11473
11474 params.extend(self._additional_params.iter());
11475
11476 params.push("alt", "json");
11477 let mut url = self.hub._base_url.clone() + "v1/{+project}/subscriptions";
11478 if self._scopes.is_empty() {
11479 self._scopes
11480 .insert(Scope::CloudPlatform.as_ref().to_string());
11481 }
11482
11483 #[allow(clippy::single_element_loop)]
11484 for &(find_this, param_name) in [("{+project}", "project")].iter() {
11485 url = params.uri_replacement(url, param_name, find_this, true);
11486 }
11487 {
11488 let to_remove = ["project"];
11489 params.remove_params(&to_remove);
11490 }
11491
11492 let url = params.parse_with_url(&url);
11493
11494 loop {
11495 let token = match self
11496 .hub
11497 .auth
11498 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11499 .await
11500 {
11501 Ok(token) => token,
11502 Err(e) => match dlg.token(e) {
11503 Ok(token) => token,
11504 Err(e) => {
11505 dlg.finished(false);
11506 return Err(common::Error::MissingToken(e));
11507 }
11508 },
11509 };
11510 let mut req_result = {
11511 let client = &self.hub.client;
11512 dlg.pre_request();
11513 let mut req_builder = hyper::Request::builder()
11514 .method(hyper::Method::GET)
11515 .uri(url.as_str())
11516 .header(USER_AGENT, self.hub._user_agent.clone());
11517
11518 if let Some(token) = token.as_ref() {
11519 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11520 }
11521
11522 let request = req_builder
11523 .header(CONTENT_LENGTH, 0_u64)
11524 .body(common::to_body::<String>(None));
11525
11526 client.request(request.unwrap()).await
11527 };
11528
11529 match req_result {
11530 Err(err) => {
11531 if let common::Retry::After(d) = dlg.http_error(&err) {
11532 sleep(d).await;
11533 continue;
11534 }
11535 dlg.finished(false);
11536 return Err(common::Error::HttpError(err));
11537 }
11538 Ok(res) => {
11539 let (mut parts, body) = res.into_parts();
11540 let mut body = common::Body::new(body);
11541 if !parts.status.is_success() {
11542 let bytes = common::to_bytes(body).await.unwrap_or_default();
11543 let error = serde_json::from_str(&common::to_string(&bytes));
11544 let response = common::to_response(parts, bytes.into());
11545
11546 if let common::Retry::After(d) =
11547 dlg.http_failure(&response, error.as_ref().ok())
11548 {
11549 sleep(d).await;
11550 continue;
11551 }
11552
11553 dlg.finished(false);
11554
11555 return Err(match error {
11556 Ok(value) => common::Error::BadRequest(value),
11557 _ => common::Error::Failure(response),
11558 });
11559 }
11560 let response = {
11561 let bytes = common::to_bytes(body).await.unwrap_or_default();
11562 let encoded = common::to_string(&bytes);
11563 match serde_json::from_str(&encoded) {
11564 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11565 Err(error) => {
11566 dlg.response_json_decode_error(&encoded, &error);
11567 return Err(common::Error::JsonDecodeError(
11568 encoded.to_string(),
11569 error,
11570 ));
11571 }
11572 }
11573 };
11574
11575 dlg.finished(true);
11576 return Ok(response);
11577 }
11578 }
11579 }
11580 }
11581
11582 /// Required. Identifier. The name of the project in which to list subscriptions. Format is `projects/{project-id}`.
11583 ///
11584 /// Sets the *project* path property to the given value.
11585 ///
11586 /// Even though the property as already been set when instantiating this call,
11587 /// we provide this method for API completeness.
11588 pub fn project(mut self, new_value: &str) -> ProjectSubscriptionListCall<'a, C> {
11589 self._project = new_value.to_string();
11590 self
11591 }
11592 /// Optional. The value returned by the last `ListSubscriptionsResponse`; indicates that this is a continuation of a prior `ListSubscriptions` call, and that the system should return the next page of data.
11593 ///
11594 /// Sets the *page token* query property to the given value.
11595 pub fn page_token(mut self, new_value: &str) -> ProjectSubscriptionListCall<'a, C> {
11596 self._page_token = Some(new_value.to_string());
11597 self
11598 }
11599 /// Optional. Maximum number of subscriptions to return.
11600 ///
11601 /// Sets the *page size* query property to the given value.
11602 pub fn page_size(mut self, new_value: i32) -> ProjectSubscriptionListCall<'a, C> {
11603 self._page_size = Some(new_value);
11604 self
11605 }
11606 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11607 /// while executing the actual API request.
11608 ///
11609 /// ````text
11610 /// It should be used to handle progress information, and to implement a certain level of resilience.
11611 /// ````
11612 ///
11613 /// Sets the *delegate* property to the given value.
11614 pub fn delegate(
11615 mut self,
11616 new_value: &'a mut dyn common::Delegate,
11617 ) -> ProjectSubscriptionListCall<'a, C> {
11618 self._delegate = Some(new_value);
11619 self
11620 }
11621
11622 /// Set any additional parameter of the query string used in the request.
11623 /// It should be used to set parameters which are not yet available through their own
11624 /// setters.
11625 ///
11626 /// Please note that this method must not be used to set any of the known parameters
11627 /// which have their own setter method. If done anyway, the request will fail.
11628 ///
11629 /// # Additional Parameters
11630 ///
11631 /// * *$.xgafv* (query-string) - V1 error format.
11632 /// * *access_token* (query-string) - OAuth access token.
11633 /// * *alt* (query-string) - Data format for response.
11634 /// * *callback* (query-string) - JSONP
11635 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11636 /// * *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.
11637 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11638 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11639 /// * *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.
11640 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11641 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11642 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionListCall<'a, C>
11643 where
11644 T: AsRef<str>,
11645 {
11646 self._additional_params
11647 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11648 self
11649 }
11650
11651 /// Identifies the authorization scope for the method you are building.
11652 ///
11653 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11654 /// [`Scope::CloudPlatform`].
11655 ///
11656 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11657 /// tokens for more than one scope.
11658 ///
11659 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11660 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11661 /// sufficient, a read-write scope will do as well.
11662 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionListCall<'a, C>
11663 where
11664 St: AsRef<str>,
11665 {
11666 self._scopes.insert(String::from(scope.as_ref()));
11667 self
11668 }
11669 /// Identifies the authorization scope(s) for the method you are building.
11670 ///
11671 /// See [`Self::add_scope()`] for details.
11672 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionListCall<'a, C>
11673 where
11674 I: IntoIterator<Item = St>,
11675 St: AsRef<str>,
11676 {
11677 self._scopes
11678 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11679 self
11680 }
11681
11682 /// Removes all scopes, and no default scope will be used either.
11683 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11684 /// for details).
11685 pub fn clear_scopes(mut self) -> ProjectSubscriptionListCall<'a, C> {
11686 self._scopes.clear();
11687 self
11688 }
11689}
11690
11691/// Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted. Note that this does not modify the subscription-level `ackDeadlineSeconds` used for subsequent messages.
11692///
11693/// A builder for the *subscriptions.modifyAckDeadline* method supported by a *project* resource.
11694/// It is not used directly, but through a [`ProjectMethods`] instance.
11695///
11696/// # Example
11697///
11698/// Instantiate a resource method builder
11699///
11700/// ```test_harness,no_run
11701/// # extern crate hyper;
11702/// # extern crate hyper_rustls;
11703/// # extern crate google_pubsub1 as pubsub1;
11704/// use pubsub1::api::ModifyAckDeadlineRequest;
11705/// # async fn dox() {
11706/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11707///
11708/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11709/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11710/// # .with_native_roots()
11711/// # .unwrap()
11712/// # .https_only()
11713/// # .enable_http2()
11714/// # .build();
11715///
11716/// # let executor = hyper_util::rt::TokioExecutor::new();
11717/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11718/// # secret,
11719/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11720/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11721/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11722/// # ),
11723/// # ).build().await.unwrap();
11724///
11725/// # let client = hyper_util::client::legacy::Client::builder(
11726/// # hyper_util::rt::TokioExecutor::new()
11727/// # )
11728/// # .build(
11729/// # hyper_rustls::HttpsConnectorBuilder::new()
11730/// # .with_native_roots()
11731/// # .unwrap()
11732/// # .https_or_http()
11733/// # .enable_http2()
11734/// # .build()
11735/// # );
11736/// # let mut hub = Pubsub::new(client, auth);
11737/// // As the method needs a request, you would usually fill it with the desired information
11738/// // into the respective structure. Some of the parts shown here might not be applicable !
11739/// // Values shown here are possibly random and not representative !
11740/// let mut req = ModifyAckDeadlineRequest::default();
11741///
11742/// // You can configure optional parameters by calling the respective setters at will, and
11743/// // execute the final call using `doit()`.
11744/// // Values shown here are possibly random and not representative !
11745/// let result = hub.projects().subscriptions_modify_ack_deadline(req, "subscription")
11746/// .doit().await;
11747/// # }
11748/// ```
11749pub struct ProjectSubscriptionModifyAckDeadlineCall<'a, C>
11750where
11751 C: 'a,
11752{
11753 hub: &'a Pubsub<C>,
11754 _request: ModifyAckDeadlineRequest,
11755 _subscription: String,
11756 _delegate: Option<&'a mut dyn common::Delegate>,
11757 _additional_params: HashMap<String, String>,
11758 _scopes: BTreeSet<String>,
11759}
11760
11761impl<'a, C> common::CallBuilder for ProjectSubscriptionModifyAckDeadlineCall<'a, C> {}
11762
11763impl<'a, C> ProjectSubscriptionModifyAckDeadlineCall<'a, C>
11764where
11765 C: common::Connector,
11766{
11767 /// Perform the operation you have build so far.
11768 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11769 use std::borrow::Cow;
11770 use std::io::{Read, Seek};
11771
11772 use common::{url::Params, ToParts};
11773 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11774
11775 let mut dd = common::DefaultDelegate;
11776 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11777 dlg.begin(common::MethodInfo {
11778 id: "pubsub.projects.subscriptions.modifyAckDeadline",
11779 http_method: hyper::Method::POST,
11780 });
11781
11782 for &field in ["alt", "subscription"].iter() {
11783 if self._additional_params.contains_key(field) {
11784 dlg.finished(false);
11785 return Err(common::Error::FieldClash(field));
11786 }
11787 }
11788
11789 let mut params = Params::with_capacity(4 + self._additional_params.len());
11790 params.push("subscription", self._subscription);
11791
11792 params.extend(self._additional_params.iter());
11793
11794 params.push("alt", "json");
11795 let mut url = self.hub._base_url.clone() + "v1/{+subscription}:modifyAckDeadline";
11796 if self._scopes.is_empty() {
11797 self._scopes
11798 .insert(Scope::CloudPlatform.as_ref().to_string());
11799 }
11800
11801 #[allow(clippy::single_element_loop)]
11802 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
11803 url = params.uri_replacement(url, param_name, find_this, true);
11804 }
11805 {
11806 let to_remove = ["subscription"];
11807 params.remove_params(&to_remove);
11808 }
11809
11810 let url = params.parse_with_url(&url);
11811
11812 let mut json_mime_type = mime::APPLICATION_JSON;
11813 let mut request_value_reader = {
11814 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11815 common::remove_json_null_values(&mut value);
11816 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11817 serde_json::to_writer(&mut dst, &value).unwrap();
11818 dst
11819 };
11820 let request_size = request_value_reader
11821 .seek(std::io::SeekFrom::End(0))
11822 .unwrap();
11823 request_value_reader
11824 .seek(std::io::SeekFrom::Start(0))
11825 .unwrap();
11826
11827 loop {
11828 let token = match self
11829 .hub
11830 .auth
11831 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11832 .await
11833 {
11834 Ok(token) => token,
11835 Err(e) => match dlg.token(e) {
11836 Ok(token) => token,
11837 Err(e) => {
11838 dlg.finished(false);
11839 return Err(common::Error::MissingToken(e));
11840 }
11841 },
11842 };
11843 request_value_reader
11844 .seek(std::io::SeekFrom::Start(0))
11845 .unwrap();
11846 let mut req_result = {
11847 let client = &self.hub.client;
11848 dlg.pre_request();
11849 let mut req_builder = hyper::Request::builder()
11850 .method(hyper::Method::POST)
11851 .uri(url.as_str())
11852 .header(USER_AGENT, self.hub._user_agent.clone());
11853
11854 if let Some(token) = token.as_ref() {
11855 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11856 }
11857
11858 let request = req_builder
11859 .header(CONTENT_TYPE, json_mime_type.to_string())
11860 .header(CONTENT_LENGTH, request_size as u64)
11861 .body(common::to_body(
11862 request_value_reader.get_ref().clone().into(),
11863 ));
11864
11865 client.request(request.unwrap()).await
11866 };
11867
11868 match req_result {
11869 Err(err) => {
11870 if let common::Retry::After(d) = dlg.http_error(&err) {
11871 sleep(d).await;
11872 continue;
11873 }
11874 dlg.finished(false);
11875 return Err(common::Error::HttpError(err));
11876 }
11877 Ok(res) => {
11878 let (mut parts, body) = res.into_parts();
11879 let mut body = common::Body::new(body);
11880 if !parts.status.is_success() {
11881 let bytes = common::to_bytes(body).await.unwrap_or_default();
11882 let error = serde_json::from_str(&common::to_string(&bytes));
11883 let response = common::to_response(parts, bytes.into());
11884
11885 if let common::Retry::After(d) =
11886 dlg.http_failure(&response, error.as_ref().ok())
11887 {
11888 sleep(d).await;
11889 continue;
11890 }
11891
11892 dlg.finished(false);
11893
11894 return Err(match error {
11895 Ok(value) => common::Error::BadRequest(value),
11896 _ => common::Error::Failure(response),
11897 });
11898 }
11899 let response = {
11900 let bytes = common::to_bytes(body).await.unwrap_or_default();
11901 let encoded = common::to_string(&bytes);
11902 match serde_json::from_str(&encoded) {
11903 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11904 Err(error) => {
11905 dlg.response_json_decode_error(&encoded, &error);
11906 return Err(common::Error::JsonDecodeError(
11907 encoded.to_string(),
11908 error,
11909 ));
11910 }
11911 }
11912 };
11913
11914 dlg.finished(true);
11915 return Ok(response);
11916 }
11917 }
11918 }
11919 }
11920
11921 ///
11922 /// Sets the *request* property to the given value.
11923 ///
11924 /// Even though the property as already been set when instantiating this call,
11925 /// we provide this method for API completeness.
11926 pub fn request(
11927 mut self,
11928 new_value: ModifyAckDeadlineRequest,
11929 ) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
11930 self._request = new_value;
11931 self
11932 }
11933 /// Required. The name of the subscription. Format is `projects/{project}/subscriptions/{sub}`.
11934 ///
11935 /// Sets the *subscription* path property to the given value.
11936 ///
11937 /// Even though the property as already been set when instantiating this call,
11938 /// we provide this method for API completeness.
11939 pub fn subscription(
11940 mut self,
11941 new_value: &str,
11942 ) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
11943 self._subscription = new_value.to_string();
11944 self
11945 }
11946 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11947 /// while executing the actual API request.
11948 ///
11949 /// ````text
11950 /// It should be used to handle progress information, and to implement a certain level of resilience.
11951 /// ````
11952 ///
11953 /// Sets the *delegate* property to the given value.
11954 pub fn delegate(
11955 mut self,
11956 new_value: &'a mut dyn common::Delegate,
11957 ) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
11958 self._delegate = Some(new_value);
11959 self
11960 }
11961
11962 /// Set any additional parameter of the query string used in the request.
11963 /// It should be used to set parameters which are not yet available through their own
11964 /// setters.
11965 ///
11966 /// Please note that this method must not be used to set any of the known parameters
11967 /// which have their own setter method. If done anyway, the request will fail.
11968 ///
11969 /// # Additional Parameters
11970 ///
11971 /// * *$.xgafv* (query-string) - V1 error format.
11972 /// * *access_token* (query-string) - OAuth access token.
11973 /// * *alt* (query-string) - Data format for response.
11974 /// * *callback* (query-string) - JSONP
11975 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11976 /// * *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.
11977 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11978 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11979 /// * *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.
11980 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11981 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11982 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C>
11983 where
11984 T: AsRef<str>,
11985 {
11986 self._additional_params
11987 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11988 self
11989 }
11990
11991 /// Identifies the authorization scope for the method you are building.
11992 ///
11993 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11994 /// [`Scope::CloudPlatform`].
11995 ///
11996 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11997 /// tokens for more than one scope.
11998 ///
11999 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12000 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12001 /// sufficient, a read-write scope will do as well.
12002 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C>
12003 where
12004 St: AsRef<str>,
12005 {
12006 self._scopes.insert(String::from(scope.as_ref()));
12007 self
12008 }
12009 /// Identifies the authorization scope(s) for the method you are building.
12010 ///
12011 /// See [`Self::add_scope()`] for details.
12012 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C>
12013 where
12014 I: IntoIterator<Item = St>,
12015 St: AsRef<str>,
12016 {
12017 self._scopes
12018 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12019 self
12020 }
12021
12022 /// Removes all scopes, and no default scope will be used either.
12023 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12024 /// for details).
12025 pub fn clear_scopes(mut self) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
12026 self._scopes.clear();
12027 self
12028 }
12029}
12030
12031/// Modifies the `PushConfig` for a specified subscription. This may be used to change a push subscription to a pull one (signified by an empty `PushConfig`) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the `PushConfig`.
12032///
12033/// A builder for the *subscriptions.modifyPushConfig* method supported by a *project* resource.
12034/// It is not used directly, but through a [`ProjectMethods`] instance.
12035///
12036/// # Example
12037///
12038/// Instantiate a resource method builder
12039///
12040/// ```test_harness,no_run
12041/// # extern crate hyper;
12042/// # extern crate hyper_rustls;
12043/// # extern crate google_pubsub1 as pubsub1;
12044/// use pubsub1::api::ModifyPushConfigRequest;
12045/// # async fn dox() {
12046/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12047///
12048/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12049/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12050/// # .with_native_roots()
12051/// # .unwrap()
12052/// # .https_only()
12053/// # .enable_http2()
12054/// # .build();
12055///
12056/// # let executor = hyper_util::rt::TokioExecutor::new();
12057/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12058/// # secret,
12059/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12060/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12061/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12062/// # ),
12063/// # ).build().await.unwrap();
12064///
12065/// # let client = hyper_util::client::legacy::Client::builder(
12066/// # hyper_util::rt::TokioExecutor::new()
12067/// # )
12068/// # .build(
12069/// # hyper_rustls::HttpsConnectorBuilder::new()
12070/// # .with_native_roots()
12071/// # .unwrap()
12072/// # .https_or_http()
12073/// # .enable_http2()
12074/// # .build()
12075/// # );
12076/// # let mut hub = Pubsub::new(client, auth);
12077/// // As the method needs a request, you would usually fill it with the desired information
12078/// // into the respective structure. Some of the parts shown here might not be applicable !
12079/// // Values shown here are possibly random and not representative !
12080/// let mut req = ModifyPushConfigRequest::default();
12081///
12082/// // You can configure optional parameters by calling the respective setters at will, and
12083/// // execute the final call using `doit()`.
12084/// // Values shown here are possibly random and not representative !
12085/// let result = hub.projects().subscriptions_modify_push_config(req, "subscription")
12086/// .doit().await;
12087/// # }
12088/// ```
12089pub struct ProjectSubscriptionModifyPushConfigCall<'a, C>
12090where
12091 C: 'a,
12092{
12093 hub: &'a Pubsub<C>,
12094 _request: ModifyPushConfigRequest,
12095 _subscription: String,
12096 _delegate: Option<&'a mut dyn common::Delegate>,
12097 _additional_params: HashMap<String, String>,
12098 _scopes: BTreeSet<String>,
12099}
12100
12101impl<'a, C> common::CallBuilder for ProjectSubscriptionModifyPushConfigCall<'a, C> {}
12102
12103impl<'a, C> ProjectSubscriptionModifyPushConfigCall<'a, C>
12104where
12105 C: common::Connector,
12106{
12107 /// Perform the operation you have build so far.
12108 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
12109 use std::borrow::Cow;
12110 use std::io::{Read, Seek};
12111
12112 use common::{url::Params, ToParts};
12113 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12114
12115 let mut dd = common::DefaultDelegate;
12116 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12117 dlg.begin(common::MethodInfo {
12118 id: "pubsub.projects.subscriptions.modifyPushConfig",
12119 http_method: hyper::Method::POST,
12120 });
12121
12122 for &field in ["alt", "subscription"].iter() {
12123 if self._additional_params.contains_key(field) {
12124 dlg.finished(false);
12125 return Err(common::Error::FieldClash(field));
12126 }
12127 }
12128
12129 let mut params = Params::with_capacity(4 + self._additional_params.len());
12130 params.push("subscription", self._subscription);
12131
12132 params.extend(self._additional_params.iter());
12133
12134 params.push("alt", "json");
12135 let mut url = self.hub._base_url.clone() + "v1/{+subscription}:modifyPushConfig";
12136 if self._scopes.is_empty() {
12137 self._scopes
12138 .insert(Scope::CloudPlatform.as_ref().to_string());
12139 }
12140
12141 #[allow(clippy::single_element_loop)]
12142 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
12143 url = params.uri_replacement(url, param_name, find_this, true);
12144 }
12145 {
12146 let to_remove = ["subscription"];
12147 params.remove_params(&to_remove);
12148 }
12149
12150 let url = params.parse_with_url(&url);
12151
12152 let mut json_mime_type = mime::APPLICATION_JSON;
12153 let mut request_value_reader = {
12154 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12155 common::remove_json_null_values(&mut value);
12156 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12157 serde_json::to_writer(&mut dst, &value).unwrap();
12158 dst
12159 };
12160 let request_size = request_value_reader
12161 .seek(std::io::SeekFrom::End(0))
12162 .unwrap();
12163 request_value_reader
12164 .seek(std::io::SeekFrom::Start(0))
12165 .unwrap();
12166
12167 loop {
12168 let token = match self
12169 .hub
12170 .auth
12171 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12172 .await
12173 {
12174 Ok(token) => token,
12175 Err(e) => match dlg.token(e) {
12176 Ok(token) => token,
12177 Err(e) => {
12178 dlg.finished(false);
12179 return Err(common::Error::MissingToken(e));
12180 }
12181 },
12182 };
12183 request_value_reader
12184 .seek(std::io::SeekFrom::Start(0))
12185 .unwrap();
12186 let mut req_result = {
12187 let client = &self.hub.client;
12188 dlg.pre_request();
12189 let mut req_builder = hyper::Request::builder()
12190 .method(hyper::Method::POST)
12191 .uri(url.as_str())
12192 .header(USER_AGENT, self.hub._user_agent.clone());
12193
12194 if let Some(token) = token.as_ref() {
12195 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12196 }
12197
12198 let request = req_builder
12199 .header(CONTENT_TYPE, json_mime_type.to_string())
12200 .header(CONTENT_LENGTH, request_size as u64)
12201 .body(common::to_body(
12202 request_value_reader.get_ref().clone().into(),
12203 ));
12204
12205 client.request(request.unwrap()).await
12206 };
12207
12208 match req_result {
12209 Err(err) => {
12210 if let common::Retry::After(d) = dlg.http_error(&err) {
12211 sleep(d).await;
12212 continue;
12213 }
12214 dlg.finished(false);
12215 return Err(common::Error::HttpError(err));
12216 }
12217 Ok(res) => {
12218 let (mut parts, body) = res.into_parts();
12219 let mut body = common::Body::new(body);
12220 if !parts.status.is_success() {
12221 let bytes = common::to_bytes(body).await.unwrap_or_default();
12222 let error = serde_json::from_str(&common::to_string(&bytes));
12223 let response = common::to_response(parts, bytes.into());
12224
12225 if let common::Retry::After(d) =
12226 dlg.http_failure(&response, error.as_ref().ok())
12227 {
12228 sleep(d).await;
12229 continue;
12230 }
12231
12232 dlg.finished(false);
12233
12234 return Err(match error {
12235 Ok(value) => common::Error::BadRequest(value),
12236 _ => common::Error::Failure(response),
12237 });
12238 }
12239 let response = {
12240 let bytes = common::to_bytes(body).await.unwrap_or_default();
12241 let encoded = common::to_string(&bytes);
12242 match serde_json::from_str(&encoded) {
12243 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12244 Err(error) => {
12245 dlg.response_json_decode_error(&encoded, &error);
12246 return Err(common::Error::JsonDecodeError(
12247 encoded.to_string(),
12248 error,
12249 ));
12250 }
12251 }
12252 };
12253
12254 dlg.finished(true);
12255 return Ok(response);
12256 }
12257 }
12258 }
12259 }
12260
12261 ///
12262 /// Sets the *request* property to the given value.
12263 ///
12264 /// Even though the property as already been set when instantiating this call,
12265 /// we provide this method for API completeness.
12266 pub fn request(
12267 mut self,
12268 new_value: ModifyPushConfigRequest,
12269 ) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
12270 self._request = new_value;
12271 self
12272 }
12273 /// Required. The name of the subscription. Format is `projects/{project}/subscriptions/{sub}`.
12274 ///
12275 /// Sets the *subscription* path property to the given value.
12276 ///
12277 /// Even though the property as already been set when instantiating this call,
12278 /// we provide this method for API completeness.
12279 pub fn subscription(
12280 mut self,
12281 new_value: &str,
12282 ) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
12283 self._subscription = new_value.to_string();
12284 self
12285 }
12286 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12287 /// while executing the actual API request.
12288 ///
12289 /// ````text
12290 /// It should be used to handle progress information, and to implement a certain level of resilience.
12291 /// ````
12292 ///
12293 /// Sets the *delegate* property to the given value.
12294 pub fn delegate(
12295 mut self,
12296 new_value: &'a mut dyn common::Delegate,
12297 ) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
12298 self._delegate = Some(new_value);
12299 self
12300 }
12301
12302 /// Set any additional parameter of the query string used in the request.
12303 /// It should be used to set parameters which are not yet available through their own
12304 /// setters.
12305 ///
12306 /// Please note that this method must not be used to set any of the known parameters
12307 /// which have their own setter method. If done anyway, the request will fail.
12308 ///
12309 /// # Additional Parameters
12310 ///
12311 /// * *$.xgafv* (query-string) - V1 error format.
12312 /// * *access_token* (query-string) - OAuth access token.
12313 /// * *alt* (query-string) - Data format for response.
12314 /// * *callback* (query-string) - JSONP
12315 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12316 /// * *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.
12317 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12318 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12319 /// * *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.
12320 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12321 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12322 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionModifyPushConfigCall<'a, C>
12323 where
12324 T: AsRef<str>,
12325 {
12326 self._additional_params
12327 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12328 self
12329 }
12330
12331 /// Identifies the authorization scope for the method you are building.
12332 ///
12333 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12334 /// [`Scope::CloudPlatform`].
12335 ///
12336 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12337 /// tokens for more than one scope.
12338 ///
12339 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12340 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12341 /// sufficient, a read-write scope will do as well.
12342 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionModifyPushConfigCall<'a, C>
12343 where
12344 St: AsRef<str>,
12345 {
12346 self._scopes.insert(String::from(scope.as_ref()));
12347 self
12348 }
12349 /// Identifies the authorization scope(s) for the method you are building.
12350 ///
12351 /// See [`Self::add_scope()`] for details.
12352 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionModifyPushConfigCall<'a, C>
12353 where
12354 I: IntoIterator<Item = St>,
12355 St: AsRef<str>,
12356 {
12357 self._scopes
12358 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12359 self
12360 }
12361
12362 /// Removes all scopes, and no default scope will be used either.
12363 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12364 /// for details).
12365 pub fn clear_scopes(mut self) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
12366 self._scopes.clear();
12367 self
12368 }
12369}
12370
12371/// Updates an existing subscription by updating the fields specified in the update mask. Note that certain properties of a subscription, such as its topic, are not modifiable.
12372///
12373/// A builder for the *subscriptions.patch* method supported by a *project* resource.
12374/// It is not used directly, but through a [`ProjectMethods`] instance.
12375///
12376/// # Example
12377///
12378/// Instantiate a resource method builder
12379///
12380/// ```test_harness,no_run
12381/// # extern crate hyper;
12382/// # extern crate hyper_rustls;
12383/// # extern crate google_pubsub1 as pubsub1;
12384/// use pubsub1::api::UpdateSubscriptionRequest;
12385/// # async fn dox() {
12386/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12387///
12388/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12389/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12390/// # .with_native_roots()
12391/// # .unwrap()
12392/// # .https_only()
12393/// # .enable_http2()
12394/// # .build();
12395///
12396/// # let executor = hyper_util::rt::TokioExecutor::new();
12397/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12398/// # secret,
12399/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12400/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12401/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12402/// # ),
12403/// # ).build().await.unwrap();
12404///
12405/// # let client = hyper_util::client::legacy::Client::builder(
12406/// # hyper_util::rt::TokioExecutor::new()
12407/// # )
12408/// # .build(
12409/// # hyper_rustls::HttpsConnectorBuilder::new()
12410/// # .with_native_roots()
12411/// # .unwrap()
12412/// # .https_or_http()
12413/// # .enable_http2()
12414/// # .build()
12415/// # );
12416/// # let mut hub = Pubsub::new(client, auth);
12417/// // As the method needs a request, you would usually fill it with the desired information
12418/// // into the respective structure. Some of the parts shown here might not be applicable !
12419/// // Values shown here are possibly random and not representative !
12420/// let mut req = UpdateSubscriptionRequest::default();
12421///
12422/// // You can configure optional parameters by calling the respective setters at will, and
12423/// // execute the final call using `doit()`.
12424/// // Values shown here are possibly random and not representative !
12425/// let result = hub.projects().subscriptions_patch(req, "name")
12426/// .doit().await;
12427/// # }
12428/// ```
12429pub struct ProjectSubscriptionPatchCall<'a, C>
12430where
12431 C: 'a,
12432{
12433 hub: &'a Pubsub<C>,
12434 _request: UpdateSubscriptionRequest,
12435 _name: String,
12436 _delegate: Option<&'a mut dyn common::Delegate>,
12437 _additional_params: HashMap<String, String>,
12438 _scopes: BTreeSet<String>,
12439}
12440
12441impl<'a, C> common::CallBuilder for ProjectSubscriptionPatchCall<'a, C> {}
12442
12443impl<'a, C> ProjectSubscriptionPatchCall<'a, C>
12444where
12445 C: common::Connector,
12446{
12447 /// Perform the operation you have build so far.
12448 pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
12449 use std::borrow::Cow;
12450 use std::io::{Read, Seek};
12451
12452 use common::{url::Params, ToParts};
12453 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12454
12455 let mut dd = common::DefaultDelegate;
12456 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12457 dlg.begin(common::MethodInfo {
12458 id: "pubsub.projects.subscriptions.patch",
12459 http_method: hyper::Method::PATCH,
12460 });
12461
12462 for &field in ["alt", "name"].iter() {
12463 if self._additional_params.contains_key(field) {
12464 dlg.finished(false);
12465 return Err(common::Error::FieldClash(field));
12466 }
12467 }
12468
12469 let mut params = Params::with_capacity(4 + self._additional_params.len());
12470 params.push("name", self._name);
12471
12472 params.extend(self._additional_params.iter());
12473
12474 params.push("alt", "json");
12475 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12476 if self._scopes.is_empty() {
12477 self._scopes
12478 .insert(Scope::CloudPlatform.as_ref().to_string());
12479 }
12480
12481 #[allow(clippy::single_element_loop)]
12482 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12483 url = params.uri_replacement(url, param_name, find_this, true);
12484 }
12485 {
12486 let to_remove = ["name"];
12487 params.remove_params(&to_remove);
12488 }
12489
12490 let url = params.parse_with_url(&url);
12491
12492 let mut json_mime_type = mime::APPLICATION_JSON;
12493 let mut request_value_reader = {
12494 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12495 common::remove_json_null_values(&mut value);
12496 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12497 serde_json::to_writer(&mut dst, &value).unwrap();
12498 dst
12499 };
12500 let request_size = request_value_reader
12501 .seek(std::io::SeekFrom::End(0))
12502 .unwrap();
12503 request_value_reader
12504 .seek(std::io::SeekFrom::Start(0))
12505 .unwrap();
12506
12507 loop {
12508 let token = match self
12509 .hub
12510 .auth
12511 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12512 .await
12513 {
12514 Ok(token) => token,
12515 Err(e) => match dlg.token(e) {
12516 Ok(token) => token,
12517 Err(e) => {
12518 dlg.finished(false);
12519 return Err(common::Error::MissingToken(e));
12520 }
12521 },
12522 };
12523 request_value_reader
12524 .seek(std::io::SeekFrom::Start(0))
12525 .unwrap();
12526 let mut req_result = {
12527 let client = &self.hub.client;
12528 dlg.pre_request();
12529 let mut req_builder = hyper::Request::builder()
12530 .method(hyper::Method::PATCH)
12531 .uri(url.as_str())
12532 .header(USER_AGENT, self.hub._user_agent.clone());
12533
12534 if let Some(token) = token.as_ref() {
12535 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12536 }
12537
12538 let request = req_builder
12539 .header(CONTENT_TYPE, json_mime_type.to_string())
12540 .header(CONTENT_LENGTH, request_size as u64)
12541 .body(common::to_body(
12542 request_value_reader.get_ref().clone().into(),
12543 ));
12544
12545 client.request(request.unwrap()).await
12546 };
12547
12548 match req_result {
12549 Err(err) => {
12550 if let common::Retry::After(d) = dlg.http_error(&err) {
12551 sleep(d).await;
12552 continue;
12553 }
12554 dlg.finished(false);
12555 return Err(common::Error::HttpError(err));
12556 }
12557 Ok(res) => {
12558 let (mut parts, body) = res.into_parts();
12559 let mut body = common::Body::new(body);
12560 if !parts.status.is_success() {
12561 let bytes = common::to_bytes(body).await.unwrap_or_default();
12562 let error = serde_json::from_str(&common::to_string(&bytes));
12563 let response = common::to_response(parts, bytes.into());
12564
12565 if let common::Retry::After(d) =
12566 dlg.http_failure(&response, error.as_ref().ok())
12567 {
12568 sleep(d).await;
12569 continue;
12570 }
12571
12572 dlg.finished(false);
12573
12574 return Err(match error {
12575 Ok(value) => common::Error::BadRequest(value),
12576 _ => common::Error::Failure(response),
12577 });
12578 }
12579 let response = {
12580 let bytes = common::to_bytes(body).await.unwrap_or_default();
12581 let encoded = common::to_string(&bytes);
12582 match serde_json::from_str(&encoded) {
12583 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12584 Err(error) => {
12585 dlg.response_json_decode_error(&encoded, &error);
12586 return Err(common::Error::JsonDecodeError(
12587 encoded.to_string(),
12588 error,
12589 ));
12590 }
12591 }
12592 };
12593
12594 dlg.finished(true);
12595 return Ok(response);
12596 }
12597 }
12598 }
12599 }
12600
12601 ///
12602 /// Sets the *request* property to the given value.
12603 ///
12604 /// Even though the property as already been set when instantiating this call,
12605 /// we provide this method for API completeness.
12606 pub fn request(
12607 mut self,
12608 new_value: UpdateSubscriptionRequest,
12609 ) -> ProjectSubscriptionPatchCall<'a, C> {
12610 self._request = new_value;
12611 self
12612 }
12613 /// Required. Identifier. The name of the subscription. It must have the format `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
12614 ///
12615 /// Sets the *name* path property to the given value.
12616 ///
12617 /// Even though the property as already been set when instantiating this call,
12618 /// we provide this method for API completeness.
12619 pub fn name(mut self, new_value: &str) -> ProjectSubscriptionPatchCall<'a, C> {
12620 self._name = new_value.to_string();
12621 self
12622 }
12623 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12624 /// while executing the actual API request.
12625 ///
12626 /// ````text
12627 /// It should be used to handle progress information, and to implement a certain level of resilience.
12628 /// ````
12629 ///
12630 /// Sets the *delegate* property to the given value.
12631 pub fn delegate(
12632 mut self,
12633 new_value: &'a mut dyn common::Delegate,
12634 ) -> ProjectSubscriptionPatchCall<'a, C> {
12635 self._delegate = Some(new_value);
12636 self
12637 }
12638
12639 /// Set any additional parameter of the query string used in the request.
12640 /// It should be used to set parameters which are not yet available through their own
12641 /// setters.
12642 ///
12643 /// Please note that this method must not be used to set any of the known parameters
12644 /// which have their own setter method. If done anyway, the request will fail.
12645 ///
12646 /// # Additional Parameters
12647 ///
12648 /// * *$.xgafv* (query-string) - V1 error format.
12649 /// * *access_token* (query-string) - OAuth access token.
12650 /// * *alt* (query-string) - Data format for response.
12651 /// * *callback* (query-string) - JSONP
12652 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12653 /// * *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.
12654 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12655 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12656 /// * *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.
12657 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12658 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12659 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionPatchCall<'a, C>
12660 where
12661 T: AsRef<str>,
12662 {
12663 self._additional_params
12664 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12665 self
12666 }
12667
12668 /// Identifies the authorization scope for the method you are building.
12669 ///
12670 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12671 /// [`Scope::CloudPlatform`].
12672 ///
12673 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12674 /// tokens for more than one scope.
12675 ///
12676 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12677 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12678 /// sufficient, a read-write scope will do as well.
12679 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionPatchCall<'a, C>
12680 where
12681 St: AsRef<str>,
12682 {
12683 self._scopes.insert(String::from(scope.as_ref()));
12684 self
12685 }
12686 /// Identifies the authorization scope(s) for the method you are building.
12687 ///
12688 /// See [`Self::add_scope()`] for details.
12689 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionPatchCall<'a, C>
12690 where
12691 I: IntoIterator<Item = St>,
12692 St: AsRef<str>,
12693 {
12694 self._scopes
12695 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12696 self
12697 }
12698
12699 /// Removes all scopes, and no default scope will be used either.
12700 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12701 /// for details).
12702 pub fn clear_scopes(mut self) -> ProjectSubscriptionPatchCall<'a, C> {
12703 self._scopes.clear();
12704 self
12705 }
12706}
12707
12708/// Pulls messages from the server.
12709///
12710/// A builder for the *subscriptions.pull* method supported by a *project* resource.
12711/// It is not used directly, but through a [`ProjectMethods`] instance.
12712///
12713/// # Example
12714///
12715/// Instantiate a resource method builder
12716///
12717/// ```test_harness,no_run
12718/// # extern crate hyper;
12719/// # extern crate hyper_rustls;
12720/// # extern crate google_pubsub1 as pubsub1;
12721/// use pubsub1::api::PullRequest;
12722/// # async fn dox() {
12723/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12724///
12725/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12726/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12727/// # .with_native_roots()
12728/// # .unwrap()
12729/// # .https_only()
12730/// # .enable_http2()
12731/// # .build();
12732///
12733/// # let executor = hyper_util::rt::TokioExecutor::new();
12734/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12735/// # secret,
12736/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12737/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12738/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12739/// # ),
12740/// # ).build().await.unwrap();
12741///
12742/// # let client = hyper_util::client::legacy::Client::builder(
12743/// # hyper_util::rt::TokioExecutor::new()
12744/// # )
12745/// # .build(
12746/// # hyper_rustls::HttpsConnectorBuilder::new()
12747/// # .with_native_roots()
12748/// # .unwrap()
12749/// # .https_or_http()
12750/// # .enable_http2()
12751/// # .build()
12752/// # );
12753/// # let mut hub = Pubsub::new(client, auth);
12754/// // As the method needs a request, you would usually fill it with the desired information
12755/// // into the respective structure. Some of the parts shown here might not be applicable !
12756/// // Values shown here are possibly random and not representative !
12757/// let mut req = PullRequest::default();
12758///
12759/// // You can configure optional parameters by calling the respective setters at will, and
12760/// // execute the final call using `doit()`.
12761/// // Values shown here are possibly random and not representative !
12762/// let result = hub.projects().subscriptions_pull(req, "subscription")
12763/// .doit().await;
12764/// # }
12765/// ```
12766pub struct ProjectSubscriptionPullCall<'a, C>
12767where
12768 C: 'a,
12769{
12770 hub: &'a Pubsub<C>,
12771 _request: PullRequest,
12772 _subscription: String,
12773 _delegate: Option<&'a mut dyn common::Delegate>,
12774 _additional_params: HashMap<String, String>,
12775 _scopes: BTreeSet<String>,
12776}
12777
12778impl<'a, C> common::CallBuilder for ProjectSubscriptionPullCall<'a, C> {}
12779
12780impl<'a, C> ProjectSubscriptionPullCall<'a, C>
12781where
12782 C: common::Connector,
12783{
12784 /// Perform the operation you have build so far.
12785 pub async fn doit(mut self) -> common::Result<(common::Response, PullResponse)> {
12786 use std::borrow::Cow;
12787 use std::io::{Read, Seek};
12788
12789 use common::{url::Params, ToParts};
12790 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12791
12792 let mut dd = common::DefaultDelegate;
12793 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12794 dlg.begin(common::MethodInfo {
12795 id: "pubsub.projects.subscriptions.pull",
12796 http_method: hyper::Method::POST,
12797 });
12798
12799 for &field in ["alt", "subscription"].iter() {
12800 if self._additional_params.contains_key(field) {
12801 dlg.finished(false);
12802 return Err(common::Error::FieldClash(field));
12803 }
12804 }
12805
12806 let mut params = Params::with_capacity(4 + self._additional_params.len());
12807 params.push("subscription", self._subscription);
12808
12809 params.extend(self._additional_params.iter());
12810
12811 params.push("alt", "json");
12812 let mut url = self.hub._base_url.clone() + "v1/{+subscription}:pull";
12813 if self._scopes.is_empty() {
12814 self._scopes
12815 .insert(Scope::CloudPlatform.as_ref().to_string());
12816 }
12817
12818 #[allow(clippy::single_element_loop)]
12819 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
12820 url = params.uri_replacement(url, param_name, find_this, true);
12821 }
12822 {
12823 let to_remove = ["subscription"];
12824 params.remove_params(&to_remove);
12825 }
12826
12827 let url = params.parse_with_url(&url);
12828
12829 let mut json_mime_type = mime::APPLICATION_JSON;
12830 let mut request_value_reader = {
12831 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12832 common::remove_json_null_values(&mut value);
12833 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12834 serde_json::to_writer(&mut dst, &value).unwrap();
12835 dst
12836 };
12837 let request_size = request_value_reader
12838 .seek(std::io::SeekFrom::End(0))
12839 .unwrap();
12840 request_value_reader
12841 .seek(std::io::SeekFrom::Start(0))
12842 .unwrap();
12843
12844 loop {
12845 let token = match self
12846 .hub
12847 .auth
12848 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12849 .await
12850 {
12851 Ok(token) => token,
12852 Err(e) => match dlg.token(e) {
12853 Ok(token) => token,
12854 Err(e) => {
12855 dlg.finished(false);
12856 return Err(common::Error::MissingToken(e));
12857 }
12858 },
12859 };
12860 request_value_reader
12861 .seek(std::io::SeekFrom::Start(0))
12862 .unwrap();
12863 let mut req_result = {
12864 let client = &self.hub.client;
12865 dlg.pre_request();
12866 let mut req_builder = hyper::Request::builder()
12867 .method(hyper::Method::POST)
12868 .uri(url.as_str())
12869 .header(USER_AGENT, self.hub._user_agent.clone());
12870
12871 if let Some(token) = token.as_ref() {
12872 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12873 }
12874
12875 let request = req_builder
12876 .header(CONTENT_TYPE, json_mime_type.to_string())
12877 .header(CONTENT_LENGTH, request_size as u64)
12878 .body(common::to_body(
12879 request_value_reader.get_ref().clone().into(),
12880 ));
12881
12882 client.request(request.unwrap()).await
12883 };
12884
12885 match req_result {
12886 Err(err) => {
12887 if let common::Retry::After(d) = dlg.http_error(&err) {
12888 sleep(d).await;
12889 continue;
12890 }
12891 dlg.finished(false);
12892 return Err(common::Error::HttpError(err));
12893 }
12894 Ok(res) => {
12895 let (mut parts, body) = res.into_parts();
12896 let mut body = common::Body::new(body);
12897 if !parts.status.is_success() {
12898 let bytes = common::to_bytes(body).await.unwrap_or_default();
12899 let error = serde_json::from_str(&common::to_string(&bytes));
12900 let response = common::to_response(parts, bytes.into());
12901
12902 if let common::Retry::After(d) =
12903 dlg.http_failure(&response, error.as_ref().ok())
12904 {
12905 sleep(d).await;
12906 continue;
12907 }
12908
12909 dlg.finished(false);
12910
12911 return Err(match error {
12912 Ok(value) => common::Error::BadRequest(value),
12913 _ => common::Error::Failure(response),
12914 });
12915 }
12916 let response = {
12917 let bytes = common::to_bytes(body).await.unwrap_or_default();
12918 let encoded = common::to_string(&bytes);
12919 match serde_json::from_str(&encoded) {
12920 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12921 Err(error) => {
12922 dlg.response_json_decode_error(&encoded, &error);
12923 return Err(common::Error::JsonDecodeError(
12924 encoded.to_string(),
12925 error,
12926 ));
12927 }
12928 }
12929 };
12930
12931 dlg.finished(true);
12932 return Ok(response);
12933 }
12934 }
12935 }
12936 }
12937
12938 ///
12939 /// Sets the *request* property to the given value.
12940 ///
12941 /// Even though the property as already been set when instantiating this call,
12942 /// we provide this method for API completeness.
12943 pub fn request(mut self, new_value: PullRequest) -> ProjectSubscriptionPullCall<'a, C> {
12944 self._request = new_value;
12945 self
12946 }
12947 /// Required. The subscription from which messages should be pulled. Format is `projects/{project}/subscriptions/{sub}`.
12948 ///
12949 /// Sets the *subscription* path property to the given value.
12950 ///
12951 /// Even though the property as already been set when instantiating this call,
12952 /// we provide this method for API completeness.
12953 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionPullCall<'a, C> {
12954 self._subscription = new_value.to_string();
12955 self
12956 }
12957 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12958 /// while executing the actual API request.
12959 ///
12960 /// ````text
12961 /// It should be used to handle progress information, and to implement a certain level of resilience.
12962 /// ````
12963 ///
12964 /// Sets the *delegate* property to the given value.
12965 pub fn delegate(
12966 mut self,
12967 new_value: &'a mut dyn common::Delegate,
12968 ) -> ProjectSubscriptionPullCall<'a, C> {
12969 self._delegate = Some(new_value);
12970 self
12971 }
12972
12973 /// Set any additional parameter of the query string used in the request.
12974 /// It should be used to set parameters which are not yet available through their own
12975 /// setters.
12976 ///
12977 /// Please note that this method must not be used to set any of the known parameters
12978 /// which have their own setter method. If done anyway, the request will fail.
12979 ///
12980 /// # Additional Parameters
12981 ///
12982 /// * *$.xgafv* (query-string) - V1 error format.
12983 /// * *access_token* (query-string) - OAuth access token.
12984 /// * *alt* (query-string) - Data format for response.
12985 /// * *callback* (query-string) - JSONP
12986 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12987 /// * *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.
12988 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12989 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12990 /// * *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.
12991 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12992 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12993 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionPullCall<'a, C>
12994 where
12995 T: AsRef<str>,
12996 {
12997 self._additional_params
12998 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12999 self
13000 }
13001
13002 /// Identifies the authorization scope for the method you are building.
13003 ///
13004 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13005 /// [`Scope::CloudPlatform`].
13006 ///
13007 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13008 /// tokens for more than one scope.
13009 ///
13010 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13011 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13012 /// sufficient, a read-write scope will do as well.
13013 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionPullCall<'a, C>
13014 where
13015 St: AsRef<str>,
13016 {
13017 self._scopes.insert(String::from(scope.as_ref()));
13018 self
13019 }
13020 /// Identifies the authorization scope(s) for the method you are building.
13021 ///
13022 /// See [`Self::add_scope()`] for details.
13023 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionPullCall<'a, C>
13024 where
13025 I: IntoIterator<Item = St>,
13026 St: AsRef<str>,
13027 {
13028 self._scopes
13029 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13030 self
13031 }
13032
13033 /// Removes all scopes, and no default scope will be used either.
13034 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13035 /// for details).
13036 pub fn clear_scopes(mut self) -> ProjectSubscriptionPullCall<'a, C> {
13037 self._scopes.clear();
13038 self
13039 }
13040}
13041
13042/// Seeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request. Snapshots are used in [Seek] (https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. Note that both the subscription and the snapshot must be on the same topic.
13043///
13044/// A builder for the *subscriptions.seek* method supported by a *project* resource.
13045/// It is not used directly, but through a [`ProjectMethods`] instance.
13046///
13047/// # Example
13048///
13049/// Instantiate a resource method builder
13050///
13051/// ```test_harness,no_run
13052/// # extern crate hyper;
13053/// # extern crate hyper_rustls;
13054/// # extern crate google_pubsub1 as pubsub1;
13055/// use pubsub1::api::SeekRequest;
13056/// # async fn dox() {
13057/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13058///
13059/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13060/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13061/// # .with_native_roots()
13062/// # .unwrap()
13063/// # .https_only()
13064/// # .enable_http2()
13065/// # .build();
13066///
13067/// # let executor = hyper_util::rt::TokioExecutor::new();
13068/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13069/// # secret,
13070/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13071/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13072/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13073/// # ),
13074/// # ).build().await.unwrap();
13075///
13076/// # let client = hyper_util::client::legacy::Client::builder(
13077/// # hyper_util::rt::TokioExecutor::new()
13078/// # )
13079/// # .build(
13080/// # hyper_rustls::HttpsConnectorBuilder::new()
13081/// # .with_native_roots()
13082/// # .unwrap()
13083/// # .https_or_http()
13084/// # .enable_http2()
13085/// # .build()
13086/// # );
13087/// # let mut hub = Pubsub::new(client, auth);
13088/// // As the method needs a request, you would usually fill it with the desired information
13089/// // into the respective structure. Some of the parts shown here might not be applicable !
13090/// // Values shown here are possibly random and not representative !
13091/// let mut req = SeekRequest::default();
13092///
13093/// // You can configure optional parameters by calling the respective setters at will, and
13094/// // execute the final call using `doit()`.
13095/// // Values shown here are possibly random and not representative !
13096/// let result = hub.projects().subscriptions_seek(req, "subscription")
13097/// .doit().await;
13098/// # }
13099/// ```
13100pub struct ProjectSubscriptionSeekCall<'a, C>
13101where
13102 C: 'a,
13103{
13104 hub: &'a Pubsub<C>,
13105 _request: SeekRequest,
13106 _subscription: String,
13107 _delegate: Option<&'a mut dyn common::Delegate>,
13108 _additional_params: HashMap<String, String>,
13109 _scopes: BTreeSet<String>,
13110}
13111
13112impl<'a, C> common::CallBuilder for ProjectSubscriptionSeekCall<'a, C> {}
13113
13114impl<'a, C> ProjectSubscriptionSeekCall<'a, C>
13115where
13116 C: common::Connector,
13117{
13118 /// Perform the operation you have build so far.
13119 pub async fn doit(mut self) -> common::Result<(common::Response, SeekResponse)> {
13120 use std::borrow::Cow;
13121 use std::io::{Read, Seek};
13122
13123 use common::{url::Params, ToParts};
13124 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13125
13126 let mut dd = common::DefaultDelegate;
13127 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13128 dlg.begin(common::MethodInfo {
13129 id: "pubsub.projects.subscriptions.seek",
13130 http_method: hyper::Method::POST,
13131 });
13132
13133 for &field in ["alt", "subscription"].iter() {
13134 if self._additional_params.contains_key(field) {
13135 dlg.finished(false);
13136 return Err(common::Error::FieldClash(field));
13137 }
13138 }
13139
13140 let mut params = Params::with_capacity(4 + self._additional_params.len());
13141 params.push("subscription", self._subscription);
13142
13143 params.extend(self._additional_params.iter());
13144
13145 params.push("alt", "json");
13146 let mut url = self.hub._base_url.clone() + "v1/{+subscription}:seek";
13147 if self._scopes.is_empty() {
13148 self._scopes
13149 .insert(Scope::CloudPlatform.as_ref().to_string());
13150 }
13151
13152 #[allow(clippy::single_element_loop)]
13153 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
13154 url = params.uri_replacement(url, param_name, find_this, true);
13155 }
13156 {
13157 let to_remove = ["subscription"];
13158 params.remove_params(&to_remove);
13159 }
13160
13161 let url = params.parse_with_url(&url);
13162
13163 let mut json_mime_type = mime::APPLICATION_JSON;
13164 let mut request_value_reader = {
13165 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13166 common::remove_json_null_values(&mut value);
13167 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13168 serde_json::to_writer(&mut dst, &value).unwrap();
13169 dst
13170 };
13171 let request_size = request_value_reader
13172 .seek(std::io::SeekFrom::End(0))
13173 .unwrap();
13174 request_value_reader
13175 .seek(std::io::SeekFrom::Start(0))
13176 .unwrap();
13177
13178 loop {
13179 let token = match self
13180 .hub
13181 .auth
13182 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13183 .await
13184 {
13185 Ok(token) => token,
13186 Err(e) => match dlg.token(e) {
13187 Ok(token) => token,
13188 Err(e) => {
13189 dlg.finished(false);
13190 return Err(common::Error::MissingToken(e));
13191 }
13192 },
13193 };
13194 request_value_reader
13195 .seek(std::io::SeekFrom::Start(0))
13196 .unwrap();
13197 let mut req_result = {
13198 let client = &self.hub.client;
13199 dlg.pre_request();
13200 let mut req_builder = hyper::Request::builder()
13201 .method(hyper::Method::POST)
13202 .uri(url.as_str())
13203 .header(USER_AGENT, self.hub._user_agent.clone());
13204
13205 if let Some(token) = token.as_ref() {
13206 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13207 }
13208
13209 let request = req_builder
13210 .header(CONTENT_TYPE, json_mime_type.to_string())
13211 .header(CONTENT_LENGTH, request_size as u64)
13212 .body(common::to_body(
13213 request_value_reader.get_ref().clone().into(),
13214 ));
13215
13216 client.request(request.unwrap()).await
13217 };
13218
13219 match req_result {
13220 Err(err) => {
13221 if let common::Retry::After(d) = dlg.http_error(&err) {
13222 sleep(d).await;
13223 continue;
13224 }
13225 dlg.finished(false);
13226 return Err(common::Error::HttpError(err));
13227 }
13228 Ok(res) => {
13229 let (mut parts, body) = res.into_parts();
13230 let mut body = common::Body::new(body);
13231 if !parts.status.is_success() {
13232 let bytes = common::to_bytes(body).await.unwrap_or_default();
13233 let error = serde_json::from_str(&common::to_string(&bytes));
13234 let response = common::to_response(parts, bytes.into());
13235
13236 if let common::Retry::After(d) =
13237 dlg.http_failure(&response, error.as_ref().ok())
13238 {
13239 sleep(d).await;
13240 continue;
13241 }
13242
13243 dlg.finished(false);
13244
13245 return Err(match error {
13246 Ok(value) => common::Error::BadRequest(value),
13247 _ => common::Error::Failure(response),
13248 });
13249 }
13250 let response = {
13251 let bytes = common::to_bytes(body).await.unwrap_or_default();
13252 let encoded = common::to_string(&bytes);
13253 match serde_json::from_str(&encoded) {
13254 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13255 Err(error) => {
13256 dlg.response_json_decode_error(&encoded, &error);
13257 return Err(common::Error::JsonDecodeError(
13258 encoded.to_string(),
13259 error,
13260 ));
13261 }
13262 }
13263 };
13264
13265 dlg.finished(true);
13266 return Ok(response);
13267 }
13268 }
13269 }
13270 }
13271
13272 ///
13273 /// Sets the *request* property to the given value.
13274 ///
13275 /// Even though the property as already been set when instantiating this call,
13276 /// we provide this method for API completeness.
13277 pub fn request(mut self, new_value: SeekRequest) -> ProjectSubscriptionSeekCall<'a, C> {
13278 self._request = new_value;
13279 self
13280 }
13281 /// Required. The subscription to affect.
13282 ///
13283 /// Sets the *subscription* path property to the given value.
13284 ///
13285 /// Even though the property as already been set when instantiating this call,
13286 /// we provide this method for API completeness.
13287 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionSeekCall<'a, C> {
13288 self._subscription = new_value.to_string();
13289 self
13290 }
13291 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13292 /// while executing the actual API request.
13293 ///
13294 /// ````text
13295 /// It should be used to handle progress information, and to implement a certain level of resilience.
13296 /// ````
13297 ///
13298 /// Sets the *delegate* property to the given value.
13299 pub fn delegate(
13300 mut self,
13301 new_value: &'a mut dyn common::Delegate,
13302 ) -> ProjectSubscriptionSeekCall<'a, C> {
13303 self._delegate = Some(new_value);
13304 self
13305 }
13306
13307 /// Set any additional parameter of the query string used in the request.
13308 /// It should be used to set parameters which are not yet available through their own
13309 /// setters.
13310 ///
13311 /// Please note that this method must not be used to set any of the known parameters
13312 /// which have their own setter method. If done anyway, the request will fail.
13313 ///
13314 /// # Additional Parameters
13315 ///
13316 /// * *$.xgafv* (query-string) - V1 error format.
13317 /// * *access_token* (query-string) - OAuth access token.
13318 /// * *alt* (query-string) - Data format for response.
13319 /// * *callback* (query-string) - JSONP
13320 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13321 /// * *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.
13322 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13323 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13324 /// * *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.
13325 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13326 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13327 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionSeekCall<'a, C>
13328 where
13329 T: AsRef<str>,
13330 {
13331 self._additional_params
13332 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13333 self
13334 }
13335
13336 /// Identifies the authorization scope for the method you are building.
13337 ///
13338 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13339 /// [`Scope::CloudPlatform`].
13340 ///
13341 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13342 /// tokens for more than one scope.
13343 ///
13344 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13345 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13346 /// sufficient, a read-write scope will do as well.
13347 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionSeekCall<'a, C>
13348 where
13349 St: AsRef<str>,
13350 {
13351 self._scopes.insert(String::from(scope.as_ref()));
13352 self
13353 }
13354 /// Identifies the authorization scope(s) for the method you are building.
13355 ///
13356 /// See [`Self::add_scope()`] for details.
13357 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionSeekCall<'a, C>
13358 where
13359 I: IntoIterator<Item = St>,
13360 St: AsRef<str>,
13361 {
13362 self._scopes
13363 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13364 self
13365 }
13366
13367 /// Removes all scopes, and no default scope will be used either.
13368 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13369 /// for details).
13370 pub fn clear_scopes(mut self) -> ProjectSubscriptionSeekCall<'a, C> {
13371 self._scopes.clear();
13372 self
13373 }
13374}
13375
13376/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
13377///
13378/// A builder for the *subscriptions.setIamPolicy* method supported by a *project* resource.
13379/// It is not used directly, but through a [`ProjectMethods`] instance.
13380///
13381/// # Example
13382///
13383/// Instantiate a resource method builder
13384///
13385/// ```test_harness,no_run
13386/// # extern crate hyper;
13387/// # extern crate hyper_rustls;
13388/// # extern crate google_pubsub1 as pubsub1;
13389/// use pubsub1::api::SetIamPolicyRequest;
13390/// # async fn dox() {
13391/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13392///
13393/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13394/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13395/// # .with_native_roots()
13396/// # .unwrap()
13397/// # .https_only()
13398/// # .enable_http2()
13399/// # .build();
13400///
13401/// # let executor = hyper_util::rt::TokioExecutor::new();
13402/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13403/// # secret,
13404/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13405/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13406/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13407/// # ),
13408/// # ).build().await.unwrap();
13409///
13410/// # let client = hyper_util::client::legacy::Client::builder(
13411/// # hyper_util::rt::TokioExecutor::new()
13412/// # )
13413/// # .build(
13414/// # hyper_rustls::HttpsConnectorBuilder::new()
13415/// # .with_native_roots()
13416/// # .unwrap()
13417/// # .https_or_http()
13418/// # .enable_http2()
13419/// # .build()
13420/// # );
13421/// # let mut hub = Pubsub::new(client, auth);
13422/// // As the method needs a request, you would usually fill it with the desired information
13423/// // into the respective structure. Some of the parts shown here might not be applicable !
13424/// // Values shown here are possibly random and not representative !
13425/// let mut req = SetIamPolicyRequest::default();
13426///
13427/// // You can configure optional parameters by calling the respective setters at will, and
13428/// // execute the final call using `doit()`.
13429/// // Values shown here are possibly random and not representative !
13430/// let result = hub.projects().subscriptions_set_iam_policy(req, "resource")
13431/// .doit().await;
13432/// # }
13433/// ```
13434pub struct ProjectSubscriptionSetIamPolicyCall<'a, C>
13435where
13436 C: 'a,
13437{
13438 hub: &'a Pubsub<C>,
13439 _request: SetIamPolicyRequest,
13440 _resource: String,
13441 _delegate: Option<&'a mut dyn common::Delegate>,
13442 _additional_params: HashMap<String, String>,
13443 _scopes: BTreeSet<String>,
13444}
13445
13446impl<'a, C> common::CallBuilder for ProjectSubscriptionSetIamPolicyCall<'a, C> {}
13447
13448impl<'a, C> ProjectSubscriptionSetIamPolicyCall<'a, C>
13449where
13450 C: common::Connector,
13451{
13452 /// Perform the operation you have build so far.
13453 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
13454 use std::borrow::Cow;
13455 use std::io::{Read, Seek};
13456
13457 use common::{url::Params, ToParts};
13458 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13459
13460 let mut dd = common::DefaultDelegate;
13461 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13462 dlg.begin(common::MethodInfo {
13463 id: "pubsub.projects.subscriptions.setIamPolicy",
13464 http_method: hyper::Method::POST,
13465 });
13466
13467 for &field in ["alt", "resource"].iter() {
13468 if self._additional_params.contains_key(field) {
13469 dlg.finished(false);
13470 return Err(common::Error::FieldClash(field));
13471 }
13472 }
13473
13474 let mut params = Params::with_capacity(4 + self._additional_params.len());
13475 params.push("resource", self._resource);
13476
13477 params.extend(self._additional_params.iter());
13478
13479 params.push("alt", "json");
13480 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
13481 if self._scopes.is_empty() {
13482 self._scopes
13483 .insert(Scope::CloudPlatform.as_ref().to_string());
13484 }
13485
13486 #[allow(clippy::single_element_loop)]
13487 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
13488 url = params.uri_replacement(url, param_name, find_this, true);
13489 }
13490 {
13491 let to_remove = ["resource"];
13492 params.remove_params(&to_remove);
13493 }
13494
13495 let url = params.parse_with_url(&url);
13496
13497 let mut json_mime_type = mime::APPLICATION_JSON;
13498 let mut request_value_reader = {
13499 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13500 common::remove_json_null_values(&mut value);
13501 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13502 serde_json::to_writer(&mut dst, &value).unwrap();
13503 dst
13504 };
13505 let request_size = request_value_reader
13506 .seek(std::io::SeekFrom::End(0))
13507 .unwrap();
13508 request_value_reader
13509 .seek(std::io::SeekFrom::Start(0))
13510 .unwrap();
13511
13512 loop {
13513 let token = match self
13514 .hub
13515 .auth
13516 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13517 .await
13518 {
13519 Ok(token) => token,
13520 Err(e) => match dlg.token(e) {
13521 Ok(token) => token,
13522 Err(e) => {
13523 dlg.finished(false);
13524 return Err(common::Error::MissingToken(e));
13525 }
13526 },
13527 };
13528 request_value_reader
13529 .seek(std::io::SeekFrom::Start(0))
13530 .unwrap();
13531 let mut req_result = {
13532 let client = &self.hub.client;
13533 dlg.pre_request();
13534 let mut req_builder = hyper::Request::builder()
13535 .method(hyper::Method::POST)
13536 .uri(url.as_str())
13537 .header(USER_AGENT, self.hub._user_agent.clone());
13538
13539 if let Some(token) = token.as_ref() {
13540 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13541 }
13542
13543 let request = req_builder
13544 .header(CONTENT_TYPE, json_mime_type.to_string())
13545 .header(CONTENT_LENGTH, request_size as u64)
13546 .body(common::to_body(
13547 request_value_reader.get_ref().clone().into(),
13548 ));
13549
13550 client.request(request.unwrap()).await
13551 };
13552
13553 match req_result {
13554 Err(err) => {
13555 if let common::Retry::After(d) = dlg.http_error(&err) {
13556 sleep(d).await;
13557 continue;
13558 }
13559 dlg.finished(false);
13560 return Err(common::Error::HttpError(err));
13561 }
13562 Ok(res) => {
13563 let (mut parts, body) = res.into_parts();
13564 let mut body = common::Body::new(body);
13565 if !parts.status.is_success() {
13566 let bytes = common::to_bytes(body).await.unwrap_or_default();
13567 let error = serde_json::from_str(&common::to_string(&bytes));
13568 let response = common::to_response(parts, bytes.into());
13569
13570 if let common::Retry::After(d) =
13571 dlg.http_failure(&response, error.as_ref().ok())
13572 {
13573 sleep(d).await;
13574 continue;
13575 }
13576
13577 dlg.finished(false);
13578
13579 return Err(match error {
13580 Ok(value) => common::Error::BadRequest(value),
13581 _ => common::Error::Failure(response),
13582 });
13583 }
13584 let response = {
13585 let bytes = common::to_bytes(body).await.unwrap_or_default();
13586 let encoded = common::to_string(&bytes);
13587 match serde_json::from_str(&encoded) {
13588 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13589 Err(error) => {
13590 dlg.response_json_decode_error(&encoded, &error);
13591 return Err(common::Error::JsonDecodeError(
13592 encoded.to_string(),
13593 error,
13594 ));
13595 }
13596 }
13597 };
13598
13599 dlg.finished(true);
13600 return Ok(response);
13601 }
13602 }
13603 }
13604 }
13605
13606 ///
13607 /// Sets the *request* property to the given value.
13608 ///
13609 /// Even though the property as already been set when instantiating this call,
13610 /// we provide this method for API completeness.
13611 pub fn request(
13612 mut self,
13613 new_value: SetIamPolicyRequest,
13614 ) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
13615 self._request = new_value;
13616 self
13617 }
13618 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
13619 ///
13620 /// Sets the *resource* path property to the given value.
13621 ///
13622 /// Even though the property as already been set when instantiating this call,
13623 /// we provide this method for API completeness.
13624 pub fn resource(mut self, new_value: &str) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
13625 self._resource = new_value.to_string();
13626 self
13627 }
13628 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13629 /// while executing the actual API request.
13630 ///
13631 /// ````text
13632 /// It should be used to handle progress information, and to implement a certain level of resilience.
13633 /// ````
13634 ///
13635 /// Sets the *delegate* property to the given value.
13636 pub fn delegate(
13637 mut self,
13638 new_value: &'a mut dyn common::Delegate,
13639 ) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
13640 self._delegate = Some(new_value);
13641 self
13642 }
13643
13644 /// Set any additional parameter of the query string used in the request.
13645 /// It should be used to set parameters which are not yet available through their own
13646 /// setters.
13647 ///
13648 /// Please note that this method must not be used to set any of the known parameters
13649 /// which have their own setter method. If done anyway, the request will fail.
13650 ///
13651 /// # Additional Parameters
13652 ///
13653 /// * *$.xgafv* (query-string) - V1 error format.
13654 /// * *access_token* (query-string) - OAuth access token.
13655 /// * *alt* (query-string) - Data format for response.
13656 /// * *callback* (query-string) - JSONP
13657 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13658 /// * *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.
13659 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13660 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13661 /// * *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.
13662 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13663 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13664 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionSetIamPolicyCall<'a, C>
13665 where
13666 T: AsRef<str>,
13667 {
13668 self._additional_params
13669 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13670 self
13671 }
13672
13673 /// Identifies the authorization scope for the method you are building.
13674 ///
13675 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13676 /// [`Scope::CloudPlatform`].
13677 ///
13678 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13679 /// tokens for more than one scope.
13680 ///
13681 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13682 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13683 /// sufficient, a read-write scope will do as well.
13684 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionSetIamPolicyCall<'a, C>
13685 where
13686 St: AsRef<str>,
13687 {
13688 self._scopes.insert(String::from(scope.as_ref()));
13689 self
13690 }
13691 /// Identifies the authorization scope(s) for the method you are building.
13692 ///
13693 /// See [`Self::add_scope()`] for details.
13694 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionSetIamPolicyCall<'a, C>
13695 where
13696 I: IntoIterator<Item = St>,
13697 St: AsRef<str>,
13698 {
13699 self._scopes
13700 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13701 self
13702 }
13703
13704 /// Removes all scopes, and no default scope will be used either.
13705 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13706 /// for details).
13707 pub fn clear_scopes(mut self) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
13708 self._scopes.clear();
13709 self
13710 }
13711}
13712
13713/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
13714///
13715/// A builder for the *subscriptions.testIamPermissions* method supported by a *project* resource.
13716/// It is not used directly, but through a [`ProjectMethods`] instance.
13717///
13718/// # Example
13719///
13720/// Instantiate a resource method builder
13721///
13722/// ```test_harness,no_run
13723/// # extern crate hyper;
13724/// # extern crate hyper_rustls;
13725/// # extern crate google_pubsub1 as pubsub1;
13726/// use pubsub1::api::TestIamPermissionsRequest;
13727/// # async fn dox() {
13728/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13729///
13730/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13731/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13732/// # .with_native_roots()
13733/// # .unwrap()
13734/// # .https_only()
13735/// # .enable_http2()
13736/// # .build();
13737///
13738/// # let executor = hyper_util::rt::TokioExecutor::new();
13739/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13740/// # secret,
13741/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13742/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13743/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13744/// # ),
13745/// # ).build().await.unwrap();
13746///
13747/// # let client = hyper_util::client::legacy::Client::builder(
13748/// # hyper_util::rt::TokioExecutor::new()
13749/// # )
13750/// # .build(
13751/// # hyper_rustls::HttpsConnectorBuilder::new()
13752/// # .with_native_roots()
13753/// # .unwrap()
13754/// # .https_or_http()
13755/// # .enable_http2()
13756/// # .build()
13757/// # );
13758/// # let mut hub = Pubsub::new(client, auth);
13759/// // As the method needs a request, you would usually fill it with the desired information
13760/// // into the respective structure. Some of the parts shown here might not be applicable !
13761/// // Values shown here are possibly random and not representative !
13762/// let mut req = TestIamPermissionsRequest::default();
13763///
13764/// // You can configure optional parameters by calling the respective setters at will, and
13765/// // execute the final call using `doit()`.
13766/// // Values shown here are possibly random and not representative !
13767/// let result = hub.projects().subscriptions_test_iam_permissions(req, "resource")
13768/// .doit().await;
13769/// # }
13770/// ```
13771pub struct ProjectSubscriptionTestIamPermissionCall<'a, C>
13772where
13773 C: 'a,
13774{
13775 hub: &'a Pubsub<C>,
13776 _request: TestIamPermissionsRequest,
13777 _resource: String,
13778 _delegate: Option<&'a mut dyn common::Delegate>,
13779 _additional_params: HashMap<String, String>,
13780 _scopes: BTreeSet<String>,
13781}
13782
13783impl<'a, C> common::CallBuilder for ProjectSubscriptionTestIamPermissionCall<'a, C> {}
13784
13785impl<'a, C> ProjectSubscriptionTestIamPermissionCall<'a, C>
13786where
13787 C: common::Connector,
13788{
13789 /// Perform the operation you have build so far.
13790 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
13791 use std::borrow::Cow;
13792 use std::io::{Read, Seek};
13793
13794 use common::{url::Params, ToParts};
13795 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13796
13797 let mut dd = common::DefaultDelegate;
13798 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13799 dlg.begin(common::MethodInfo {
13800 id: "pubsub.projects.subscriptions.testIamPermissions",
13801 http_method: hyper::Method::POST,
13802 });
13803
13804 for &field in ["alt", "resource"].iter() {
13805 if self._additional_params.contains_key(field) {
13806 dlg.finished(false);
13807 return Err(common::Error::FieldClash(field));
13808 }
13809 }
13810
13811 let mut params = Params::with_capacity(4 + self._additional_params.len());
13812 params.push("resource", self._resource);
13813
13814 params.extend(self._additional_params.iter());
13815
13816 params.push("alt", "json");
13817 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
13818 if self._scopes.is_empty() {
13819 self._scopes
13820 .insert(Scope::CloudPlatform.as_ref().to_string());
13821 }
13822
13823 #[allow(clippy::single_element_loop)]
13824 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
13825 url = params.uri_replacement(url, param_name, find_this, true);
13826 }
13827 {
13828 let to_remove = ["resource"];
13829 params.remove_params(&to_remove);
13830 }
13831
13832 let url = params.parse_with_url(&url);
13833
13834 let mut json_mime_type = mime::APPLICATION_JSON;
13835 let mut request_value_reader = {
13836 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13837 common::remove_json_null_values(&mut value);
13838 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13839 serde_json::to_writer(&mut dst, &value).unwrap();
13840 dst
13841 };
13842 let request_size = request_value_reader
13843 .seek(std::io::SeekFrom::End(0))
13844 .unwrap();
13845 request_value_reader
13846 .seek(std::io::SeekFrom::Start(0))
13847 .unwrap();
13848
13849 loop {
13850 let token = match self
13851 .hub
13852 .auth
13853 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13854 .await
13855 {
13856 Ok(token) => token,
13857 Err(e) => match dlg.token(e) {
13858 Ok(token) => token,
13859 Err(e) => {
13860 dlg.finished(false);
13861 return Err(common::Error::MissingToken(e));
13862 }
13863 },
13864 };
13865 request_value_reader
13866 .seek(std::io::SeekFrom::Start(0))
13867 .unwrap();
13868 let mut req_result = {
13869 let client = &self.hub.client;
13870 dlg.pre_request();
13871 let mut req_builder = hyper::Request::builder()
13872 .method(hyper::Method::POST)
13873 .uri(url.as_str())
13874 .header(USER_AGENT, self.hub._user_agent.clone());
13875
13876 if let Some(token) = token.as_ref() {
13877 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13878 }
13879
13880 let request = req_builder
13881 .header(CONTENT_TYPE, json_mime_type.to_string())
13882 .header(CONTENT_LENGTH, request_size as u64)
13883 .body(common::to_body(
13884 request_value_reader.get_ref().clone().into(),
13885 ));
13886
13887 client.request(request.unwrap()).await
13888 };
13889
13890 match req_result {
13891 Err(err) => {
13892 if let common::Retry::After(d) = dlg.http_error(&err) {
13893 sleep(d).await;
13894 continue;
13895 }
13896 dlg.finished(false);
13897 return Err(common::Error::HttpError(err));
13898 }
13899 Ok(res) => {
13900 let (mut parts, body) = res.into_parts();
13901 let mut body = common::Body::new(body);
13902 if !parts.status.is_success() {
13903 let bytes = common::to_bytes(body).await.unwrap_or_default();
13904 let error = serde_json::from_str(&common::to_string(&bytes));
13905 let response = common::to_response(parts, bytes.into());
13906
13907 if let common::Retry::After(d) =
13908 dlg.http_failure(&response, error.as_ref().ok())
13909 {
13910 sleep(d).await;
13911 continue;
13912 }
13913
13914 dlg.finished(false);
13915
13916 return Err(match error {
13917 Ok(value) => common::Error::BadRequest(value),
13918 _ => common::Error::Failure(response),
13919 });
13920 }
13921 let response = {
13922 let bytes = common::to_bytes(body).await.unwrap_or_default();
13923 let encoded = common::to_string(&bytes);
13924 match serde_json::from_str(&encoded) {
13925 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13926 Err(error) => {
13927 dlg.response_json_decode_error(&encoded, &error);
13928 return Err(common::Error::JsonDecodeError(
13929 encoded.to_string(),
13930 error,
13931 ));
13932 }
13933 }
13934 };
13935
13936 dlg.finished(true);
13937 return Ok(response);
13938 }
13939 }
13940 }
13941 }
13942
13943 ///
13944 /// Sets the *request* property to the given value.
13945 ///
13946 /// Even though the property as already been set when instantiating this call,
13947 /// we provide this method for API completeness.
13948 pub fn request(
13949 mut self,
13950 new_value: TestIamPermissionsRequest,
13951 ) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
13952 self._request = new_value;
13953 self
13954 }
13955 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
13956 ///
13957 /// Sets the *resource* path property to the given value.
13958 ///
13959 /// Even though the property as already been set when instantiating this call,
13960 /// we provide this method for API completeness.
13961 pub fn resource(mut self, new_value: &str) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
13962 self._resource = new_value.to_string();
13963 self
13964 }
13965 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13966 /// while executing the actual API request.
13967 ///
13968 /// ````text
13969 /// It should be used to handle progress information, and to implement a certain level of resilience.
13970 /// ````
13971 ///
13972 /// Sets the *delegate* property to the given value.
13973 pub fn delegate(
13974 mut self,
13975 new_value: &'a mut dyn common::Delegate,
13976 ) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
13977 self._delegate = Some(new_value);
13978 self
13979 }
13980
13981 /// Set any additional parameter of the query string used in the request.
13982 /// It should be used to set parameters which are not yet available through their own
13983 /// setters.
13984 ///
13985 /// Please note that this method must not be used to set any of the known parameters
13986 /// which have their own setter method. If done anyway, the request will fail.
13987 ///
13988 /// # Additional Parameters
13989 ///
13990 /// * *$.xgafv* (query-string) - V1 error format.
13991 /// * *access_token* (query-string) - OAuth access token.
13992 /// * *alt* (query-string) - Data format for response.
13993 /// * *callback* (query-string) - JSONP
13994 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13995 /// * *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.
13996 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13997 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13998 /// * *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.
13999 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14000 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14001 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionTestIamPermissionCall<'a, C>
14002 where
14003 T: AsRef<str>,
14004 {
14005 self._additional_params
14006 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14007 self
14008 }
14009
14010 /// Identifies the authorization scope for the method you are building.
14011 ///
14012 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14013 /// [`Scope::CloudPlatform`].
14014 ///
14015 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14016 /// tokens for more than one scope.
14017 ///
14018 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14019 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14020 /// sufficient, a read-write scope will do as well.
14021 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionTestIamPermissionCall<'a, C>
14022 where
14023 St: AsRef<str>,
14024 {
14025 self._scopes.insert(String::from(scope.as_ref()));
14026 self
14027 }
14028 /// Identifies the authorization scope(s) for the method you are building.
14029 ///
14030 /// See [`Self::add_scope()`] for details.
14031 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionTestIamPermissionCall<'a, C>
14032 where
14033 I: IntoIterator<Item = St>,
14034 St: AsRef<str>,
14035 {
14036 self._scopes
14037 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14038 self
14039 }
14040
14041 /// Removes all scopes, and no default scope will be used either.
14042 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14043 /// for details).
14044 pub fn clear_scopes(mut self) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
14045 self._scopes.clear();
14046 self
14047 }
14048}
14049
14050/// Lists the names of the snapshots on this topic. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
14051///
14052/// A builder for the *topics.snapshots.list* method supported by a *project* resource.
14053/// It is not used directly, but through a [`ProjectMethods`] instance.
14054///
14055/// # Example
14056///
14057/// Instantiate a resource method builder
14058///
14059/// ```test_harness,no_run
14060/// # extern crate hyper;
14061/// # extern crate hyper_rustls;
14062/// # extern crate google_pubsub1 as pubsub1;
14063/// # async fn dox() {
14064/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14065///
14066/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14067/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14068/// # .with_native_roots()
14069/// # .unwrap()
14070/// # .https_only()
14071/// # .enable_http2()
14072/// # .build();
14073///
14074/// # let executor = hyper_util::rt::TokioExecutor::new();
14075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14076/// # secret,
14077/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14078/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14079/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14080/// # ),
14081/// # ).build().await.unwrap();
14082///
14083/// # let client = hyper_util::client::legacy::Client::builder(
14084/// # hyper_util::rt::TokioExecutor::new()
14085/// # )
14086/// # .build(
14087/// # hyper_rustls::HttpsConnectorBuilder::new()
14088/// # .with_native_roots()
14089/// # .unwrap()
14090/// # .https_or_http()
14091/// # .enable_http2()
14092/// # .build()
14093/// # );
14094/// # let mut hub = Pubsub::new(client, auth);
14095/// // You can configure optional parameters by calling the respective setters at will, and
14096/// // execute the final call using `doit()`.
14097/// // Values shown here are possibly random and not representative !
14098/// let result = hub.projects().topics_snapshots_list("topic")
14099/// .page_token("dolor")
14100/// .page_size(-18)
14101/// .doit().await;
14102/// # }
14103/// ```
14104pub struct ProjectTopicSnapshotListCall<'a, C>
14105where
14106 C: 'a,
14107{
14108 hub: &'a Pubsub<C>,
14109 _topic: String,
14110 _page_token: Option<String>,
14111 _page_size: Option<i32>,
14112 _delegate: Option<&'a mut dyn common::Delegate>,
14113 _additional_params: HashMap<String, String>,
14114 _scopes: BTreeSet<String>,
14115}
14116
14117impl<'a, C> common::CallBuilder for ProjectTopicSnapshotListCall<'a, C> {}
14118
14119impl<'a, C> ProjectTopicSnapshotListCall<'a, C>
14120where
14121 C: common::Connector,
14122{
14123 /// Perform the operation you have build so far.
14124 pub async fn doit(mut self) -> common::Result<(common::Response, ListTopicSnapshotsResponse)> {
14125 use std::borrow::Cow;
14126 use std::io::{Read, Seek};
14127
14128 use common::{url::Params, ToParts};
14129 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14130
14131 let mut dd = common::DefaultDelegate;
14132 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14133 dlg.begin(common::MethodInfo {
14134 id: "pubsub.projects.topics.snapshots.list",
14135 http_method: hyper::Method::GET,
14136 });
14137
14138 for &field in ["alt", "topic", "pageToken", "pageSize"].iter() {
14139 if self._additional_params.contains_key(field) {
14140 dlg.finished(false);
14141 return Err(common::Error::FieldClash(field));
14142 }
14143 }
14144
14145 let mut params = Params::with_capacity(5 + self._additional_params.len());
14146 params.push("topic", self._topic);
14147 if let Some(value) = self._page_token.as_ref() {
14148 params.push("pageToken", value);
14149 }
14150 if let Some(value) = self._page_size.as_ref() {
14151 params.push("pageSize", value.to_string());
14152 }
14153
14154 params.extend(self._additional_params.iter());
14155
14156 params.push("alt", "json");
14157 let mut url = self.hub._base_url.clone() + "v1/{+topic}/snapshots";
14158 if self._scopes.is_empty() {
14159 self._scopes
14160 .insert(Scope::CloudPlatform.as_ref().to_string());
14161 }
14162
14163 #[allow(clippy::single_element_loop)]
14164 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
14165 url = params.uri_replacement(url, param_name, find_this, true);
14166 }
14167 {
14168 let to_remove = ["topic"];
14169 params.remove_params(&to_remove);
14170 }
14171
14172 let url = params.parse_with_url(&url);
14173
14174 loop {
14175 let token = match self
14176 .hub
14177 .auth
14178 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14179 .await
14180 {
14181 Ok(token) => token,
14182 Err(e) => match dlg.token(e) {
14183 Ok(token) => token,
14184 Err(e) => {
14185 dlg.finished(false);
14186 return Err(common::Error::MissingToken(e));
14187 }
14188 },
14189 };
14190 let mut req_result = {
14191 let client = &self.hub.client;
14192 dlg.pre_request();
14193 let mut req_builder = hyper::Request::builder()
14194 .method(hyper::Method::GET)
14195 .uri(url.as_str())
14196 .header(USER_AGENT, self.hub._user_agent.clone());
14197
14198 if let Some(token) = token.as_ref() {
14199 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14200 }
14201
14202 let request = req_builder
14203 .header(CONTENT_LENGTH, 0_u64)
14204 .body(common::to_body::<String>(None));
14205
14206 client.request(request.unwrap()).await
14207 };
14208
14209 match req_result {
14210 Err(err) => {
14211 if let common::Retry::After(d) = dlg.http_error(&err) {
14212 sleep(d).await;
14213 continue;
14214 }
14215 dlg.finished(false);
14216 return Err(common::Error::HttpError(err));
14217 }
14218 Ok(res) => {
14219 let (mut parts, body) = res.into_parts();
14220 let mut body = common::Body::new(body);
14221 if !parts.status.is_success() {
14222 let bytes = common::to_bytes(body).await.unwrap_or_default();
14223 let error = serde_json::from_str(&common::to_string(&bytes));
14224 let response = common::to_response(parts, bytes.into());
14225
14226 if let common::Retry::After(d) =
14227 dlg.http_failure(&response, error.as_ref().ok())
14228 {
14229 sleep(d).await;
14230 continue;
14231 }
14232
14233 dlg.finished(false);
14234
14235 return Err(match error {
14236 Ok(value) => common::Error::BadRequest(value),
14237 _ => common::Error::Failure(response),
14238 });
14239 }
14240 let response = {
14241 let bytes = common::to_bytes(body).await.unwrap_or_default();
14242 let encoded = common::to_string(&bytes);
14243 match serde_json::from_str(&encoded) {
14244 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14245 Err(error) => {
14246 dlg.response_json_decode_error(&encoded, &error);
14247 return Err(common::Error::JsonDecodeError(
14248 encoded.to_string(),
14249 error,
14250 ));
14251 }
14252 }
14253 };
14254
14255 dlg.finished(true);
14256 return Ok(response);
14257 }
14258 }
14259 }
14260 }
14261
14262 /// Required. The name of the topic that snapshots are attached to. Format is `projects/{project}/topics/{topic}`.
14263 ///
14264 /// Sets the *topic* path property to the given value.
14265 ///
14266 /// Even though the property as already been set when instantiating this call,
14267 /// we provide this method for API completeness.
14268 pub fn topic(mut self, new_value: &str) -> ProjectTopicSnapshotListCall<'a, C> {
14269 self._topic = new_value.to_string();
14270 self
14271 }
14272 /// Optional. The value returned by the last `ListTopicSnapshotsResponse`; indicates that this is a continuation of a prior `ListTopicSnapshots` call, and that the system should return the next page of data.
14273 ///
14274 /// Sets the *page token* query property to the given value.
14275 pub fn page_token(mut self, new_value: &str) -> ProjectTopicSnapshotListCall<'a, C> {
14276 self._page_token = Some(new_value.to_string());
14277 self
14278 }
14279 /// Optional. Maximum number of snapshot names to return.
14280 ///
14281 /// Sets the *page size* query property to the given value.
14282 pub fn page_size(mut self, new_value: i32) -> ProjectTopicSnapshotListCall<'a, C> {
14283 self._page_size = Some(new_value);
14284 self
14285 }
14286 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14287 /// while executing the actual API request.
14288 ///
14289 /// ````text
14290 /// It should be used to handle progress information, and to implement a certain level of resilience.
14291 /// ````
14292 ///
14293 /// Sets the *delegate* property to the given value.
14294 pub fn delegate(
14295 mut self,
14296 new_value: &'a mut dyn common::Delegate,
14297 ) -> ProjectTopicSnapshotListCall<'a, C> {
14298 self._delegate = Some(new_value);
14299 self
14300 }
14301
14302 /// Set any additional parameter of the query string used in the request.
14303 /// It should be used to set parameters which are not yet available through their own
14304 /// setters.
14305 ///
14306 /// Please note that this method must not be used to set any of the known parameters
14307 /// which have their own setter method. If done anyway, the request will fail.
14308 ///
14309 /// # Additional Parameters
14310 ///
14311 /// * *$.xgafv* (query-string) - V1 error format.
14312 /// * *access_token* (query-string) - OAuth access token.
14313 /// * *alt* (query-string) - Data format for response.
14314 /// * *callback* (query-string) - JSONP
14315 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14316 /// * *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.
14317 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14318 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14319 /// * *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.
14320 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14321 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14322 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicSnapshotListCall<'a, C>
14323 where
14324 T: AsRef<str>,
14325 {
14326 self._additional_params
14327 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14328 self
14329 }
14330
14331 /// Identifies the authorization scope for the method you are building.
14332 ///
14333 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14334 /// [`Scope::CloudPlatform`].
14335 ///
14336 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14337 /// tokens for more than one scope.
14338 ///
14339 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14340 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14341 /// sufficient, a read-write scope will do as well.
14342 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicSnapshotListCall<'a, C>
14343 where
14344 St: AsRef<str>,
14345 {
14346 self._scopes.insert(String::from(scope.as_ref()));
14347 self
14348 }
14349 /// Identifies the authorization scope(s) for the method you are building.
14350 ///
14351 /// See [`Self::add_scope()`] for details.
14352 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicSnapshotListCall<'a, C>
14353 where
14354 I: IntoIterator<Item = St>,
14355 St: AsRef<str>,
14356 {
14357 self._scopes
14358 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14359 self
14360 }
14361
14362 /// Removes all scopes, and no default scope will be used either.
14363 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14364 /// for details).
14365 pub fn clear_scopes(mut self) -> ProjectTopicSnapshotListCall<'a, C> {
14366 self._scopes.clear();
14367 self
14368 }
14369}
14370
14371/// Lists the names of the attached subscriptions on this topic.
14372///
14373/// A builder for the *topics.subscriptions.list* method supported by a *project* resource.
14374/// It is not used directly, but through a [`ProjectMethods`] instance.
14375///
14376/// # Example
14377///
14378/// Instantiate a resource method builder
14379///
14380/// ```test_harness,no_run
14381/// # extern crate hyper;
14382/// # extern crate hyper_rustls;
14383/// # extern crate google_pubsub1 as pubsub1;
14384/// # async fn dox() {
14385/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14386///
14387/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14388/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14389/// # .with_native_roots()
14390/// # .unwrap()
14391/// # .https_only()
14392/// # .enable_http2()
14393/// # .build();
14394///
14395/// # let executor = hyper_util::rt::TokioExecutor::new();
14396/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14397/// # secret,
14398/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14399/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14400/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14401/// # ),
14402/// # ).build().await.unwrap();
14403///
14404/// # let client = hyper_util::client::legacy::Client::builder(
14405/// # hyper_util::rt::TokioExecutor::new()
14406/// # )
14407/// # .build(
14408/// # hyper_rustls::HttpsConnectorBuilder::new()
14409/// # .with_native_roots()
14410/// # .unwrap()
14411/// # .https_or_http()
14412/// # .enable_http2()
14413/// # .build()
14414/// # );
14415/// # let mut hub = Pubsub::new(client, auth);
14416/// // You can configure optional parameters by calling the respective setters at will, and
14417/// // execute the final call using `doit()`.
14418/// // Values shown here are possibly random and not representative !
14419/// let result = hub.projects().topics_subscriptions_list("topic")
14420/// .page_token("sadipscing")
14421/// .page_size(-15)
14422/// .doit().await;
14423/// # }
14424/// ```
14425pub struct ProjectTopicSubscriptionListCall<'a, C>
14426where
14427 C: 'a,
14428{
14429 hub: &'a Pubsub<C>,
14430 _topic: String,
14431 _page_token: Option<String>,
14432 _page_size: Option<i32>,
14433 _delegate: Option<&'a mut dyn common::Delegate>,
14434 _additional_params: HashMap<String, String>,
14435 _scopes: BTreeSet<String>,
14436}
14437
14438impl<'a, C> common::CallBuilder for ProjectTopicSubscriptionListCall<'a, C> {}
14439
14440impl<'a, C> ProjectTopicSubscriptionListCall<'a, C>
14441where
14442 C: common::Connector,
14443{
14444 /// Perform the operation you have build so far.
14445 pub async fn doit(
14446 mut self,
14447 ) -> common::Result<(common::Response, ListTopicSubscriptionsResponse)> {
14448 use std::borrow::Cow;
14449 use std::io::{Read, Seek};
14450
14451 use common::{url::Params, ToParts};
14452 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14453
14454 let mut dd = common::DefaultDelegate;
14455 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14456 dlg.begin(common::MethodInfo {
14457 id: "pubsub.projects.topics.subscriptions.list",
14458 http_method: hyper::Method::GET,
14459 });
14460
14461 for &field in ["alt", "topic", "pageToken", "pageSize"].iter() {
14462 if self._additional_params.contains_key(field) {
14463 dlg.finished(false);
14464 return Err(common::Error::FieldClash(field));
14465 }
14466 }
14467
14468 let mut params = Params::with_capacity(5 + self._additional_params.len());
14469 params.push("topic", self._topic);
14470 if let Some(value) = self._page_token.as_ref() {
14471 params.push("pageToken", value);
14472 }
14473 if let Some(value) = self._page_size.as_ref() {
14474 params.push("pageSize", value.to_string());
14475 }
14476
14477 params.extend(self._additional_params.iter());
14478
14479 params.push("alt", "json");
14480 let mut url = self.hub._base_url.clone() + "v1/{+topic}/subscriptions";
14481 if self._scopes.is_empty() {
14482 self._scopes
14483 .insert(Scope::CloudPlatform.as_ref().to_string());
14484 }
14485
14486 #[allow(clippy::single_element_loop)]
14487 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
14488 url = params.uri_replacement(url, param_name, find_this, true);
14489 }
14490 {
14491 let to_remove = ["topic"];
14492 params.remove_params(&to_remove);
14493 }
14494
14495 let url = params.parse_with_url(&url);
14496
14497 loop {
14498 let token = match self
14499 .hub
14500 .auth
14501 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14502 .await
14503 {
14504 Ok(token) => token,
14505 Err(e) => match dlg.token(e) {
14506 Ok(token) => token,
14507 Err(e) => {
14508 dlg.finished(false);
14509 return Err(common::Error::MissingToken(e));
14510 }
14511 },
14512 };
14513 let mut req_result = {
14514 let client = &self.hub.client;
14515 dlg.pre_request();
14516 let mut req_builder = hyper::Request::builder()
14517 .method(hyper::Method::GET)
14518 .uri(url.as_str())
14519 .header(USER_AGENT, self.hub._user_agent.clone());
14520
14521 if let Some(token) = token.as_ref() {
14522 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14523 }
14524
14525 let request = req_builder
14526 .header(CONTENT_LENGTH, 0_u64)
14527 .body(common::to_body::<String>(None));
14528
14529 client.request(request.unwrap()).await
14530 };
14531
14532 match req_result {
14533 Err(err) => {
14534 if let common::Retry::After(d) = dlg.http_error(&err) {
14535 sleep(d).await;
14536 continue;
14537 }
14538 dlg.finished(false);
14539 return Err(common::Error::HttpError(err));
14540 }
14541 Ok(res) => {
14542 let (mut parts, body) = res.into_parts();
14543 let mut body = common::Body::new(body);
14544 if !parts.status.is_success() {
14545 let bytes = common::to_bytes(body).await.unwrap_or_default();
14546 let error = serde_json::from_str(&common::to_string(&bytes));
14547 let response = common::to_response(parts, bytes.into());
14548
14549 if let common::Retry::After(d) =
14550 dlg.http_failure(&response, error.as_ref().ok())
14551 {
14552 sleep(d).await;
14553 continue;
14554 }
14555
14556 dlg.finished(false);
14557
14558 return Err(match error {
14559 Ok(value) => common::Error::BadRequest(value),
14560 _ => common::Error::Failure(response),
14561 });
14562 }
14563 let response = {
14564 let bytes = common::to_bytes(body).await.unwrap_or_default();
14565 let encoded = common::to_string(&bytes);
14566 match serde_json::from_str(&encoded) {
14567 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14568 Err(error) => {
14569 dlg.response_json_decode_error(&encoded, &error);
14570 return Err(common::Error::JsonDecodeError(
14571 encoded.to_string(),
14572 error,
14573 ));
14574 }
14575 }
14576 };
14577
14578 dlg.finished(true);
14579 return Ok(response);
14580 }
14581 }
14582 }
14583 }
14584
14585 /// Required. The name of the topic that subscriptions are attached to. Format is `projects/{project}/topics/{topic}`.
14586 ///
14587 /// Sets the *topic* path property to the given value.
14588 ///
14589 /// Even though the property as already been set when instantiating this call,
14590 /// we provide this method for API completeness.
14591 pub fn topic(mut self, new_value: &str) -> ProjectTopicSubscriptionListCall<'a, C> {
14592 self._topic = new_value.to_string();
14593 self
14594 }
14595 /// Optional. The value returned by the last `ListTopicSubscriptionsResponse`; indicates that this is a continuation of a prior `ListTopicSubscriptions` call, and that the system should return the next page of data.
14596 ///
14597 /// Sets the *page token* query property to the given value.
14598 pub fn page_token(mut self, new_value: &str) -> ProjectTopicSubscriptionListCall<'a, C> {
14599 self._page_token = Some(new_value.to_string());
14600 self
14601 }
14602 /// Optional. Maximum number of subscription names to return.
14603 ///
14604 /// Sets the *page size* query property to the given value.
14605 pub fn page_size(mut self, new_value: i32) -> ProjectTopicSubscriptionListCall<'a, C> {
14606 self._page_size = Some(new_value);
14607 self
14608 }
14609 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14610 /// while executing the actual API request.
14611 ///
14612 /// ````text
14613 /// It should be used to handle progress information, and to implement a certain level of resilience.
14614 /// ````
14615 ///
14616 /// Sets the *delegate* property to the given value.
14617 pub fn delegate(
14618 mut self,
14619 new_value: &'a mut dyn common::Delegate,
14620 ) -> ProjectTopicSubscriptionListCall<'a, C> {
14621 self._delegate = Some(new_value);
14622 self
14623 }
14624
14625 /// Set any additional parameter of the query string used in the request.
14626 /// It should be used to set parameters which are not yet available through their own
14627 /// setters.
14628 ///
14629 /// Please note that this method must not be used to set any of the known parameters
14630 /// which have their own setter method. If done anyway, the request will fail.
14631 ///
14632 /// # Additional Parameters
14633 ///
14634 /// * *$.xgafv* (query-string) - V1 error format.
14635 /// * *access_token* (query-string) - OAuth access token.
14636 /// * *alt* (query-string) - Data format for response.
14637 /// * *callback* (query-string) - JSONP
14638 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14639 /// * *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.
14640 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14641 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14642 /// * *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.
14643 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14644 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14645 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicSubscriptionListCall<'a, C>
14646 where
14647 T: AsRef<str>,
14648 {
14649 self._additional_params
14650 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14651 self
14652 }
14653
14654 /// Identifies the authorization scope for the method you are building.
14655 ///
14656 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14657 /// [`Scope::CloudPlatform`].
14658 ///
14659 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14660 /// tokens for more than one scope.
14661 ///
14662 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14663 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14664 /// sufficient, a read-write scope will do as well.
14665 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicSubscriptionListCall<'a, C>
14666 where
14667 St: AsRef<str>,
14668 {
14669 self._scopes.insert(String::from(scope.as_ref()));
14670 self
14671 }
14672 /// Identifies the authorization scope(s) for the method you are building.
14673 ///
14674 /// See [`Self::add_scope()`] for details.
14675 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicSubscriptionListCall<'a, C>
14676 where
14677 I: IntoIterator<Item = St>,
14678 St: AsRef<str>,
14679 {
14680 self._scopes
14681 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14682 self
14683 }
14684
14685 /// Removes all scopes, and no default scope will be used either.
14686 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14687 /// for details).
14688 pub fn clear_scopes(mut self) -> ProjectTopicSubscriptionListCall<'a, C> {
14689 self._scopes.clear();
14690 self
14691 }
14692}
14693
14694/// Creates the given topic with the given name. See the [resource name rules] (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
14695///
14696/// A builder for the *topics.create* method supported by a *project* resource.
14697/// It is not used directly, but through a [`ProjectMethods`] instance.
14698///
14699/// # Example
14700///
14701/// Instantiate a resource method builder
14702///
14703/// ```test_harness,no_run
14704/// # extern crate hyper;
14705/// # extern crate hyper_rustls;
14706/// # extern crate google_pubsub1 as pubsub1;
14707/// use pubsub1::api::Topic;
14708/// # async fn dox() {
14709/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14710///
14711/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14712/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14713/// # .with_native_roots()
14714/// # .unwrap()
14715/// # .https_only()
14716/// # .enable_http2()
14717/// # .build();
14718///
14719/// # let executor = hyper_util::rt::TokioExecutor::new();
14720/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14721/// # secret,
14722/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14723/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14724/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14725/// # ),
14726/// # ).build().await.unwrap();
14727///
14728/// # let client = hyper_util::client::legacy::Client::builder(
14729/// # hyper_util::rt::TokioExecutor::new()
14730/// # )
14731/// # .build(
14732/// # hyper_rustls::HttpsConnectorBuilder::new()
14733/// # .with_native_roots()
14734/// # .unwrap()
14735/// # .https_or_http()
14736/// # .enable_http2()
14737/// # .build()
14738/// # );
14739/// # let mut hub = Pubsub::new(client, auth);
14740/// // As the method needs a request, you would usually fill it with the desired information
14741/// // into the respective structure. Some of the parts shown here might not be applicable !
14742/// // Values shown here are possibly random and not representative !
14743/// let mut req = Topic::default();
14744///
14745/// // You can configure optional parameters by calling the respective setters at will, and
14746/// // execute the final call using `doit()`.
14747/// // Values shown here are possibly random and not representative !
14748/// let result = hub.projects().topics_create(req, "name")
14749/// .doit().await;
14750/// # }
14751/// ```
14752pub struct ProjectTopicCreateCall<'a, C>
14753where
14754 C: 'a,
14755{
14756 hub: &'a Pubsub<C>,
14757 _request: Topic,
14758 _name: String,
14759 _delegate: Option<&'a mut dyn common::Delegate>,
14760 _additional_params: HashMap<String, String>,
14761 _scopes: BTreeSet<String>,
14762}
14763
14764impl<'a, C> common::CallBuilder for ProjectTopicCreateCall<'a, C> {}
14765
14766impl<'a, C> ProjectTopicCreateCall<'a, C>
14767where
14768 C: common::Connector,
14769{
14770 /// Perform the operation you have build so far.
14771 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
14772 use std::borrow::Cow;
14773 use std::io::{Read, Seek};
14774
14775 use common::{url::Params, ToParts};
14776 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14777
14778 let mut dd = common::DefaultDelegate;
14779 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14780 dlg.begin(common::MethodInfo {
14781 id: "pubsub.projects.topics.create",
14782 http_method: hyper::Method::PUT,
14783 });
14784
14785 for &field in ["alt", "name"].iter() {
14786 if self._additional_params.contains_key(field) {
14787 dlg.finished(false);
14788 return Err(common::Error::FieldClash(field));
14789 }
14790 }
14791
14792 let mut params = Params::with_capacity(4 + self._additional_params.len());
14793 params.push("name", self._name);
14794
14795 params.extend(self._additional_params.iter());
14796
14797 params.push("alt", "json");
14798 let mut url = self.hub._base_url.clone() + "v1/{+name}";
14799 if self._scopes.is_empty() {
14800 self._scopes
14801 .insert(Scope::CloudPlatform.as_ref().to_string());
14802 }
14803
14804 #[allow(clippy::single_element_loop)]
14805 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14806 url = params.uri_replacement(url, param_name, find_this, true);
14807 }
14808 {
14809 let to_remove = ["name"];
14810 params.remove_params(&to_remove);
14811 }
14812
14813 let url = params.parse_with_url(&url);
14814
14815 let mut json_mime_type = mime::APPLICATION_JSON;
14816 let mut request_value_reader = {
14817 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14818 common::remove_json_null_values(&mut value);
14819 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14820 serde_json::to_writer(&mut dst, &value).unwrap();
14821 dst
14822 };
14823 let request_size = request_value_reader
14824 .seek(std::io::SeekFrom::End(0))
14825 .unwrap();
14826 request_value_reader
14827 .seek(std::io::SeekFrom::Start(0))
14828 .unwrap();
14829
14830 loop {
14831 let token = match self
14832 .hub
14833 .auth
14834 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14835 .await
14836 {
14837 Ok(token) => token,
14838 Err(e) => match dlg.token(e) {
14839 Ok(token) => token,
14840 Err(e) => {
14841 dlg.finished(false);
14842 return Err(common::Error::MissingToken(e));
14843 }
14844 },
14845 };
14846 request_value_reader
14847 .seek(std::io::SeekFrom::Start(0))
14848 .unwrap();
14849 let mut req_result = {
14850 let client = &self.hub.client;
14851 dlg.pre_request();
14852 let mut req_builder = hyper::Request::builder()
14853 .method(hyper::Method::PUT)
14854 .uri(url.as_str())
14855 .header(USER_AGENT, self.hub._user_agent.clone());
14856
14857 if let Some(token) = token.as_ref() {
14858 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14859 }
14860
14861 let request = req_builder
14862 .header(CONTENT_TYPE, json_mime_type.to_string())
14863 .header(CONTENT_LENGTH, request_size as u64)
14864 .body(common::to_body(
14865 request_value_reader.get_ref().clone().into(),
14866 ));
14867
14868 client.request(request.unwrap()).await
14869 };
14870
14871 match req_result {
14872 Err(err) => {
14873 if let common::Retry::After(d) = dlg.http_error(&err) {
14874 sleep(d).await;
14875 continue;
14876 }
14877 dlg.finished(false);
14878 return Err(common::Error::HttpError(err));
14879 }
14880 Ok(res) => {
14881 let (mut parts, body) = res.into_parts();
14882 let mut body = common::Body::new(body);
14883 if !parts.status.is_success() {
14884 let bytes = common::to_bytes(body).await.unwrap_or_default();
14885 let error = serde_json::from_str(&common::to_string(&bytes));
14886 let response = common::to_response(parts, bytes.into());
14887
14888 if let common::Retry::After(d) =
14889 dlg.http_failure(&response, error.as_ref().ok())
14890 {
14891 sleep(d).await;
14892 continue;
14893 }
14894
14895 dlg.finished(false);
14896
14897 return Err(match error {
14898 Ok(value) => common::Error::BadRequest(value),
14899 _ => common::Error::Failure(response),
14900 });
14901 }
14902 let response = {
14903 let bytes = common::to_bytes(body).await.unwrap_or_default();
14904 let encoded = common::to_string(&bytes);
14905 match serde_json::from_str(&encoded) {
14906 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14907 Err(error) => {
14908 dlg.response_json_decode_error(&encoded, &error);
14909 return Err(common::Error::JsonDecodeError(
14910 encoded.to_string(),
14911 error,
14912 ));
14913 }
14914 }
14915 };
14916
14917 dlg.finished(true);
14918 return Ok(response);
14919 }
14920 }
14921 }
14922 }
14923
14924 ///
14925 /// Sets the *request* property to the given value.
14926 ///
14927 /// Even though the property as already been set when instantiating this call,
14928 /// we provide this method for API completeness.
14929 pub fn request(mut self, new_value: Topic) -> ProjectTopicCreateCall<'a, C> {
14930 self._request = new_value;
14931 self
14932 }
14933 /// Required. Identifier. The name of the topic. It must have the format `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
14934 ///
14935 /// Sets the *name* path property to the given value.
14936 ///
14937 /// Even though the property as already been set when instantiating this call,
14938 /// we provide this method for API completeness.
14939 pub fn name(mut self, new_value: &str) -> ProjectTopicCreateCall<'a, C> {
14940 self._name = new_value.to_string();
14941 self
14942 }
14943 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14944 /// while executing the actual API request.
14945 ///
14946 /// ````text
14947 /// It should be used to handle progress information, and to implement a certain level of resilience.
14948 /// ````
14949 ///
14950 /// Sets the *delegate* property to the given value.
14951 pub fn delegate(
14952 mut self,
14953 new_value: &'a mut dyn common::Delegate,
14954 ) -> ProjectTopicCreateCall<'a, C> {
14955 self._delegate = Some(new_value);
14956 self
14957 }
14958
14959 /// Set any additional parameter of the query string used in the request.
14960 /// It should be used to set parameters which are not yet available through their own
14961 /// setters.
14962 ///
14963 /// Please note that this method must not be used to set any of the known parameters
14964 /// which have their own setter method. If done anyway, the request will fail.
14965 ///
14966 /// # Additional Parameters
14967 ///
14968 /// * *$.xgafv* (query-string) - V1 error format.
14969 /// * *access_token* (query-string) - OAuth access token.
14970 /// * *alt* (query-string) - Data format for response.
14971 /// * *callback* (query-string) - JSONP
14972 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14973 /// * *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.
14974 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14975 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14976 /// * *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.
14977 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14978 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14979 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicCreateCall<'a, C>
14980 where
14981 T: AsRef<str>,
14982 {
14983 self._additional_params
14984 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14985 self
14986 }
14987
14988 /// Identifies the authorization scope for the method you are building.
14989 ///
14990 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14991 /// [`Scope::CloudPlatform`].
14992 ///
14993 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14994 /// tokens for more than one scope.
14995 ///
14996 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14997 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14998 /// sufficient, a read-write scope will do as well.
14999 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicCreateCall<'a, C>
15000 where
15001 St: AsRef<str>,
15002 {
15003 self._scopes.insert(String::from(scope.as_ref()));
15004 self
15005 }
15006 /// Identifies the authorization scope(s) for the method you are building.
15007 ///
15008 /// See [`Self::add_scope()`] for details.
15009 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicCreateCall<'a, C>
15010 where
15011 I: IntoIterator<Item = St>,
15012 St: AsRef<str>,
15013 {
15014 self._scopes
15015 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15016 self
15017 }
15018
15019 /// Removes all scopes, and no default scope will be used either.
15020 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15021 /// for details).
15022 pub fn clear_scopes(mut self) -> ProjectTopicCreateCall<'a, C> {
15023 self._scopes.clear();
15024 self
15025 }
15026}
15027
15028/// Deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.
15029///
15030/// A builder for the *topics.delete* method supported by a *project* resource.
15031/// It is not used directly, but through a [`ProjectMethods`] instance.
15032///
15033/// # Example
15034///
15035/// Instantiate a resource method builder
15036///
15037/// ```test_harness,no_run
15038/// # extern crate hyper;
15039/// # extern crate hyper_rustls;
15040/// # extern crate google_pubsub1 as pubsub1;
15041/// # async fn dox() {
15042/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15043///
15044/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15045/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15046/// # .with_native_roots()
15047/// # .unwrap()
15048/// # .https_only()
15049/// # .enable_http2()
15050/// # .build();
15051///
15052/// # let executor = hyper_util::rt::TokioExecutor::new();
15053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15054/// # secret,
15055/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15056/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15057/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15058/// # ),
15059/// # ).build().await.unwrap();
15060///
15061/// # let client = hyper_util::client::legacy::Client::builder(
15062/// # hyper_util::rt::TokioExecutor::new()
15063/// # )
15064/// # .build(
15065/// # hyper_rustls::HttpsConnectorBuilder::new()
15066/// # .with_native_roots()
15067/// # .unwrap()
15068/// # .https_or_http()
15069/// # .enable_http2()
15070/// # .build()
15071/// # );
15072/// # let mut hub = Pubsub::new(client, auth);
15073/// // You can configure optional parameters by calling the respective setters at will, and
15074/// // execute the final call using `doit()`.
15075/// // Values shown here are possibly random and not representative !
15076/// let result = hub.projects().topics_delete("topic")
15077/// .doit().await;
15078/// # }
15079/// ```
15080pub struct ProjectTopicDeleteCall<'a, C>
15081where
15082 C: 'a,
15083{
15084 hub: &'a Pubsub<C>,
15085 _topic: String,
15086 _delegate: Option<&'a mut dyn common::Delegate>,
15087 _additional_params: HashMap<String, String>,
15088 _scopes: BTreeSet<String>,
15089}
15090
15091impl<'a, C> common::CallBuilder for ProjectTopicDeleteCall<'a, C> {}
15092
15093impl<'a, C> ProjectTopicDeleteCall<'a, C>
15094where
15095 C: common::Connector,
15096{
15097 /// Perform the operation you have build so far.
15098 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
15099 use std::borrow::Cow;
15100 use std::io::{Read, Seek};
15101
15102 use common::{url::Params, ToParts};
15103 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15104
15105 let mut dd = common::DefaultDelegate;
15106 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15107 dlg.begin(common::MethodInfo {
15108 id: "pubsub.projects.topics.delete",
15109 http_method: hyper::Method::DELETE,
15110 });
15111
15112 for &field in ["alt", "topic"].iter() {
15113 if self._additional_params.contains_key(field) {
15114 dlg.finished(false);
15115 return Err(common::Error::FieldClash(field));
15116 }
15117 }
15118
15119 let mut params = Params::with_capacity(3 + self._additional_params.len());
15120 params.push("topic", self._topic);
15121
15122 params.extend(self._additional_params.iter());
15123
15124 params.push("alt", "json");
15125 let mut url = self.hub._base_url.clone() + "v1/{+topic}";
15126 if self._scopes.is_empty() {
15127 self._scopes
15128 .insert(Scope::CloudPlatform.as_ref().to_string());
15129 }
15130
15131 #[allow(clippy::single_element_loop)]
15132 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
15133 url = params.uri_replacement(url, param_name, find_this, true);
15134 }
15135 {
15136 let to_remove = ["topic"];
15137 params.remove_params(&to_remove);
15138 }
15139
15140 let url = params.parse_with_url(&url);
15141
15142 loop {
15143 let token = match self
15144 .hub
15145 .auth
15146 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15147 .await
15148 {
15149 Ok(token) => token,
15150 Err(e) => match dlg.token(e) {
15151 Ok(token) => token,
15152 Err(e) => {
15153 dlg.finished(false);
15154 return Err(common::Error::MissingToken(e));
15155 }
15156 },
15157 };
15158 let mut req_result = {
15159 let client = &self.hub.client;
15160 dlg.pre_request();
15161 let mut req_builder = hyper::Request::builder()
15162 .method(hyper::Method::DELETE)
15163 .uri(url.as_str())
15164 .header(USER_AGENT, self.hub._user_agent.clone());
15165
15166 if let Some(token) = token.as_ref() {
15167 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15168 }
15169
15170 let request = req_builder
15171 .header(CONTENT_LENGTH, 0_u64)
15172 .body(common::to_body::<String>(None));
15173
15174 client.request(request.unwrap()).await
15175 };
15176
15177 match req_result {
15178 Err(err) => {
15179 if let common::Retry::After(d) = dlg.http_error(&err) {
15180 sleep(d).await;
15181 continue;
15182 }
15183 dlg.finished(false);
15184 return Err(common::Error::HttpError(err));
15185 }
15186 Ok(res) => {
15187 let (mut parts, body) = res.into_parts();
15188 let mut body = common::Body::new(body);
15189 if !parts.status.is_success() {
15190 let bytes = common::to_bytes(body).await.unwrap_or_default();
15191 let error = serde_json::from_str(&common::to_string(&bytes));
15192 let response = common::to_response(parts, bytes.into());
15193
15194 if let common::Retry::After(d) =
15195 dlg.http_failure(&response, error.as_ref().ok())
15196 {
15197 sleep(d).await;
15198 continue;
15199 }
15200
15201 dlg.finished(false);
15202
15203 return Err(match error {
15204 Ok(value) => common::Error::BadRequest(value),
15205 _ => common::Error::Failure(response),
15206 });
15207 }
15208 let response = {
15209 let bytes = common::to_bytes(body).await.unwrap_or_default();
15210 let encoded = common::to_string(&bytes);
15211 match serde_json::from_str(&encoded) {
15212 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15213 Err(error) => {
15214 dlg.response_json_decode_error(&encoded, &error);
15215 return Err(common::Error::JsonDecodeError(
15216 encoded.to_string(),
15217 error,
15218 ));
15219 }
15220 }
15221 };
15222
15223 dlg.finished(true);
15224 return Ok(response);
15225 }
15226 }
15227 }
15228 }
15229
15230 /// Required. Identifier. Name of the topic to delete. Format is `projects/{project}/topics/{topic}`.
15231 ///
15232 /// Sets the *topic* path property to the given value.
15233 ///
15234 /// Even though the property as already been set when instantiating this call,
15235 /// we provide this method for API completeness.
15236 pub fn topic(mut self, new_value: &str) -> ProjectTopicDeleteCall<'a, C> {
15237 self._topic = new_value.to_string();
15238 self
15239 }
15240 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15241 /// while executing the actual API request.
15242 ///
15243 /// ````text
15244 /// It should be used to handle progress information, and to implement a certain level of resilience.
15245 /// ````
15246 ///
15247 /// Sets the *delegate* property to the given value.
15248 pub fn delegate(
15249 mut self,
15250 new_value: &'a mut dyn common::Delegate,
15251 ) -> ProjectTopicDeleteCall<'a, C> {
15252 self._delegate = Some(new_value);
15253 self
15254 }
15255
15256 /// Set any additional parameter of the query string used in the request.
15257 /// It should be used to set parameters which are not yet available through their own
15258 /// setters.
15259 ///
15260 /// Please note that this method must not be used to set any of the known parameters
15261 /// which have their own setter method. If done anyway, the request will fail.
15262 ///
15263 /// # Additional Parameters
15264 ///
15265 /// * *$.xgafv* (query-string) - V1 error format.
15266 /// * *access_token* (query-string) - OAuth access token.
15267 /// * *alt* (query-string) - Data format for response.
15268 /// * *callback* (query-string) - JSONP
15269 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15270 /// * *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.
15271 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15272 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15273 /// * *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.
15274 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15275 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15276 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicDeleteCall<'a, C>
15277 where
15278 T: AsRef<str>,
15279 {
15280 self._additional_params
15281 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15282 self
15283 }
15284
15285 /// Identifies the authorization scope for the method you are building.
15286 ///
15287 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15288 /// [`Scope::CloudPlatform`].
15289 ///
15290 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15291 /// tokens for more than one scope.
15292 ///
15293 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15294 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15295 /// sufficient, a read-write scope will do as well.
15296 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicDeleteCall<'a, C>
15297 where
15298 St: AsRef<str>,
15299 {
15300 self._scopes.insert(String::from(scope.as_ref()));
15301 self
15302 }
15303 /// Identifies the authorization scope(s) for the method you are building.
15304 ///
15305 /// See [`Self::add_scope()`] for details.
15306 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicDeleteCall<'a, C>
15307 where
15308 I: IntoIterator<Item = St>,
15309 St: AsRef<str>,
15310 {
15311 self._scopes
15312 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15313 self
15314 }
15315
15316 /// Removes all scopes, and no default scope will be used either.
15317 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15318 /// for details).
15319 pub fn clear_scopes(mut self) -> ProjectTopicDeleteCall<'a, C> {
15320 self._scopes.clear();
15321 self
15322 }
15323}
15324
15325/// Gets the configuration of a topic.
15326///
15327/// A builder for the *topics.get* method supported by a *project* resource.
15328/// It is not used directly, but through a [`ProjectMethods`] instance.
15329///
15330/// # Example
15331///
15332/// Instantiate a resource method builder
15333///
15334/// ```test_harness,no_run
15335/// # extern crate hyper;
15336/// # extern crate hyper_rustls;
15337/// # extern crate google_pubsub1 as pubsub1;
15338/// # async fn dox() {
15339/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15340///
15341/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15342/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15343/// # .with_native_roots()
15344/// # .unwrap()
15345/// # .https_only()
15346/// # .enable_http2()
15347/// # .build();
15348///
15349/// # let executor = hyper_util::rt::TokioExecutor::new();
15350/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15351/// # secret,
15352/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15353/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15354/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15355/// # ),
15356/// # ).build().await.unwrap();
15357///
15358/// # let client = hyper_util::client::legacy::Client::builder(
15359/// # hyper_util::rt::TokioExecutor::new()
15360/// # )
15361/// # .build(
15362/// # hyper_rustls::HttpsConnectorBuilder::new()
15363/// # .with_native_roots()
15364/// # .unwrap()
15365/// # .https_or_http()
15366/// # .enable_http2()
15367/// # .build()
15368/// # );
15369/// # let mut hub = Pubsub::new(client, auth);
15370/// // You can configure optional parameters by calling the respective setters at will, and
15371/// // execute the final call using `doit()`.
15372/// // Values shown here are possibly random and not representative !
15373/// let result = hub.projects().topics_get("topic")
15374/// .doit().await;
15375/// # }
15376/// ```
15377pub struct ProjectTopicGetCall<'a, C>
15378where
15379 C: 'a,
15380{
15381 hub: &'a Pubsub<C>,
15382 _topic: String,
15383 _delegate: Option<&'a mut dyn common::Delegate>,
15384 _additional_params: HashMap<String, String>,
15385 _scopes: BTreeSet<String>,
15386}
15387
15388impl<'a, C> common::CallBuilder for ProjectTopicGetCall<'a, C> {}
15389
15390impl<'a, C> ProjectTopicGetCall<'a, C>
15391where
15392 C: common::Connector,
15393{
15394 /// Perform the operation you have build so far.
15395 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
15396 use std::borrow::Cow;
15397 use std::io::{Read, Seek};
15398
15399 use common::{url::Params, ToParts};
15400 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15401
15402 let mut dd = common::DefaultDelegate;
15403 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15404 dlg.begin(common::MethodInfo {
15405 id: "pubsub.projects.topics.get",
15406 http_method: hyper::Method::GET,
15407 });
15408
15409 for &field in ["alt", "topic"].iter() {
15410 if self._additional_params.contains_key(field) {
15411 dlg.finished(false);
15412 return Err(common::Error::FieldClash(field));
15413 }
15414 }
15415
15416 let mut params = Params::with_capacity(3 + self._additional_params.len());
15417 params.push("topic", self._topic);
15418
15419 params.extend(self._additional_params.iter());
15420
15421 params.push("alt", "json");
15422 let mut url = self.hub._base_url.clone() + "v1/{+topic}";
15423 if self._scopes.is_empty() {
15424 self._scopes
15425 .insert(Scope::CloudPlatform.as_ref().to_string());
15426 }
15427
15428 #[allow(clippy::single_element_loop)]
15429 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
15430 url = params.uri_replacement(url, param_name, find_this, true);
15431 }
15432 {
15433 let to_remove = ["topic"];
15434 params.remove_params(&to_remove);
15435 }
15436
15437 let url = params.parse_with_url(&url);
15438
15439 loop {
15440 let token = match self
15441 .hub
15442 .auth
15443 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15444 .await
15445 {
15446 Ok(token) => token,
15447 Err(e) => match dlg.token(e) {
15448 Ok(token) => token,
15449 Err(e) => {
15450 dlg.finished(false);
15451 return Err(common::Error::MissingToken(e));
15452 }
15453 },
15454 };
15455 let mut req_result = {
15456 let client = &self.hub.client;
15457 dlg.pre_request();
15458 let mut req_builder = hyper::Request::builder()
15459 .method(hyper::Method::GET)
15460 .uri(url.as_str())
15461 .header(USER_AGENT, self.hub._user_agent.clone());
15462
15463 if let Some(token) = token.as_ref() {
15464 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15465 }
15466
15467 let request = req_builder
15468 .header(CONTENT_LENGTH, 0_u64)
15469 .body(common::to_body::<String>(None));
15470
15471 client.request(request.unwrap()).await
15472 };
15473
15474 match req_result {
15475 Err(err) => {
15476 if let common::Retry::After(d) = dlg.http_error(&err) {
15477 sleep(d).await;
15478 continue;
15479 }
15480 dlg.finished(false);
15481 return Err(common::Error::HttpError(err));
15482 }
15483 Ok(res) => {
15484 let (mut parts, body) = res.into_parts();
15485 let mut body = common::Body::new(body);
15486 if !parts.status.is_success() {
15487 let bytes = common::to_bytes(body).await.unwrap_or_default();
15488 let error = serde_json::from_str(&common::to_string(&bytes));
15489 let response = common::to_response(parts, bytes.into());
15490
15491 if let common::Retry::After(d) =
15492 dlg.http_failure(&response, error.as_ref().ok())
15493 {
15494 sleep(d).await;
15495 continue;
15496 }
15497
15498 dlg.finished(false);
15499
15500 return Err(match error {
15501 Ok(value) => common::Error::BadRequest(value),
15502 _ => common::Error::Failure(response),
15503 });
15504 }
15505 let response = {
15506 let bytes = common::to_bytes(body).await.unwrap_or_default();
15507 let encoded = common::to_string(&bytes);
15508 match serde_json::from_str(&encoded) {
15509 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15510 Err(error) => {
15511 dlg.response_json_decode_error(&encoded, &error);
15512 return Err(common::Error::JsonDecodeError(
15513 encoded.to_string(),
15514 error,
15515 ));
15516 }
15517 }
15518 };
15519
15520 dlg.finished(true);
15521 return Ok(response);
15522 }
15523 }
15524 }
15525 }
15526
15527 /// Required. Identifier. The name of the topic to get. Format is `projects/{project}/topics/{topic}`.
15528 ///
15529 /// Sets the *topic* path property to the given value.
15530 ///
15531 /// Even though the property as already been set when instantiating this call,
15532 /// we provide this method for API completeness.
15533 pub fn topic(mut self, new_value: &str) -> ProjectTopicGetCall<'a, C> {
15534 self._topic = new_value.to_string();
15535 self
15536 }
15537 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15538 /// while executing the actual API request.
15539 ///
15540 /// ````text
15541 /// It should be used to handle progress information, and to implement a certain level of resilience.
15542 /// ````
15543 ///
15544 /// Sets the *delegate* property to the given value.
15545 pub fn delegate(
15546 mut self,
15547 new_value: &'a mut dyn common::Delegate,
15548 ) -> ProjectTopicGetCall<'a, C> {
15549 self._delegate = Some(new_value);
15550 self
15551 }
15552
15553 /// Set any additional parameter of the query string used in the request.
15554 /// It should be used to set parameters which are not yet available through their own
15555 /// setters.
15556 ///
15557 /// Please note that this method must not be used to set any of the known parameters
15558 /// which have their own setter method. If done anyway, the request will fail.
15559 ///
15560 /// # Additional Parameters
15561 ///
15562 /// * *$.xgafv* (query-string) - V1 error format.
15563 /// * *access_token* (query-string) - OAuth access token.
15564 /// * *alt* (query-string) - Data format for response.
15565 /// * *callback* (query-string) - JSONP
15566 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15567 /// * *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.
15568 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15569 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15570 /// * *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.
15571 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15572 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15573 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicGetCall<'a, C>
15574 where
15575 T: AsRef<str>,
15576 {
15577 self._additional_params
15578 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15579 self
15580 }
15581
15582 /// Identifies the authorization scope for the method you are building.
15583 ///
15584 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15585 /// [`Scope::CloudPlatform`].
15586 ///
15587 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15588 /// tokens for more than one scope.
15589 ///
15590 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15591 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15592 /// sufficient, a read-write scope will do as well.
15593 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicGetCall<'a, C>
15594 where
15595 St: AsRef<str>,
15596 {
15597 self._scopes.insert(String::from(scope.as_ref()));
15598 self
15599 }
15600 /// Identifies the authorization scope(s) for the method you are building.
15601 ///
15602 /// See [`Self::add_scope()`] for details.
15603 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicGetCall<'a, C>
15604 where
15605 I: IntoIterator<Item = St>,
15606 St: AsRef<str>,
15607 {
15608 self._scopes
15609 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15610 self
15611 }
15612
15613 /// Removes all scopes, and no default scope will be used either.
15614 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15615 /// for details).
15616 pub fn clear_scopes(mut self) -> ProjectTopicGetCall<'a, C> {
15617 self._scopes.clear();
15618 self
15619 }
15620}
15621
15622/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
15623///
15624/// A builder for the *topics.getIamPolicy* method supported by a *project* resource.
15625/// It is not used directly, but through a [`ProjectMethods`] instance.
15626///
15627/// # Example
15628///
15629/// Instantiate a resource method builder
15630///
15631/// ```test_harness,no_run
15632/// # extern crate hyper;
15633/// # extern crate hyper_rustls;
15634/// # extern crate google_pubsub1 as pubsub1;
15635/// # async fn dox() {
15636/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15637///
15638/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15639/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15640/// # .with_native_roots()
15641/// # .unwrap()
15642/// # .https_only()
15643/// # .enable_http2()
15644/// # .build();
15645///
15646/// # let executor = hyper_util::rt::TokioExecutor::new();
15647/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15648/// # secret,
15649/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15650/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15651/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15652/// # ),
15653/// # ).build().await.unwrap();
15654///
15655/// # let client = hyper_util::client::legacy::Client::builder(
15656/// # hyper_util::rt::TokioExecutor::new()
15657/// # )
15658/// # .build(
15659/// # hyper_rustls::HttpsConnectorBuilder::new()
15660/// # .with_native_roots()
15661/// # .unwrap()
15662/// # .https_or_http()
15663/// # .enable_http2()
15664/// # .build()
15665/// # );
15666/// # let mut hub = Pubsub::new(client, auth);
15667/// // You can configure optional parameters by calling the respective setters at will, and
15668/// // execute the final call using `doit()`.
15669/// // Values shown here are possibly random and not representative !
15670/// let result = hub.projects().topics_get_iam_policy("resource")
15671/// .options_requested_policy_version(-88)
15672/// .doit().await;
15673/// # }
15674/// ```
15675pub struct ProjectTopicGetIamPolicyCall<'a, C>
15676where
15677 C: 'a,
15678{
15679 hub: &'a Pubsub<C>,
15680 _resource: String,
15681 _options_requested_policy_version: Option<i32>,
15682 _delegate: Option<&'a mut dyn common::Delegate>,
15683 _additional_params: HashMap<String, String>,
15684 _scopes: BTreeSet<String>,
15685}
15686
15687impl<'a, C> common::CallBuilder for ProjectTopicGetIamPolicyCall<'a, C> {}
15688
15689impl<'a, C> ProjectTopicGetIamPolicyCall<'a, C>
15690where
15691 C: common::Connector,
15692{
15693 /// Perform the operation you have build so far.
15694 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
15695 use std::borrow::Cow;
15696 use std::io::{Read, Seek};
15697
15698 use common::{url::Params, ToParts};
15699 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15700
15701 let mut dd = common::DefaultDelegate;
15702 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15703 dlg.begin(common::MethodInfo {
15704 id: "pubsub.projects.topics.getIamPolicy",
15705 http_method: hyper::Method::GET,
15706 });
15707
15708 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
15709 if self._additional_params.contains_key(field) {
15710 dlg.finished(false);
15711 return Err(common::Error::FieldClash(field));
15712 }
15713 }
15714
15715 let mut params = Params::with_capacity(4 + self._additional_params.len());
15716 params.push("resource", self._resource);
15717 if let Some(value) = self._options_requested_policy_version.as_ref() {
15718 params.push("options.requestedPolicyVersion", value.to_string());
15719 }
15720
15721 params.extend(self._additional_params.iter());
15722
15723 params.push("alt", "json");
15724 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
15725 if self._scopes.is_empty() {
15726 self._scopes
15727 .insert(Scope::CloudPlatform.as_ref().to_string());
15728 }
15729
15730 #[allow(clippy::single_element_loop)]
15731 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
15732 url = params.uri_replacement(url, param_name, find_this, true);
15733 }
15734 {
15735 let to_remove = ["resource"];
15736 params.remove_params(&to_remove);
15737 }
15738
15739 let url = params.parse_with_url(&url);
15740
15741 loop {
15742 let token = match self
15743 .hub
15744 .auth
15745 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15746 .await
15747 {
15748 Ok(token) => token,
15749 Err(e) => match dlg.token(e) {
15750 Ok(token) => token,
15751 Err(e) => {
15752 dlg.finished(false);
15753 return Err(common::Error::MissingToken(e));
15754 }
15755 },
15756 };
15757 let mut req_result = {
15758 let client = &self.hub.client;
15759 dlg.pre_request();
15760 let mut req_builder = hyper::Request::builder()
15761 .method(hyper::Method::GET)
15762 .uri(url.as_str())
15763 .header(USER_AGENT, self.hub._user_agent.clone());
15764
15765 if let Some(token) = token.as_ref() {
15766 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15767 }
15768
15769 let request = req_builder
15770 .header(CONTENT_LENGTH, 0_u64)
15771 .body(common::to_body::<String>(None));
15772
15773 client.request(request.unwrap()).await
15774 };
15775
15776 match req_result {
15777 Err(err) => {
15778 if let common::Retry::After(d) = dlg.http_error(&err) {
15779 sleep(d).await;
15780 continue;
15781 }
15782 dlg.finished(false);
15783 return Err(common::Error::HttpError(err));
15784 }
15785 Ok(res) => {
15786 let (mut parts, body) = res.into_parts();
15787 let mut body = common::Body::new(body);
15788 if !parts.status.is_success() {
15789 let bytes = common::to_bytes(body).await.unwrap_or_default();
15790 let error = serde_json::from_str(&common::to_string(&bytes));
15791 let response = common::to_response(parts, bytes.into());
15792
15793 if let common::Retry::After(d) =
15794 dlg.http_failure(&response, error.as_ref().ok())
15795 {
15796 sleep(d).await;
15797 continue;
15798 }
15799
15800 dlg.finished(false);
15801
15802 return Err(match error {
15803 Ok(value) => common::Error::BadRequest(value),
15804 _ => common::Error::Failure(response),
15805 });
15806 }
15807 let response = {
15808 let bytes = common::to_bytes(body).await.unwrap_or_default();
15809 let encoded = common::to_string(&bytes);
15810 match serde_json::from_str(&encoded) {
15811 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15812 Err(error) => {
15813 dlg.response_json_decode_error(&encoded, &error);
15814 return Err(common::Error::JsonDecodeError(
15815 encoded.to_string(),
15816 error,
15817 ));
15818 }
15819 }
15820 };
15821
15822 dlg.finished(true);
15823 return Ok(response);
15824 }
15825 }
15826 }
15827 }
15828
15829 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
15830 ///
15831 /// Sets the *resource* path property to the given value.
15832 ///
15833 /// Even though the property as already been set when instantiating this call,
15834 /// we provide this method for API completeness.
15835 pub fn resource(mut self, new_value: &str) -> ProjectTopicGetIamPolicyCall<'a, C> {
15836 self._resource = new_value.to_string();
15837 self
15838 }
15839 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
15840 ///
15841 /// Sets the *options.requested policy version* query property to the given value.
15842 pub fn options_requested_policy_version(
15843 mut self,
15844 new_value: i32,
15845 ) -> ProjectTopicGetIamPolicyCall<'a, C> {
15846 self._options_requested_policy_version = Some(new_value);
15847 self
15848 }
15849 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15850 /// while executing the actual API request.
15851 ///
15852 /// ````text
15853 /// It should be used to handle progress information, and to implement a certain level of resilience.
15854 /// ````
15855 ///
15856 /// Sets the *delegate* property to the given value.
15857 pub fn delegate(
15858 mut self,
15859 new_value: &'a mut dyn common::Delegate,
15860 ) -> ProjectTopicGetIamPolicyCall<'a, C> {
15861 self._delegate = Some(new_value);
15862 self
15863 }
15864
15865 /// Set any additional parameter of the query string used in the request.
15866 /// It should be used to set parameters which are not yet available through their own
15867 /// setters.
15868 ///
15869 /// Please note that this method must not be used to set any of the known parameters
15870 /// which have their own setter method. If done anyway, the request will fail.
15871 ///
15872 /// # Additional Parameters
15873 ///
15874 /// * *$.xgafv* (query-string) - V1 error format.
15875 /// * *access_token* (query-string) - OAuth access token.
15876 /// * *alt* (query-string) - Data format for response.
15877 /// * *callback* (query-string) - JSONP
15878 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15879 /// * *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.
15880 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15881 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15882 /// * *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.
15883 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15884 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15885 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicGetIamPolicyCall<'a, C>
15886 where
15887 T: AsRef<str>,
15888 {
15889 self._additional_params
15890 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15891 self
15892 }
15893
15894 /// Identifies the authorization scope for the method you are building.
15895 ///
15896 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15897 /// [`Scope::CloudPlatform`].
15898 ///
15899 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15900 /// tokens for more than one scope.
15901 ///
15902 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15903 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15904 /// sufficient, a read-write scope will do as well.
15905 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicGetIamPolicyCall<'a, C>
15906 where
15907 St: AsRef<str>,
15908 {
15909 self._scopes.insert(String::from(scope.as_ref()));
15910 self
15911 }
15912 /// Identifies the authorization scope(s) for the method you are building.
15913 ///
15914 /// See [`Self::add_scope()`] for details.
15915 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicGetIamPolicyCall<'a, C>
15916 where
15917 I: IntoIterator<Item = St>,
15918 St: AsRef<str>,
15919 {
15920 self._scopes
15921 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15922 self
15923 }
15924
15925 /// Removes all scopes, and no default scope will be used either.
15926 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15927 /// for details).
15928 pub fn clear_scopes(mut self) -> ProjectTopicGetIamPolicyCall<'a, C> {
15929 self._scopes.clear();
15930 self
15931 }
15932}
15933
15934/// Lists matching topics.
15935///
15936/// A builder for the *topics.list* method supported by a *project* resource.
15937/// It is not used directly, but through a [`ProjectMethods`] instance.
15938///
15939/// # Example
15940///
15941/// Instantiate a resource method builder
15942///
15943/// ```test_harness,no_run
15944/// # extern crate hyper;
15945/// # extern crate hyper_rustls;
15946/// # extern crate google_pubsub1 as pubsub1;
15947/// # async fn dox() {
15948/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15949///
15950/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15951/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15952/// # .with_native_roots()
15953/// # .unwrap()
15954/// # .https_only()
15955/// # .enable_http2()
15956/// # .build();
15957///
15958/// # let executor = hyper_util::rt::TokioExecutor::new();
15959/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15960/// # secret,
15961/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15962/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15963/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15964/// # ),
15965/// # ).build().await.unwrap();
15966///
15967/// # let client = hyper_util::client::legacy::Client::builder(
15968/// # hyper_util::rt::TokioExecutor::new()
15969/// # )
15970/// # .build(
15971/// # hyper_rustls::HttpsConnectorBuilder::new()
15972/// # .with_native_roots()
15973/// # .unwrap()
15974/// # .https_or_http()
15975/// # .enable_http2()
15976/// # .build()
15977/// # );
15978/// # let mut hub = Pubsub::new(client, auth);
15979/// // You can configure optional parameters by calling the respective setters at will, and
15980/// // execute the final call using `doit()`.
15981/// // Values shown here are possibly random and not representative !
15982/// let result = hub.projects().topics_list("project")
15983/// .page_token("vero")
15984/// .page_size(-44)
15985/// .doit().await;
15986/// # }
15987/// ```
15988pub struct ProjectTopicListCall<'a, C>
15989where
15990 C: 'a,
15991{
15992 hub: &'a Pubsub<C>,
15993 _project: String,
15994 _page_token: Option<String>,
15995 _page_size: Option<i32>,
15996 _delegate: Option<&'a mut dyn common::Delegate>,
15997 _additional_params: HashMap<String, String>,
15998 _scopes: BTreeSet<String>,
15999}
16000
16001impl<'a, C> common::CallBuilder for ProjectTopicListCall<'a, C> {}
16002
16003impl<'a, C> ProjectTopicListCall<'a, C>
16004where
16005 C: common::Connector,
16006{
16007 /// Perform the operation you have build so far.
16008 pub async fn doit(mut self) -> common::Result<(common::Response, ListTopicsResponse)> {
16009 use std::borrow::Cow;
16010 use std::io::{Read, Seek};
16011
16012 use common::{url::Params, ToParts};
16013 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16014
16015 let mut dd = common::DefaultDelegate;
16016 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16017 dlg.begin(common::MethodInfo {
16018 id: "pubsub.projects.topics.list",
16019 http_method: hyper::Method::GET,
16020 });
16021
16022 for &field in ["alt", "project", "pageToken", "pageSize"].iter() {
16023 if self._additional_params.contains_key(field) {
16024 dlg.finished(false);
16025 return Err(common::Error::FieldClash(field));
16026 }
16027 }
16028
16029 let mut params = Params::with_capacity(5 + self._additional_params.len());
16030 params.push("project", self._project);
16031 if let Some(value) = self._page_token.as_ref() {
16032 params.push("pageToken", value);
16033 }
16034 if let Some(value) = self._page_size.as_ref() {
16035 params.push("pageSize", value.to_string());
16036 }
16037
16038 params.extend(self._additional_params.iter());
16039
16040 params.push("alt", "json");
16041 let mut url = self.hub._base_url.clone() + "v1/{+project}/topics";
16042 if self._scopes.is_empty() {
16043 self._scopes
16044 .insert(Scope::CloudPlatform.as_ref().to_string());
16045 }
16046
16047 #[allow(clippy::single_element_loop)]
16048 for &(find_this, param_name) in [("{+project}", "project")].iter() {
16049 url = params.uri_replacement(url, param_name, find_this, true);
16050 }
16051 {
16052 let to_remove = ["project"];
16053 params.remove_params(&to_remove);
16054 }
16055
16056 let url = params.parse_with_url(&url);
16057
16058 loop {
16059 let token = match self
16060 .hub
16061 .auth
16062 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16063 .await
16064 {
16065 Ok(token) => token,
16066 Err(e) => match dlg.token(e) {
16067 Ok(token) => token,
16068 Err(e) => {
16069 dlg.finished(false);
16070 return Err(common::Error::MissingToken(e));
16071 }
16072 },
16073 };
16074 let mut req_result = {
16075 let client = &self.hub.client;
16076 dlg.pre_request();
16077 let mut req_builder = hyper::Request::builder()
16078 .method(hyper::Method::GET)
16079 .uri(url.as_str())
16080 .header(USER_AGENT, self.hub._user_agent.clone());
16081
16082 if let Some(token) = token.as_ref() {
16083 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16084 }
16085
16086 let request = req_builder
16087 .header(CONTENT_LENGTH, 0_u64)
16088 .body(common::to_body::<String>(None));
16089
16090 client.request(request.unwrap()).await
16091 };
16092
16093 match req_result {
16094 Err(err) => {
16095 if let common::Retry::After(d) = dlg.http_error(&err) {
16096 sleep(d).await;
16097 continue;
16098 }
16099 dlg.finished(false);
16100 return Err(common::Error::HttpError(err));
16101 }
16102 Ok(res) => {
16103 let (mut parts, body) = res.into_parts();
16104 let mut body = common::Body::new(body);
16105 if !parts.status.is_success() {
16106 let bytes = common::to_bytes(body).await.unwrap_or_default();
16107 let error = serde_json::from_str(&common::to_string(&bytes));
16108 let response = common::to_response(parts, bytes.into());
16109
16110 if let common::Retry::After(d) =
16111 dlg.http_failure(&response, error.as_ref().ok())
16112 {
16113 sleep(d).await;
16114 continue;
16115 }
16116
16117 dlg.finished(false);
16118
16119 return Err(match error {
16120 Ok(value) => common::Error::BadRequest(value),
16121 _ => common::Error::Failure(response),
16122 });
16123 }
16124 let response = {
16125 let bytes = common::to_bytes(body).await.unwrap_or_default();
16126 let encoded = common::to_string(&bytes);
16127 match serde_json::from_str(&encoded) {
16128 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16129 Err(error) => {
16130 dlg.response_json_decode_error(&encoded, &error);
16131 return Err(common::Error::JsonDecodeError(
16132 encoded.to_string(),
16133 error,
16134 ));
16135 }
16136 }
16137 };
16138
16139 dlg.finished(true);
16140 return Ok(response);
16141 }
16142 }
16143 }
16144 }
16145
16146 /// Required. Identifier. The name of the project in which to list topics. Format is `projects/{project-id}`.
16147 ///
16148 /// Sets the *project* path property to the given value.
16149 ///
16150 /// Even though the property as already been set when instantiating this call,
16151 /// we provide this method for API completeness.
16152 pub fn project(mut self, new_value: &str) -> ProjectTopicListCall<'a, C> {
16153 self._project = new_value.to_string();
16154 self
16155 }
16156 /// Optional. The value returned by the last `ListTopicsResponse`; indicates that this is a continuation of a prior `ListTopics` call, and that the system should return the next page of data.
16157 ///
16158 /// Sets the *page token* query property to the given value.
16159 pub fn page_token(mut self, new_value: &str) -> ProjectTopicListCall<'a, C> {
16160 self._page_token = Some(new_value.to_string());
16161 self
16162 }
16163 /// Optional. Maximum number of topics to return.
16164 ///
16165 /// Sets the *page size* query property to the given value.
16166 pub fn page_size(mut self, new_value: i32) -> ProjectTopicListCall<'a, C> {
16167 self._page_size = Some(new_value);
16168 self
16169 }
16170 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16171 /// while executing the actual API request.
16172 ///
16173 /// ````text
16174 /// It should be used to handle progress information, and to implement a certain level of resilience.
16175 /// ````
16176 ///
16177 /// Sets the *delegate* property to the given value.
16178 pub fn delegate(
16179 mut self,
16180 new_value: &'a mut dyn common::Delegate,
16181 ) -> ProjectTopicListCall<'a, C> {
16182 self._delegate = Some(new_value);
16183 self
16184 }
16185
16186 /// Set any additional parameter of the query string used in the request.
16187 /// It should be used to set parameters which are not yet available through their own
16188 /// setters.
16189 ///
16190 /// Please note that this method must not be used to set any of the known parameters
16191 /// which have their own setter method. If done anyway, the request will fail.
16192 ///
16193 /// # Additional Parameters
16194 ///
16195 /// * *$.xgafv* (query-string) - V1 error format.
16196 /// * *access_token* (query-string) - OAuth access token.
16197 /// * *alt* (query-string) - Data format for response.
16198 /// * *callback* (query-string) - JSONP
16199 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16200 /// * *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.
16201 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16202 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16203 /// * *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.
16204 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16205 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16206 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicListCall<'a, C>
16207 where
16208 T: AsRef<str>,
16209 {
16210 self._additional_params
16211 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16212 self
16213 }
16214
16215 /// Identifies the authorization scope for the method you are building.
16216 ///
16217 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16218 /// [`Scope::CloudPlatform`].
16219 ///
16220 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16221 /// tokens for more than one scope.
16222 ///
16223 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16224 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16225 /// sufficient, a read-write scope will do as well.
16226 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicListCall<'a, C>
16227 where
16228 St: AsRef<str>,
16229 {
16230 self._scopes.insert(String::from(scope.as_ref()));
16231 self
16232 }
16233 /// Identifies the authorization scope(s) for the method you are building.
16234 ///
16235 /// See [`Self::add_scope()`] for details.
16236 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicListCall<'a, C>
16237 where
16238 I: IntoIterator<Item = St>,
16239 St: AsRef<str>,
16240 {
16241 self._scopes
16242 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16243 self
16244 }
16245
16246 /// Removes all scopes, and no default scope will be used either.
16247 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16248 /// for details).
16249 pub fn clear_scopes(mut self) -> ProjectTopicListCall<'a, C> {
16250 self._scopes.clear();
16251 self
16252 }
16253}
16254
16255/// Updates an existing topic by updating the fields specified in the update mask. Note that certain properties of a topic are not modifiable.
16256///
16257/// A builder for the *topics.patch* method supported by a *project* resource.
16258/// It is not used directly, but through a [`ProjectMethods`] instance.
16259///
16260/// # Example
16261///
16262/// Instantiate a resource method builder
16263///
16264/// ```test_harness,no_run
16265/// # extern crate hyper;
16266/// # extern crate hyper_rustls;
16267/// # extern crate google_pubsub1 as pubsub1;
16268/// use pubsub1::api::UpdateTopicRequest;
16269/// # async fn dox() {
16270/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16271///
16272/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16273/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16274/// # .with_native_roots()
16275/// # .unwrap()
16276/// # .https_only()
16277/// # .enable_http2()
16278/// # .build();
16279///
16280/// # let executor = hyper_util::rt::TokioExecutor::new();
16281/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16282/// # secret,
16283/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16284/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16285/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16286/// # ),
16287/// # ).build().await.unwrap();
16288///
16289/// # let client = hyper_util::client::legacy::Client::builder(
16290/// # hyper_util::rt::TokioExecutor::new()
16291/// # )
16292/// # .build(
16293/// # hyper_rustls::HttpsConnectorBuilder::new()
16294/// # .with_native_roots()
16295/// # .unwrap()
16296/// # .https_or_http()
16297/// # .enable_http2()
16298/// # .build()
16299/// # );
16300/// # let mut hub = Pubsub::new(client, auth);
16301/// // As the method needs a request, you would usually fill it with the desired information
16302/// // into the respective structure. Some of the parts shown here might not be applicable !
16303/// // Values shown here are possibly random and not representative !
16304/// let mut req = UpdateTopicRequest::default();
16305///
16306/// // You can configure optional parameters by calling the respective setters at will, and
16307/// // execute the final call using `doit()`.
16308/// // Values shown here are possibly random and not representative !
16309/// let result = hub.projects().topics_patch(req, "name")
16310/// .doit().await;
16311/// # }
16312/// ```
16313pub struct ProjectTopicPatchCall<'a, C>
16314where
16315 C: 'a,
16316{
16317 hub: &'a Pubsub<C>,
16318 _request: UpdateTopicRequest,
16319 _name: String,
16320 _delegate: Option<&'a mut dyn common::Delegate>,
16321 _additional_params: HashMap<String, String>,
16322 _scopes: BTreeSet<String>,
16323}
16324
16325impl<'a, C> common::CallBuilder for ProjectTopicPatchCall<'a, C> {}
16326
16327impl<'a, C> ProjectTopicPatchCall<'a, C>
16328where
16329 C: common::Connector,
16330{
16331 /// Perform the operation you have build so far.
16332 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
16333 use std::borrow::Cow;
16334 use std::io::{Read, Seek};
16335
16336 use common::{url::Params, ToParts};
16337 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16338
16339 let mut dd = common::DefaultDelegate;
16340 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16341 dlg.begin(common::MethodInfo {
16342 id: "pubsub.projects.topics.patch",
16343 http_method: hyper::Method::PATCH,
16344 });
16345
16346 for &field in ["alt", "name"].iter() {
16347 if self._additional_params.contains_key(field) {
16348 dlg.finished(false);
16349 return Err(common::Error::FieldClash(field));
16350 }
16351 }
16352
16353 let mut params = Params::with_capacity(4 + self._additional_params.len());
16354 params.push("name", self._name);
16355
16356 params.extend(self._additional_params.iter());
16357
16358 params.push("alt", "json");
16359 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16360 if self._scopes.is_empty() {
16361 self._scopes
16362 .insert(Scope::CloudPlatform.as_ref().to_string());
16363 }
16364
16365 #[allow(clippy::single_element_loop)]
16366 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16367 url = params.uri_replacement(url, param_name, find_this, true);
16368 }
16369 {
16370 let to_remove = ["name"];
16371 params.remove_params(&to_remove);
16372 }
16373
16374 let url = params.parse_with_url(&url);
16375
16376 let mut json_mime_type = mime::APPLICATION_JSON;
16377 let mut request_value_reader = {
16378 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16379 common::remove_json_null_values(&mut value);
16380 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16381 serde_json::to_writer(&mut dst, &value).unwrap();
16382 dst
16383 };
16384 let request_size = request_value_reader
16385 .seek(std::io::SeekFrom::End(0))
16386 .unwrap();
16387 request_value_reader
16388 .seek(std::io::SeekFrom::Start(0))
16389 .unwrap();
16390
16391 loop {
16392 let token = match self
16393 .hub
16394 .auth
16395 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16396 .await
16397 {
16398 Ok(token) => token,
16399 Err(e) => match dlg.token(e) {
16400 Ok(token) => token,
16401 Err(e) => {
16402 dlg.finished(false);
16403 return Err(common::Error::MissingToken(e));
16404 }
16405 },
16406 };
16407 request_value_reader
16408 .seek(std::io::SeekFrom::Start(0))
16409 .unwrap();
16410 let mut req_result = {
16411 let client = &self.hub.client;
16412 dlg.pre_request();
16413 let mut req_builder = hyper::Request::builder()
16414 .method(hyper::Method::PATCH)
16415 .uri(url.as_str())
16416 .header(USER_AGENT, self.hub._user_agent.clone());
16417
16418 if let Some(token) = token.as_ref() {
16419 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16420 }
16421
16422 let request = req_builder
16423 .header(CONTENT_TYPE, json_mime_type.to_string())
16424 .header(CONTENT_LENGTH, request_size as u64)
16425 .body(common::to_body(
16426 request_value_reader.get_ref().clone().into(),
16427 ));
16428
16429 client.request(request.unwrap()).await
16430 };
16431
16432 match req_result {
16433 Err(err) => {
16434 if let common::Retry::After(d) = dlg.http_error(&err) {
16435 sleep(d).await;
16436 continue;
16437 }
16438 dlg.finished(false);
16439 return Err(common::Error::HttpError(err));
16440 }
16441 Ok(res) => {
16442 let (mut parts, body) = res.into_parts();
16443 let mut body = common::Body::new(body);
16444 if !parts.status.is_success() {
16445 let bytes = common::to_bytes(body).await.unwrap_or_default();
16446 let error = serde_json::from_str(&common::to_string(&bytes));
16447 let response = common::to_response(parts, bytes.into());
16448
16449 if let common::Retry::After(d) =
16450 dlg.http_failure(&response, error.as_ref().ok())
16451 {
16452 sleep(d).await;
16453 continue;
16454 }
16455
16456 dlg.finished(false);
16457
16458 return Err(match error {
16459 Ok(value) => common::Error::BadRequest(value),
16460 _ => common::Error::Failure(response),
16461 });
16462 }
16463 let response = {
16464 let bytes = common::to_bytes(body).await.unwrap_or_default();
16465 let encoded = common::to_string(&bytes);
16466 match serde_json::from_str(&encoded) {
16467 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16468 Err(error) => {
16469 dlg.response_json_decode_error(&encoded, &error);
16470 return Err(common::Error::JsonDecodeError(
16471 encoded.to_string(),
16472 error,
16473 ));
16474 }
16475 }
16476 };
16477
16478 dlg.finished(true);
16479 return Ok(response);
16480 }
16481 }
16482 }
16483 }
16484
16485 ///
16486 /// Sets the *request* property to the given value.
16487 ///
16488 /// Even though the property as already been set when instantiating this call,
16489 /// we provide this method for API completeness.
16490 pub fn request(mut self, new_value: UpdateTopicRequest) -> ProjectTopicPatchCall<'a, C> {
16491 self._request = new_value;
16492 self
16493 }
16494 /// Required. Identifier. The name of the topic. It must have the format `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `"goog"`.
16495 ///
16496 /// Sets the *name* path property to the given value.
16497 ///
16498 /// Even though the property as already been set when instantiating this call,
16499 /// we provide this method for API completeness.
16500 pub fn name(mut self, new_value: &str) -> ProjectTopicPatchCall<'a, C> {
16501 self._name = new_value.to_string();
16502 self
16503 }
16504 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16505 /// while executing the actual API request.
16506 ///
16507 /// ````text
16508 /// It should be used to handle progress information, and to implement a certain level of resilience.
16509 /// ````
16510 ///
16511 /// Sets the *delegate* property to the given value.
16512 pub fn delegate(
16513 mut self,
16514 new_value: &'a mut dyn common::Delegate,
16515 ) -> ProjectTopicPatchCall<'a, C> {
16516 self._delegate = Some(new_value);
16517 self
16518 }
16519
16520 /// Set any additional parameter of the query string used in the request.
16521 /// It should be used to set parameters which are not yet available through their own
16522 /// setters.
16523 ///
16524 /// Please note that this method must not be used to set any of the known parameters
16525 /// which have their own setter method. If done anyway, the request will fail.
16526 ///
16527 /// # Additional Parameters
16528 ///
16529 /// * *$.xgafv* (query-string) - V1 error format.
16530 /// * *access_token* (query-string) - OAuth access token.
16531 /// * *alt* (query-string) - Data format for response.
16532 /// * *callback* (query-string) - JSONP
16533 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16534 /// * *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.
16535 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16536 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16537 /// * *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.
16538 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16539 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16540 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicPatchCall<'a, C>
16541 where
16542 T: AsRef<str>,
16543 {
16544 self._additional_params
16545 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16546 self
16547 }
16548
16549 /// Identifies the authorization scope for the method you are building.
16550 ///
16551 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16552 /// [`Scope::CloudPlatform`].
16553 ///
16554 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16555 /// tokens for more than one scope.
16556 ///
16557 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16558 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16559 /// sufficient, a read-write scope will do as well.
16560 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicPatchCall<'a, C>
16561 where
16562 St: AsRef<str>,
16563 {
16564 self._scopes.insert(String::from(scope.as_ref()));
16565 self
16566 }
16567 /// Identifies the authorization scope(s) for the method you are building.
16568 ///
16569 /// See [`Self::add_scope()`] for details.
16570 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicPatchCall<'a, C>
16571 where
16572 I: IntoIterator<Item = St>,
16573 St: AsRef<str>,
16574 {
16575 self._scopes
16576 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16577 self
16578 }
16579
16580 /// Removes all scopes, and no default scope will be used either.
16581 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16582 /// for details).
16583 pub fn clear_scopes(mut self) -> ProjectTopicPatchCall<'a, C> {
16584 self._scopes.clear();
16585 self
16586 }
16587}
16588
16589/// Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist.
16590///
16591/// A builder for the *topics.publish* method supported by a *project* resource.
16592/// It is not used directly, but through a [`ProjectMethods`] instance.
16593///
16594/// # Example
16595///
16596/// Instantiate a resource method builder
16597///
16598/// ```test_harness,no_run
16599/// # extern crate hyper;
16600/// # extern crate hyper_rustls;
16601/// # extern crate google_pubsub1 as pubsub1;
16602/// use pubsub1::api::PublishRequest;
16603/// # async fn dox() {
16604/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16605///
16606/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16607/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16608/// # .with_native_roots()
16609/// # .unwrap()
16610/// # .https_only()
16611/// # .enable_http2()
16612/// # .build();
16613///
16614/// # let executor = hyper_util::rt::TokioExecutor::new();
16615/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16616/// # secret,
16617/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16618/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16619/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16620/// # ),
16621/// # ).build().await.unwrap();
16622///
16623/// # let client = hyper_util::client::legacy::Client::builder(
16624/// # hyper_util::rt::TokioExecutor::new()
16625/// # )
16626/// # .build(
16627/// # hyper_rustls::HttpsConnectorBuilder::new()
16628/// # .with_native_roots()
16629/// # .unwrap()
16630/// # .https_or_http()
16631/// # .enable_http2()
16632/// # .build()
16633/// # );
16634/// # let mut hub = Pubsub::new(client, auth);
16635/// // As the method needs a request, you would usually fill it with the desired information
16636/// // into the respective structure. Some of the parts shown here might not be applicable !
16637/// // Values shown here are possibly random and not representative !
16638/// let mut req = PublishRequest::default();
16639///
16640/// // You can configure optional parameters by calling the respective setters at will, and
16641/// // execute the final call using `doit()`.
16642/// // Values shown here are possibly random and not representative !
16643/// let result = hub.projects().topics_publish(req, "topic")
16644/// .doit().await;
16645/// # }
16646/// ```
16647pub struct ProjectTopicPublishCall<'a, C>
16648where
16649 C: 'a,
16650{
16651 hub: &'a Pubsub<C>,
16652 _request: PublishRequest,
16653 _topic: String,
16654 _delegate: Option<&'a mut dyn common::Delegate>,
16655 _additional_params: HashMap<String, String>,
16656 _scopes: BTreeSet<String>,
16657}
16658
16659impl<'a, C> common::CallBuilder for ProjectTopicPublishCall<'a, C> {}
16660
16661impl<'a, C> ProjectTopicPublishCall<'a, C>
16662where
16663 C: common::Connector,
16664{
16665 /// Perform the operation you have build so far.
16666 pub async fn doit(mut self) -> common::Result<(common::Response, PublishResponse)> {
16667 use std::borrow::Cow;
16668 use std::io::{Read, Seek};
16669
16670 use common::{url::Params, ToParts};
16671 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16672
16673 let mut dd = common::DefaultDelegate;
16674 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16675 dlg.begin(common::MethodInfo {
16676 id: "pubsub.projects.topics.publish",
16677 http_method: hyper::Method::POST,
16678 });
16679
16680 for &field in ["alt", "topic"].iter() {
16681 if self._additional_params.contains_key(field) {
16682 dlg.finished(false);
16683 return Err(common::Error::FieldClash(field));
16684 }
16685 }
16686
16687 let mut params = Params::with_capacity(4 + self._additional_params.len());
16688 params.push("topic", self._topic);
16689
16690 params.extend(self._additional_params.iter());
16691
16692 params.push("alt", "json");
16693 let mut url = self.hub._base_url.clone() + "v1/{+topic}:publish";
16694 if self._scopes.is_empty() {
16695 self._scopes
16696 .insert(Scope::CloudPlatform.as_ref().to_string());
16697 }
16698
16699 #[allow(clippy::single_element_loop)]
16700 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
16701 url = params.uri_replacement(url, param_name, find_this, true);
16702 }
16703 {
16704 let to_remove = ["topic"];
16705 params.remove_params(&to_remove);
16706 }
16707
16708 let url = params.parse_with_url(&url);
16709
16710 let mut json_mime_type = mime::APPLICATION_JSON;
16711 let mut request_value_reader = {
16712 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16713 common::remove_json_null_values(&mut value);
16714 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16715 serde_json::to_writer(&mut dst, &value).unwrap();
16716 dst
16717 };
16718 let request_size = request_value_reader
16719 .seek(std::io::SeekFrom::End(0))
16720 .unwrap();
16721 request_value_reader
16722 .seek(std::io::SeekFrom::Start(0))
16723 .unwrap();
16724
16725 loop {
16726 let token = match self
16727 .hub
16728 .auth
16729 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16730 .await
16731 {
16732 Ok(token) => token,
16733 Err(e) => match dlg.token(e) {
16734 Ok(token) => token,
16735 Err(e) => {
16736 dlg.finished(false);
16737 return Err(common::Error::MissingToken(e));
16738 }
16739 },
16740 };
16741 request_value_reader
16742 .seek(std::io::SeekFrom::Start(0))
16743 .unwrap();
16744 let mut req_result = {
16745 let client = &self.hub.client;
16746 dlg.pre_request();
16747 let mut req_builder = hyper::Request::builder()
16748 .method(hyper::Method::POST)
16749 .uri(url.as_str())
16750 .header(USER_AGENT, self.hub._user_agent.clone());
16751
16752 if let Some(token) = token.as_ref() {
16753 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16754 }
16755
16756 let request = req_builder
16757 .header(CONTENT_TYPE, json_mime_type.to_string())
16758 .header(CONTENT_LENGTH, request_size as u64)
16759 .body(common::to_body(
16760 request_value_reader.get_ref().clone().into(),
16761 ));
16762
16763 client.request(request.unwrap()).await
16764 };
16765
16766 match req_result {
16767 Err(err) => {
16768 if let common::Retry::After(d) = dlg.http_error(&err) {
16769 sleep(d).await;
16770 continue;
16771 }
16772 dlg.finished(false);
16773 return Err(common::Error::HttpError(err));
16774 }
16775 Ok(res) => {
16776 let (mut parts, body) = res.into_parts();
16777 let mut body = common::Body::new(body);
16778 if !parts.status.is_success() {
16779 let bytes = common::to_bytes(body).await.unwrap_or_default();
16780 let error = serde_json::from_str(&common::to_string(&bytes));
16781 let response = common::to_response(parts, bytes.into());
16782
16783 if let common::Retry::After(d) =
16784 dlg.http_failure(&response, error.as_ref().ok())
16785 {
16786 sleep(d).await;
16787 continue;
16788 }
16789
16790 dlg.finished(false);
16791
16792 return Err(match error {
16793 Ok(value) => common::Error::BadRequest(value),
16794 _ => common::Error::Failure(response),
16795 });
16796 }
16797 let response = {
16798 let bytes = common::to_bytes(body).await.unwrap_or_default();
16799 let encoded = common::to_string(&bytes);
16800 match serde_json::from_str(&encoded) {
16801 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16802 Err(error) => {
16803 dlg.response_json_decode_error(&encoded, &error);
16804 return Err(common::Error::JsonDecodeError(
16805 encoded.to_string(),
16806 error,
16807 ));
16808 }
16809 }
16810 };
16811
16812 dlg.finished(true);
16813 return Ok(response);
16814 }
16815 }
16816 }
16817 }
16818
16819 ///
16820 /// Sets the *request* property to the given value.
16821 ///
16822 /// Even though the property as already been set when instantiating this call,
16823 /// we provide this method for API completeness.
16824 pub fn request(mut self, new_value: PublishRequest) -> ProjectTopicPublishCall<'a, C> {
16825 self._request = new_value;
16826 self
16827 }
16828 /// Required. Identifier. The messages in the request will be published on this topic. Format is `projects/{project}/topics/{topic}`.
16829 ///
16830 /// Sets the *topic* path property to the given value.
16831 ///
16832 /// Even though the property as already been set when instantiating this call,
16833 /// we provide this method for API completeness.
16834 pub fn topic(mut self, new_value: &str) -> ProjectTopicPublishCall<'a, C> {
16835 self._topic = new_value.to_string();
16836 self
16837 }
16838 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16839 /// while executing the actual API request.
16840 ///
16841 /// ````text
16842 /// It should be used to handle progress information, and to implement a certain level of resilience.
16843 /// ````
16844 ///
16845 /// Sets the *delegate* property to the given value.
16846 pub fn delegate(
16847 mut self,
16848 new_value: &'a mut dyn common::Delegate,
16849 ) -> ProjectTopicPublishCall<'a, C> {
16850 self._delegate = Some(new_value);
16851 self
16852 }
16853
16854 /// Set any additional parameter of the query string used in the request.
16855 /// It should be used to set parameters which are not yet available through their own
16856 /// setters.
16857 ///
16858 /// Please note that this method must not be used to set any of the known parameters
16859 /// which have their own setter method. If done anyway, the request will fail.
16860 ///
16861 /// # Additional Parameters
16862 ///
16863 /// * *$.xgafv* (query-string) - V1 error format.
16864 /// * *access_token* (query-string) - OAuth access token.
16865 /// * *alt* (query-string) - Data format for response.
16866 /// * *callback* (query-string) - JSONP
16867 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16868 /// * *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.
16869 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16870 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16871 /// * *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.
16872 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16873 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16874 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicPublishCall<'a, C>
16875 where
16876 T: AsRef<str>,
16877 {
16878 self._additional_params
16879 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16880 self
16881 }
16882
16883 /// Identifies the authorization scope for the method you are building.
16884 ///
16885 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16886 /// [`Scope::CloudPlatform`].
16887 ///
16888 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16889 /// tokens for more than one scope.
16890 ///
16891 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16892 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16893 /// sufficient, a read-write scope will do as well.
16894 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicPublishCall<'a, C>
16895 where
16896 St: AsRef<str>,
16897 {
16898 self._scopes.insert(String::from(scope.as_ref()));
16899 self
16900 }
16901 /// Identifies the authorization scope(s) for the method you are building.
16902 ///
16903 /// See [`Self::add_scope()`] for details.
16904 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicPublishCall<'a, C>
16905 where
16906 I: IntoIterator<Item = St>,
16907 St: AsRef<str>,
16908 {
16909 self._scopes
16910 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16911 self
16912 }
16913
16914 /// Removes all scopes, and no default scope will be used either.
16915 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16916 /// for details).
16917 pub fn clear_scopes(mut self) -> ProjectTopicPublishCall<'a, C> {
16918 self._scopes.clear();
16919 self
16920 }
16921}
16922
16923/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
16924///
16925/// A builder for the *topics.setIamPolicy* method supported by a *project* resource.
16926/// It is not used directly, but through a [`ProjectMethods`] instance.
16927///
16928/// # Example
16929///
16930/// Instantiate a resource method builder
16931///
16932/// ```test_harness,no_run
16933/// # extern crate hyper;
16934/// # extern crate hyper_rustls;
16935/// # extern crate google_pubsub1 as pubsub1;
16936/// use pubsub1::api::SetIamPolicyRequest;
16937/// # async fn dox() {
16938/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16939///
16940/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16941/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16942/// # .with_native_roots()
16943/// # .unwrap()
16944/// # .https_only()
16945/// # .enable_http2()
16946/// # .build();
16947///
16948/// # let executor = hyper_util::rt::TokioExecutor::new();
16949/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16950/// # secret,
16951/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16952/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16953/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16954/// # ),
16955/// # ).build().await.unwrap();
16956///
16957/// # let client = hyper_util::client::legacy::Client::builder(
16958/// # hyper_util::rt::TokioExecutor::new()
16959/// # )
16960/// # .build(
16961/// # hyper_rustls::HttpsConnectorBuilder::new()
16962/// # .with_native_roots()
16963/// # .unwrap()
16964/// # .https_or_http()
16965/// # .enable_http2()
16966/// # .build()
16967/// # );
16968/// # let mut hub = Pubsub::new(client, auth);
16969/// // As the method needs a request, you would usually fill it with the desired information
16970/// // into the respective structure. Some of the parts shown here might not be applicable !
16971/// // Values shown here are possibly random and not representative !
16972/// let mut req = SetIamPolicyRequest::default();
16973///
16974/// // You can configure optional parameters by calling the respective setters at will, and
16975/// // execute the final call using `doit()`.
16976/// // Values shown here are possibly random and not representative !
16977/// let result = hub.projects().topics_set_iam_policy(req, "resource")
16978/// .doit().await;
16979/// # }
16980/// ```
16981pub struct ProjectTopicSetIamPolicyCall<'a, C>
16982where
16983 C: 'a,
16984{
16985 hub: &'a Pubsub<C>,
16986 _request: SetIamPolicyRequest,
16987 _resource: String,
16988 _delegate: Option<&'a mut dyn common::Delegate>,
16989 _additional_params: HashMap<String, String>,
16990 _scopes: BTreeSet<String>,
16991}
16992
16993impl<'a, C> common::CallBuilder for ProjectTopicSetIamPolicyCall<'a, C> {}
16994
16995impl<'a, C> ProjectTopicSetIamPolicyCall<'a, C>
16996where
16997 C: common::Connector,
16998{
16999 /// Perform the operation you have build so far.
17000 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
17001 use std::borrow::Cow;
17002 use std::io::{Read, Seek};
17003
17004 use common::{url::Params, ToParts};
17005 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17006
17007 let mut dd = common::DefaultDelegate;
17008 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17009 dlg.begin(common::MethodInfo {
17010 id: "pubsub.projects.topics.setIamPolicy",
17011 http_method: hyper::Method::POST,
17012 });
17013
17014 for &field in ["alt", "resource"].iter() {
17015 if self._additional_params.contains_key(field) {
17016 dlg.finished(false);
17017 return Err(common::Error::FieldClash(field));
17018 }
17019 }
17020
17021 let mut params = Params::with_capacity(4 + self._additional_params.len());
17022 params.push("resource", self._resource);
17023
17024 params.extend(self._additional_params.iter());
17025
17026 params.push("alt", "json");
17027 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
17028 if self._scopes.is_empty() {
17029 self._scopes
17030 .insert(Scope::CloudPlatform.as_ref().to_string());
17031 }
17032
17033 #[allow(clippy::single_element_loop)]
17034 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17035 url = params.uri_replacement(url, param_name, find_this, true);
17036 }
17037 {
17038 let to_remove = ["resource"];
17039 params.remove_params(&to_remove);
17040 }
17041
17042 let url = params.parse_with_url(&url);
17043
17044 let mut json_mime_type = mime::APPLICATION_JSON;
17045 let mut request_value_reader = {
17046 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17047 common::remove_json_null_values(&mut value);
17048 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17049 serde_json::to_writer(&mut dst, &value).unwrap();
17050 dst
17051 };
17052 let request_size = request_value_reader
17053 .seek(std::io::SeekFrom::End(0))
17054 .unwrap();
17055 request_value_reader
17056 .seek(std::io::SeekFrom::Start(0))
17057 .unwrap();
17058
17059 loop {
17060 let token = match self
17061 .hub
17062 .auth
17063 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17064 .await
17065 {
17066 Ok(token) => token,
17067 Err(e) => match dlg.token(e) {
17068 Ok(token) => token,
17069 Err(e) => {
17070 dlg.finished(false);
17071 return Err(common::Error::MissingToken(e));
17072 }
17073 },
17074 };
17075 request_value_reader
17076 .seek(std::io::SeekFrom::Start(0))
17077 .unwrap();
17078 let mut req_result = {
17079 let client = &self.hub.client;
17080 dlg.pre_request();
17081 let mut req_builder = hyper::Request::builder()
17082 .method(hyper::Method::POST)
17083 .uri(url.as_str())
17084 .header(USER_AGENT, self.hub._user_agent.clone());
17085
17086 if let Some(token) = token.as_ref() {
17087 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17088 }
17089
17090 let request = req_builder
17091 .header(CONTENT_TYPE, json_mime_type.to_string())
17092 .header(CONTENT_LENGTH, request_size as u64)
17093 .body(common::to_body(
17094 request_value_reader.get_ref().clone().into(),
17095 ));
17096
17097 client.request(request.unwrap()).await
17098 };
17099
17100 match req_result {
17101 Err(err) => {
17102 if let common::Retry::After(d) = dlg.http_error(&err) {
17103 sleep(d).await;
17104 continue;
17105 }
17106 dlg.finished(false);
17107 return Err(common::Error::HttpError(err));
17108 }
17109 Ok(res) => {
17110 let (mut parts, body) = res.into_parts();
17111 let mut body = common::Body::new(body);
17112 if !parts.status.is_success() {
17113 let bytes = common::to_bytes(body).await.unwrap_or_default();
17114 let error = serde_json::from_str(&common::to_string(&bytes));
17115 let response = common::to_response(parts, bytes.into());
17116
17117 if let common::Retry::After(d) =
17118 dlg.http_failure(&response, error.as_ref().ok())
17119 {
17120 sleep(d).await;
17121 continue;
17122 }
17123
17124 dlg.finished(false);
17125
17126 return Err(match error {
17127 Ok(value) => common::Error::BadRequest(value),
17128 _ => common::Error::Failure(response),
17129 });
17130 }
17131 let response = {
17132 let bytes = common::to_bytes(body).await.unwrap_or_default();
17133 let encoded = common::to_string(&bytes);
17134 match serde_json::from_str(&encoded) {
17135 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17136 Err(error) => {
17137 dlg.response_json_decode_error(&encoded, &error);
17138 return Err(common::Error::JsonDecodeError(
17139 encoded.to_string(),
17140 error,
17141 ));
17142 }
17143 }
17144 };
17145
17146 dlg.finished(true);
17147 return Ok(response);
17148 }
17149 }
17150 }
17151 }
17152
17153 ///
17154 /// Sets the *request* property to the given value.
17155 ///
17156 /// Even though the property as already been set when instantiating this call,
17157 /// we provide this method for API completeness.
17158 pub fn request(
17159 mut self,
17160 new_value: SetIamPolicyRequest,
17161 ) -> ProjectTopicSetIamPolicyCall<'a, C> {
17162 self._request = new_value;
17163 self
17164 }
17165 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
17166 ///
17167 /// Sets the *resource* path property to the given value.
17168 ///
17169 /// Even though the property as already been set when instantiating this call,
17170 /// we provide this method for API completeness.
17171 pub fn resource(mut self, new_value: &str) -> ProjectTopicSetIamPolicyCall<'a, C> {
17172 self._resource = new_value.to_string();
17173 self
17174 }
17175 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17176 /// while executing the actual API request.
17177 ///
17178 /// ````text
17179 /// It should be used to handle progress information, and to implement a certain level of resilience.
17180 /// ````
17181 ///
17182 /// Sets the *delegate* property to the given value.
17183 pub fn delegate(
17184 mut self,
17185 new_value: &'a mut dyn common::Delegate,
17186 ) -> ProjectTopicSetIamPolicyCall<'a, C> {
17187 self._delegate = Some(new_value);
17188 self
17189 }
17190
17191 /// Set any additional parameter of the query string used in the request.
17192 /// It should be used to set parameters which are not yet available through their own
17193 /// setters.
17194 ///
17195 /// Please note that this method must not be used to set any of the known parameters
17196 /// which have their own setter method. If done anyway, the request will fail.
17197 ///
17198 /// # Additional Parameters
17199 ///
17200 /// * *$.xgafv* (query-string) - V1 error format.
17201 /// * *access_token* (query-string) - OAuth access token.
17202 /// * *alt* (query-string) - Data format for response.
17203 /// * *callback* (query-string) - JSONP
17204 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17205 /// * *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.
17206 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17207 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17208 /// * *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.
17209 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17210 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17211 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicSetIamPolicyCall<'a, C>
17212 where
17213 T: AsRef<str>,
17214 {
17215 self._additional_params
17216 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17217 self
17218 }
17219
17220 /// Identifies the authorization scope for the method you are building.
17221 ///
17222 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17223 /// [`Scope::CloudPlatform`].
17224 ///
17225 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17226 /// tokens for more than one scope.
17227 ///
17228 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17229 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17230 /// sufficient, a read-write scope will do as well.
17231 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicSetIamPolicyCall<'a, C>
17232 where
17233 St: AsRef<str>,
17234 {
17235 self._scopes.insert(String::from(scope.as_ref()));
17236 self
17237 }
17238 /// Identifies the authorization scope(s) for the method you are building.
17239 ///
17240 /// See [`Self::add_scope()`] for details.
17241 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicSetIamPolicyCall<'a, C>
17242 where
17243 I: IntoIterator<Item = St>,
17244 St: AsRef<str>,
17245 {
17246 self._scopes
17247 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17248 self
17249 }
17250
17251 /// Removes all scopes, and no default scope will be used either.
17252 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17253 /// for details).
17254 pub fn clear_scopes(mut self) -> ProjectTopicSetIamPolicyCall<'a, C> {
17255 self._scopes.clear();
17256 self
17257 }
17258}
17259
17260/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
17261///
17262/// A builder for the *topics.testIamPermissions* method supported by a *project* resource.
17263/// It is not used directly, but through a [`ProjectMethods`] instance.
17264///
17265/// # Example
17266///
17267/// Instantiate a resource method builder
17268///
17269/// ```test_harness,no_run
17270/// # extern crate hyper;
17271/// # extern crate hyper_rustls;
17272/// # extern crate google_pubsub1 as pubsub1;
17273/// use pubsub1::api::TestIamPermissionsRequest;
17274/// # async fn dox() {
17275/// # use pubsub1::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17276///
17277/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17278/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17279/// # .with_native_roots()
17280/// # .unwrap()
17281/// # .https_only()
17282/// # .enable_http2()
17283/// # .build();
17284///
17285/// # let executor = hyper_util::rt::TokioExecutor::new();
17286/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17287/// # secret,
17288/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17289/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17290/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17291/// # ),
17292/// # ).build().await.unwrap();
17293///
17294/// # let client = hyper_util::client::legacy::Client::builder(
17295/// # hyper_util::rt::TokioExecutor::new()
17296/// # )
17297/// # .build(
17298/// # hyper_rustls::HttpsConnectorBuilder::new()
17299/// # .with_native_roots()
17300/// # .unwrap()
17301/// # .https_or_http()
17302/// # .enable_http2()
17303/// # .build()
17304/// # );
17305/// # let mut hub = Pubsub::new(client, auth);
17306/// // As the method needs a request, you would usually fill it with the desired information
17307/// // into the respective structure. Some of the parts shown here might not be applicable !
17308/// // Values shown here are possibly random and not representative !
17309/// let mut req = TestIamPermissionsRequest::default();
17310///
17311/// // You can configure optional parameters by calling the respective setters at will, and
17312/// // execute the final call using `doit()`.
17313/// // Values shown here are possibly random and not representative !
17314/// let result = hub.projects().topics_test_iam_permissions(req, "resource")
17315/// .doit().await;
17316/// # }
17317/// ```
17318pub struct ProjectTopicTestIamPermissionCall<'a, C>
17319where
17320 C: 'a,
17321{
17322 hub: &'a Pubsub<C>,
17323 _request: TestIamPermissionsRequest,
17324 _resource: String,
17325 _delegate: Option<&'a mut dyn common::Delegate>,
17326 _additional_params: HashMap<String, String>,
17327 _scopes: BTreeSet<String>,
17328}
17329
17330impl<'a, C> common::CallBuilder for ProjectTopicTestIamPermissionCall<'a, C> {}
17331
17332impl<'a, C> ProjectTopicTestIamPermissionCall<'a, C>
17333where
17334 C: common::Connector,
17335{
17336 /// Perform the operation you have build so far.
17337 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
17338 use std::borrow::Cow;
17339 use std::io::{Read, Seek};
17340
17341 use common::{url::Params, ToParts};
17342 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17343
17344 let mut dd = common::DefaultDelegate;
17345 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17346 dlg.begin(common::MethodInfo {
17347 id: "pubsub.projects.topics.testIamPermissions",
17348 http_method: hyper::Method::POST,
17349 });
17350
17351 for &field in ["alt", "resource"].iter() {
17352 if self._additional_params.contains_key(field) {
17353 dlg.finished(false);
17354 return Err(common::Error::FieldClash(field));
17355 }
17356 }
17357
17358 let mut params = Params::with_capacity(4 + self._additional_params.len());
17359 params.push("resource", self._resource);
17360
17361 params.extend(self._additional_params.iter());
17362
17363 params.push("alt", "json");
17364 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
17365 if self._scopes.is_empty() {
17366 self._scopes
17367 .insert(Scope::CloudPlatform.as_ref().to_string());
17368 }
17369
17370 #[allow(clippy::single_element_loop)]
17371 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17372 url = params.uri_replacement(url, param_name, find_this, true);
17373 }
17374 {
17375 let to_remove = ["resource"];
17376 params.remove_params(&to_remove);
17377 }
17378
17379 let url = params.parse_with_url(&url);
17380
17381 let mut json_mime_type = mime::APPLICATION_JSON;
17382 let mut request_value_reader = {
17383 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17384 common::remove_json_null_values(&mut value);
17385 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17386 serde_json::to_writer(&mut dst, &value).unwrap();
17387 dst
17388 };
17389 let request_size = request_value_reader
17390 .seek(std::io::SeekFrom::End(0))
17391 .unwrap();
17392 request_value_reader
17393 .seek(std::io::SeekFrom::Start(0))
17394 .unwrap();
17395
17396 loop {
17397 let token = match self
17398 .hub
17399 .auth
17400 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17401 .await
17402 {
17403 Ok(token) => token,
17404 Err(e) => match dlg.token(e) {
17405 Ok(token) => token,
17406 Err(e) => {
17407 dlg.finished(false);
17408 return Err(common::Error::MissingToken(e));
17409 }
17410 },
17411 };
17412 request_value_reader
17413 .seek(std::io::SeekFrom::Start(0))
17414 .unwrap();
17415 let mut req_result = {
17416 let client = &self.hub.client;
17417 dlg.pre_request();
17418 let mut req_builder = hyper::Request::builder()
17419 .method(hyper::Method::POST)
17420 .uri(url.as_str())
17421 .header(USER_AGENT, self.hub._user_agent.clone());
17422
17423 if let Some(token) = token.as_ref() {
17424 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17425 }
17426
17427 let request = req_builder
17428 .header(CONTENT_TYPE, json_mime_type.to_string())
17429 .header(CONTENT_LENGTH, request_size as u64)
17430 .body(common::to_body(
17431 request_value_reader.get_ref().clone().into(),
17432 ));
17433
17434 client.request(request.unwrap()).await
17435 };
17436
17437 match req_result {
17438 Err(err) => {
17439 if let common::Retry::After(d) = dlg.http_error(&err) {
17440 sleep(d).await;
17441 continue;
17442 }
17443 dlg.finished(false);
17444 return Err(common::Error::HttpError(err));
17445 }
17446 Ok(res) => {
17447 let (mut parts, body) = res.into_parts();
17448 let mut body = common::Body::new(body);
17449 if !parts.status.is_success() {
17450 let bytes = common::to_bytes(body).await.unwrap_or_default();
17451 let error = serde_json::from_str(&common::to_string(&bytes));
17452 let response = common::to_response(parts, bytes.into());
17453
17454 if let common::Retry::After(d) =
17455 dlg.http_failure(&response, error.as_ref().ok())
17456 {
17457 sleep(d).await;
17458 continue;
17459 }
17460
17461 dlg.finished(false);
17462
17463 return Err(match error {
17464 Ok(value) => common::Error::BadRequest(value),
17465 _ => common::Error::Failure(response),
17466 });
17467 }
17468 let response = {
17469 let bytes = common::to_bytes(body).await.unwrap_or_default();
17470 let encoded = common::to_string(&bytes);
17471 match serde_json::from_str(&encoded) {
17472 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17473 Err(error) => {
17474 dlg.response_json_decode_error(&encoded, &error);
17475 return Err(common::Error::JsonDecodeError(
17476 encoded.to_string(),
17477 error,
17478 ));
17479 }
17480 }
17481 };
17482
17483 dlg.finished(true);
17484 return Ok(response);
17485 }
17486 }
17487 }
17488 }
17489
17490 ///
17491 /// Sets the *request* property to the given value.
17492 ///
17493 /// Even though the property as already been set when instantiating this call,
17494 /// we provide this method for API completeness.
17495 pub fn request(
17496 mut self,
17497 new_value: TestIamPermissionsRequest,
17498 ) -> ProjectTopicTestIamPermissionCall<'a, C> {
17499 self._request = new_value;
17500 self
17501 }
17502 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
17503 ///
17504 /// Sets the *resource* path property to the given value.
17505 ///
17506 /// Even though the property as already been set when instantiating this call,
17507 /// we provide this method for API completeness.
17508 pub fn resource(mut self, new_value: &str) -> ProjectTopicTestIamPermissionCall<'a, C> {
17509 self._resource = new_value.to_string();
17510 self
17511 }
17512 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17513 /// while executing the actual API request.
17514 ///
17515 /// ````text
17516 /// It should be used to handle progress information, and to implement a certain level of resilience.
17517 /// ````
17518 ///
17519 /// Sets the *delegate* property to the given value.
17520 pub fn delegate(
17521 mut self,
17522 new_value: &'a mut dyn common::Delegate,
17523 ) -> ProjectTopicTestIamPermissionCall<'a, C> {
17524 self._delegate = Some(new_value);
17525 self
17526 }
17527
17528 /// Set any additional parameter of the query string used in the request.
17529 /// It should be used to set parameters which are not yet available through their own
17530 /// setters.
17531 ///
17532 /// Please note that this method must not be used to set any of the known parameters
17533 /// which have their own setter method. If done anyway, the request will fail.
17534 ///
17535 /// # Additional Parameters
17536 ///
17537 /// * *$.xgafv* (query-string) - V1 error format.
17538 /// * *access_token* (query-string) - OAuth access token.
17539 /// * *alt* (query-string) - Data format for response.
17540 /// * *callback* (query-string) - JSONP
17541 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17542 /// * *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.
17543 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17544 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17545 /// * *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.
17546 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17547 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17548 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicTestIamPermissionCall<'a, C>
17549 where
17550 T: AsRef<str>,
17551 {
17552 self._additional_params
17553 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17554 self
17555 }
17556
17557 /// Identifies the authorization scope for the method you are building.
17558 ///
17559 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17560 /// [`Scope::CloudPlatform`].
17561 ///
17562 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17563 /// tokens for more than one scope.
17564 ///
17565 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17566 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17567 /// sufficient, a read-write scope will do as well.
17568 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicTestIamPermissionCall<'a, C>
17569 where
17570 St: AsRef<str>,
17571 {
17572 self._scopes.insert(String::from(scope.as_ref()));
17573 self
17574 }
17575 /// Identifies the authorization scope(s) for the method you are building.
17576 ///
17577 /// See [`Self::add_scope()`] for details.
17578 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicTestIamPermissionCall<'a, C>
17579 where
17580 I: IntoIterator<Item = St>,
17581 St: AsRef<str>,
17582 {
17583 self._scopes
17584 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17585 self
17586 }
17587
17588 /// Removes all scopes, and no default scope will be used either.
17589 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17590 /// for details).
17591 pub fn clear_scopes(mut self) -> ProjectTopicTestIamPermissionCall<'a, C> {
17592 self._scopes.clear();
17593 self
17594 }
17595}