google_pubsub1_beta2/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_beta2 as pubsub1_beta2;
53/// use pubsub1_beta2::api::AcknowledgeRequest;
54/// use pubsub1_beta2::{Result, Error};
55/// # async fn dox() {
56/// use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67/// .with_native_roots()
68/// .unwrap()
69/// .https_only()
70/// .enable_http2()
71/// .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75/// secret,
76/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77/// yup_oauth2::client::CustomHyperClientBuilder::from(
78/// hyper_util::client::legacy::Client::builder(executor).build(connector),
79/// ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83/// hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86/// hyper_rustls::HttpsConnectorBuilder::new()
87/// .with_native_roots()
88/// .unwrap()
89/// .https_or_http()
90/// .enable_http2()
91/// .build()
92/// );
93/// let mut hub = Pubsub::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = AcknowledgeRequest::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.projects().subscriptions_acknowledge(req, "subscription")
103/// .doit().await;
104///
105/// match result {
106/// Err(e) => match e {
107/// // The Error enum provides details about what exactly happened.
108/// // You can also just use its `Debug`, `Display` or `Error` traits
109/// Error::HttpError(_)
110/// |Error::Io(_)
111/// |Error::MissingAPIKey
112/// |Error::MissingToken(_)
113/// |Error::Cancelled
114/// |Error::UploadSizeLimitExceeded(_, _)
115/// |Error::Failure(_)
116/// |Error::BadRequest(_)
117/// |Error::FieldClash(_)
118/// |Error::JsonDecodeError(_, _) => println!("{}", e),
119/// },
120/// Ok(res) => println!("Success: {:?}", res),
121/// }
122/// # }
123/// ```
124#[derive(Clone)]
125pub struct Pubsub<C> {
126 pub client: common::Client<C>,
127 pub auth: Box<dyn common::GetToken>,
128 _user_agent: String,
129 _base_url: String,
130 _root_url: String,
131}
132
133impl<C> common::Hub for Pubsub<C> {}
134
135impl<'a, C> Pubsub<C> {
136 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Pubsub<C> {
137 Pubsub {
138 client,
139 auth: Box::new(auth),
140 _user_agent: "google-api-rust-client/7.0.0".to_string(),
141 _base_url: "https://pubsub.googleapis.com/".to_string(),
142 _root_url: "https://pubsub.googleapis.com/".to_string(),
143 }
144 }
145
146 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147 ProjectMethods { hub: self }
148 }
149
150 /// Set the user-agent header field to use in all requests to the server.
151 /// It defaults to `google-api-rust-client/7.0.0`.
152 ///
153 /// Returns the previously set user-agent.
154 pub fn user_agent(&mut self, agent_name: String) -> String {
155 std::mem::replace(&mut self._user_agent, agent_name)
156 }
157
158 /// Set the base url to use in all requests to the server.
159 /// It defaults to `https://pubsub.googleapis.com/`.
160 ///
161 /// Returns the previously set base url.
162 pub fn base_url(&mut self, new_base_url: String) -> String {
163 std::mem::replace(&mut self._base_url, new_base_url)
164 }
165
166 /// Set the root url to use in all requests to the server.
167 /// It defaults to `https://pubsub.googleapis.com/`.
168 ///
169 /// Returns the previously set root url.
170 pub fn root_url(&mut self, new_root_url: String) -> String {
171 std::mem::replace(&mut self._root_url, new_root_url)
172 }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// Request for the Acknowledge method.
179///
180/// # Activities
181///
182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
184///
185/// * [subscriptions acknowledge projects](ProjectSubscriptionAcknowledgeCall) (request)
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct AcknowledgeRequest {
190 /// The acknowledgment ID for the messages being acknowledged that was returned by the Pub/Sub system in the `Pull` response. Must not be empty.
191 #[serde(rename = "ackIds")]
192 pub ack_ids: Option<Vec<String>>,
193}
194
195impl common::RequestValue for AcknowledgeRequest {}
196
197/// Associates `members`, or principals, with a `role`.
198///
199/// This type is not used in any activity, and only used as *part* of another schema.
200///
201#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
202#[serde_with::serde_as]
203#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
204pub struct Binding {
205 /// 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).
206 pub condition: Option<Expr>,
207 /// 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`.
208 pub members: Option<Vec<String>>,
209 /// 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).
210 pub role: Option<String>,
211}
212
213impl common::Part for Binding {}
214
215/// 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); }
216///
217/// # Activities
218///
219/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
220/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
221///
222/// * [subscriptions acknowledge projects](ProjectSubscriptionAcknowledgeCall) (response)
223/// * [subscriptions delete projects](ProjectSubscriptionDeleteCall) (response)
224/// * [subscriptions modify ack deadline projects](ProjectSubscriptionModifyAckDeadlineCall) (response)
225/// * [subscriptions modify push config projects](ProjectSubscriptionModifyPushConfigCall) (response)
226/// * [topics delete projects](ProjectTopicDeleteCall) (response)
227#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
228#[serde_with::serde_as]
229#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
230pub struct Empty {
231 _never_set: Option<bool>,
232}
233
234impl common::ResponseResult for Empty {}
235
236/// 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.
237///
238/// This type is not used in any activity, and only used as *part* of another schema.
239///
240#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
241#[serde_with::serde_as]
242#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
243pub struct Expr {
244 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
245 pub description: Option<String>,
246 /// Textual representation of an expression in Common Expression Language syntax.
247 pub expression: Option<String>,
248 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
249 pub location: Option<String>,
250 /// 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.
251 pub title: Option<String>,
252}
253
254impl common::Part for Expr {}
255
256/// Response for the `ListSubscriptions` method.
257///
258/// # Activities
259///
260/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
261/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
262///
263/// * [subscriptions list projects](ProjectSubscriptionListCall) (response)
264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
265#[serde_with::serde_as]
266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
267pub struct ListSubscriptionsResponse {
268 /// 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.
269 #[serde(rename = "nextPageToken")]
270 pub next_page_token: Option<String>,
271 /// The subscriptions that match the request.
272 pub subscriptions: Option<Vec<Subscription>>,
273}
274
275impl common::ResponseResult for ListSubscriptionsResponse {}
276
277/// Response for the `ListTopicSubscriptions` method.
278///
279/// # Activities
280///
281/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
282/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
283///
284/// * [topics subscriptions list projects](ProjectTopicSubscriptionListCall) (response)
285#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
286#[serde_with::serde_as]
287#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
288pub struct ListTopicSubscriptionsResponse {
289 /// 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.
290 #[serde(rename = "nextPageToken")]
291 pub next_page_token: Option<String>,
292 /// The names of the subscriptions that match the request.
293 pub subscriptions: Option<Vec<String>>,
294}
295
296impl common::ResponseResult for ListTopicSubscriptionsResponse {}
297
298/// Response for the `ListTopics` method.
299///
300/// # Activities
301///
302/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
303/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
304///
305/// * [topics list projects](ProjectTopicListCall) (response)
306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
307#[serde_with::serde_as]
308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
309pub struct ListTopicsResponse {
310 /// If not empty, indicates that there may be more topics that match the request; this value should be passed in a new `ListTopicsRequest`.
311 #[serde(rename = "nextPageToken")]
312 pub next_page_token: Option<String>,
313 /// The resulting topics.
314 pub topics: Option<Vec<Topic>>,
315}
316
317impl common::ResponseResult for ListTopicsResponse {}
318
319/// Request for the ModifyAckDeadline method.
320///
321/// # Activities
322///
323/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
324/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
325///
326/// * [subscriptions modify ack deadline projects](ProjectSubscriptionModifyAckDeadlineCall) (request)
327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
328#[serde_with::serde_as]
329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
330pub struct ModifyAckDeadlineRequest {
331 /// The new ack deadline with respect to the time this request was sent to the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack deadline will expire 10 seconds after the `ModifyAckDeadline` call was made. Specifying zero may immediately make the message available for another pull request.
332 #[serde(rename = "ackDeadlineSeconds")]
333 pub ack_deadline_seconds: Option<i32>,
334 /// The acknowledgment ID. Either this or ack_ids must be populated, but not both.
335 #[serde(rename = "ackId")]
336 pub ack_id: Option<String>,
337 /// List of acknowledgment IDs.
338 #[serde(rename = "ackIds")]
339 pub ack_ids: Option<Vec<String>>,
340}
341
342impl common::RequestValue for ModifyAckDeadlineRequest {}
343
344/// Request for the ModifyPushConfig method.
345///
346/// # Activities
347///
348/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
349/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
350///
351/// * [subscriptions modify push config projects](ProjectSubscriptionModifyPushConfigCall) (request)
352#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
353#[serde_with::serde_as]
354#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
355pub struct ModifyPushConfigRequest {
356 /// 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` is not called.
357 #[serde(rename = "pushConfig")]
358 pub push_config: Option<PushConfig>,
359}
360
361impl common::RequestValue for ModifyPushConfigRequest {}
362
363/// Contains information needed for generating an [OpenID Connect token](https://developers.google.com/identity/protocols/OpenIDConnect).
364///
365/// This type is not used in any activity, and only used as *part* of another schema.
366///
367#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
368#[serde_with::serde_as]
369#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
370pub struct OidcToken {
371 /// 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.
372 pub audience: Option<String>,
373 /// [Service account email](https://cloud.google.com/iam/docs/service-accounts) to be used for generating the OIDC token. The caller (for CreateSubscription, UpdateSubscription, and ModifyPushConfig RPCs) must have the iam.serviceAccounts.actAs permission for the service account.
374 #[serde(rename = "serviceAccountEmail")]
375 pub service_account_email: Option<String>,
376}
377
378impl common::Part for OidcToken {}
379
380/// 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/).
381///
382/// # Activities
383///
384/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
385/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
386///
387/// * [subscriptions get iam policy projects](ProjectSubscriptionGetIamPolicyCall) (response)
388/// * [subscriptions set iam policy projects](ProjectSubscriptionSetIamPolicyCall) (response)
389/// * [topics get iam policy projects](ProjectTopicGetIamPolicyCall) (response)
390/// * [topics set iam policy projects](ProjectTopicSetIamPolicyCall) (response)
391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
392#[serde_with::serde_as]
393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
394pub struct Policy {
395 /// 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`.
396 pub bindings: Option<Vec<Binding>>,
397 /// `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.
398 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
399 pub etag: Option<Vec<u8>>,
400 /// 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).
401 pub version: Option<i32>,
402}
403
404impl common::ResponseResult for Policy {}
405
406/// Request for the Publish method.
407///
408/// # Activities
409///
410/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
411/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
412///
413/// * [topics publish projects](ProjectTopicPublishCall) (request)
414#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
415#[serde_with::serde_as]
416#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
417pub struct PublishRequest {
418 /// The messages to publish.
419 pub messages: Option<Vec<PubsubMessage>>,
420}
421
422impl common::RequestValue for PublishRequest {}
423
424/// Response for the `Publish` method.
425///
426/// # Activities
427///
428/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
429/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
430///
431/// * [topics publish projects](ProjectTopicPublishCall) (response)
432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
433#[serde_with::serde_as]
434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
435pub struct PublishResponse {
436 /// 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.
437 #[serde(rename = "messageIds")]
438 pub message_ids: Option<Vec<String>>,
439}
440
441impl common::ResponseResult for PublishResponse {}
442
443/// A message data and its attributes. The message payload must not be empty; it must contain either a non-empty data field, or at least one attribute.
444///
445/// This type is not used in any activity, and only used as *part* of another schema.
446///
447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
448#[serde_with::serde_as]
449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
450pub struct PubsubMessage {
451 /// Optional attributes for this message.
452 pub attributes: Option<HashMap<String, String>>,
453 /// The message payload. For JSON requests, the value of this field must be [base64-encoded](https://tools.ietf.org/html/rfc4648).
454 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
455 pub data: Option<Vec<u8>>,
456 /// 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.
457 #[serde(rename = "messageId")]
458 pub message_id: Option<String>,
459 /// 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.
460 #[serde(rename = "publishTime")]
461 pub publish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
462}
463
464impl common::Part for PubsubMessage {}
465
466/// Request for the `Pull` method.
467///
468/// # Activities
469///
470/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
471/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
472///
473/// * [subscriptions pull projects](ProjectSubscriptionPullCall) (request)
474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
475#[serde_with::serde_as]
476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
477pub struct PullRequest {
478 /// The maximum number of messages returned for this request. The Pub/Sub system may return fewer than the number specified.
479 #[serde(rename = "maxMessages")]
480 pub max_messages: Option<i32>,
481 /// Optional. If this is specified as true the system will respond immediately even if it is not able to return a message in the `Pull` response. Otherwise the system is allowed to wait until at least one message is available rather than returning no messages. The client may cancel the request if it does not wish to wait any longer for the response. 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.
482 #[serde(rename = "returnImmediately")]
483 pub return_immediately: Option<bool>,
484}
485
486impl common::RequestValue for PullRequest {}
487
488/// Response for the `Pull` method.
489///
490/// # Activities
491///
492/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
493/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
494///
495/// * [subscriptions pull projects](ProjectSubscriptionPullCall) (response)
496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
497#[serde_with::serde_as]
498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
499pub struct PullResponse {
500 /// Received Pub/Sub messages. The Pub/Sub system will return zero messages if there are no more available in the backlog. The Pub/Sub system may return fewer than the `maxMessages` requested even if there are more messages available in the backlog.
501 #[serde(rename = "receivedMessages")]
502 pub received_messages: Option<Vec<ReceivedMessage>>,
503}
504
505impl common::ResponseResult for PullResponse {}
506
507/// Configuration for a push delivery endpoint.
508///
509/// This type is not used in any activity, and only used as *part* of another schema.
510///
511#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
512#[serde_with::serde_as]
513#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
514pub struct PushConfig {
515 /// Endpoint configuration attributes. Every endpoint has a set of API supported attributes that can be used to control different aspects of the message delivery. The currently supported attribute is `x-goog-version`, which you can use to change the format of the push message. This attribute indicates the version of the data expected by the endpoint. This controls the shape of the envelope (i.e. its fields and metadata). The endpoint version is based on the version of the Pub/Sub API. If not present during the `CreateSubscription` call, it will default to the version of the API used to make such call. If not present during 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 possible values for this 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.
516 pub attributes: Option<HashMap<String, String>>,
517 /// If specified, Pub/Sub will generate and attach an OIDC JWT token as an `Authorization` header in the HTTP request for every pushed message.
518 #[serde(rename = "oidcToken")]
519 pub oidc_token: Option<OidcToken>,
520 /// A URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use "https://example.com/push".
521 #[serde(rename = "pushEndpoint")]
522 pub push_endpoint: Option<String>,
523}
524
525impl common::Part for PushConfig {}
526
527/// A message and its corresponding acknowledgment ID.
528///
529/// This type is not used in any activity, and only used as *part* of another schema.
530///
531#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
532#[serde_with::serde_as]
533#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
534pub struct ReceivedMessage {
535 /// This ID can be used to acknowledge the received message.
536 #[serde(rename = "ackId")]
537 pub ack_id: Option<String>,
538 /// The message.
539 pub message: Option<PubsubMessage>,
540}
541
542impl common::Part for ReceivedMessage {}
543
544/// Request message for `SetIamPolicy` method.
545///
546/// # Activities
547///
548/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
549/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
550///
551/// * [subscriptions set iam policy projects](ProjectSubscriptionSetIamPolicyCall) (request)
552/// * [topics set iam policy projects](ProjectTopicSetIamPolicyCall) (request)
553#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
554#[serde_with::serde_as]
555#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
556pub struct SetIamPolicyRequest {
557 /// 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.
558 pub policy: Option<Policy>,
559}
560
561impl common::RequestValue for SetIamPolicyRequest {}
562
563/// A subscription resource.
564///
565/// # Activities
566///
567/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
568/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
569///
570/// * [subscriptions create projects](ProjectSubscriptionCreateCall) (request|response)
571/// * [subscriptions get projects](ProjectSubscriptionGetCall) (response)
572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
573#[serde_with::serde_as]
574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
575pub struct Subscription {
576 /// This value is the maximum time after a subscriber receives a message before the subscriber should acknowledge the message. After message delivery but before the ack deadline expires and before the message is acknowledged, it is an outstanding message and will not be delivered again during that time (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 pull. The maximum custom deadline you can specify is 600 seconds (10 minutes). 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. If this parameter is 0, a default value of 10 seconds is used.
577 #[serde(rename = "ackDeadlineSeconds")]
578 pub ack_deadline_seconds: Option<i32>,
579 /// 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"`.
580 pub name: Option<String>,
581 /// If push delivery is used with this subscription, this field is used to configure it. An empty `pushConfig` signifies that the subscriber will pull and ack messages using API methods.
582 #[serde(rename = "pushConfig")]
583 pub push_config: Option<PushConfig>,
584 /// The name of the topic from which this subscription is receiving messages. The value of this field will be `_deleted-topic_` if the topic has been deleted.
585 pub topic: Option<String>,
586}
587
588impl common::RequestValue for Subscription {}
589impl common::ResponseResult for Subscription {}
590
591/// Request message for `TestIamPermissions` method.
592///
593/// # Activities
594///
595/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
596/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
597///
598/// * [subscriptions test iam permissions projects](ProjectSubscriptionTestIamPermissionCall) (request)
599/// * [topics test iam permissions projects](ProjectTopicTestIamPermissionCall) (request)
600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
601#[serde_with::serde_as]
602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
603pub struct TestIamPermissionsRequest {
604 /// 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).
605 pub permissions: Option<Vec<String>>,
606}
607
608impl common::RequestValue for TestIamPermissionsRequest {}
609
610/// Response message for `TestIamPermissions` method.
611///
612/// # Activities
613///
614/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
615/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
616///
617/// * [subscriptions test iam permissions projects](ProjectSubscriptionTestIamPermissionCall) (response)
618/// * [topics test iam permissions projects](ProjectTopicTestIamPermissionCall) (response)
619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
620#[serde_with::serde_as]
621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
622pub struct TestIamPermissionsResponse {
623 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
624 pub permissions: Option<Vec<String>>,
625}
626
627impl common::ResponseResult for TestIamPermissionsResponse {}
628
629/// A topic resource.
630///
631/// # Activities
632///
633/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
634/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
635///
636/// * [topics create projects](ProjectTopicCreateCall) (request|response)
637/// * [topics get projects](ProjectTopicGetCall) (response)
638#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
639#[serde_with::serde_as]
640#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
641pub struct Topic {
642 /// 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"`.
643 pub name: Option<String>,
644}
645
646impl common::RequestValue for Topic {}
647impl common::ResponseResult for Topic {}
648
649// ###################
650// MethodBuilders ###
651// #################
652
653/// A builder providing access to all methods supported on *project* resources.
654/// It is not used directly, but through the [`Pubsub`] hub.
655///
656/// # Example
657///
658/// Instantiate a resource builder
659///
660/// ```test_harness,no_run
661/// extern crate hyper;
662/// extern crate hyper_rustls;
663/// extern crate google_pubsub1_beta2 as pubsub1_beta2;
664///
665/// # async fn dox() {
666/// use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
667///
668/// let secret: yup_oauth2::ApplicationSecret = Default::default();
669/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
670/// .with_native_roots()
671/// .unwrap()
672/// .https_only()
673/// .enable_http2()
674/// .build();
675///
676/// let executor = hyper_util::rt::TokioExecutor::new();
677/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
678/// secret,
679/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
680/// yup_oauth2::client::CustomHyperClientBuilder::from(
681/// hyper_util::client::legacy::Client::builder(executor).build(connector),
682/// ),
683/// ).build().await.unwrap();
684///
685/// let client = hyper_util::client::legacy::Client::builder(
686/// hyper_util::rt::TokioExecutor::new()
687/// )
688/// .build(
689/// hyper_rustls::HttpsConnectorBuilder::new()
690/// .with_native_roots()
691/// .unwrap()
692/// .https_or_http()
693/// .enable_http2()
694/// .build()
695/// );
696/// let mut hub = Pubsub::new(client, auth);
697/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
698/// // like `subscriptions_acknowledge(...)`, `subscriptions_create(...)`, `subscriptions_delete(...)`, `subscriptions_get(...)`, `subscriptions_get_iam_policy(...)`, `subscriptions_list(...)`, `subscriptions_modify_ack_deadline(...)`, `subscriptions_modify_push_config(...)`, `subscriptions_pull(...)`, `subscriptions_set_iam_policy(...)`, `subscriptions_test_iam_permissions(...)`, `topics_create(...)`, `topics_delete(...)`, `topics_get(...)`, `topics_get_iam_policy(...)`, `topics_list(...)`, `topics_publish(...)`, `topics_set_iam_policy(...)`, `topics_subscriptions_list(...)` and `topics_test_iam_permissions(...)`
699/// // to build up your call.
700/// let rb = hub.projects();
701/// # }
702/// ```
703pub struct ProjectMethods<'a, C>
704where
705 C: 'a,
706{
707 hub: &'a Pubsub<C>,
708}
709
710impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
711
712impl<'a, C> ProjectMethods<'a, C> {
713 /// Create a builder to help you perform the following task:
714 ///
715 /// 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.
716 ///
717 /// # Arguments
718 ///
719 /// * `request` - No description provided.
720 /// * `subscription` - The subscription whose message is being acknowledged.
721 pub fn subscriptions_acknowledge(
722 &self,
723 request: AcknowledgeRequest,
724 subscription: &str,
725 ) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
726 ProjectSubscriptionAcknowledgeCall {
727 hub: self.hub,
728 _request: request,
729 _subscription: subscription.to_string(),
730 _delegate: Default::default(),
731 _additional_params: Default::default(),
732 _scopes: Default::default(),
733 }
734 }
735
736 /// Create a builder to help you perform the following task:
737 ///
738 /// Creates a subscription to a given topic. 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. Note that for REST API requests, you must specify a name.
739 ///
740 /// # Arguments
741 ///
742 /// * `request` - No description provided.
743 /// * `name` - 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"`.
744 pub fn subscriptions_create(
745 &self,
746 request: Subscription,
747 name: &str,
748 ) -> ProjectSubscriptionCreateCall<'a, C> {
749 ProjectSubscriptionCreateCall {
750 hub: self.hub,
751 _request: request,
752 _name: name.to_string(),
753 _delegate: Default::default(),
754 _additional_params: Default::default(),
755 _scopes: Default::default(),
756 }
757 }
758
759 /// Create a builder to help you perform the following task:
760 ///
761 /// Deletes an existing subscription. All pending messages 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.
762 ///
763 /// # Arguments
764 ///
765 /// * `subscription` - The subscription to delete.
766 pub fn subscriptions_delete(&self, subscription: &str) -> ProjectSubscriptionDeleteCall<'a, C> {
767 ProjectSubscriptionDeleteCall {
768 hub: self.hub,
769 _subscription: subscription.to_string(),
770 _delegate: Default::default(),
771 _additional_params: Default::default(),
772 _scopes: Default::default(),
773 }
774 }
775
776 /// Create a builder to help you perform the following task:
777 ///
778 /// Gets the configuration details of a subscription.
779 ///
780 /// # Arguments
781 ///
782 /// * `subscription` - The name of the subscription to get.
783 pub fn subscriptions_get(&self, subscription: &str) -> ProjectSubscriptionGetCall<'a, C> {
784 ProjectSubscriptionGetCall {
785 hub: self.hub,
786 _subscription: subscription.to_string(),
787 _delegate: Default::default(),
788 _additional_params: Default::default(),
789 _scopes: Default::default(),
790 }
791 }
792
793 /// Create a builder to help you perform the following task:
794 ///
795 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
796 ///
797 /// # Arguments
798 ///
799 /// * `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.
800 pub fn subscriptions_get_iam_policy(
801 &self,
802 resource: &str,
803 ) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
804 ProjectSubscriptionGetIamPolicyCall {
805 hub: self.hub,
806 _resource: resource.to_string(),
807 _options_requested_policy_version: Default::default(),
808 _delegate: Default::default(),
809 _additional_params: Default::default(),
810 _scopes: Default::default(),
811 }
812 }
813
814 /// Create a builder to help you perform the following task:
815 ///
816 /// Lists matching subscriptions.
817 ///
818 /// # Arguments
819 ///
820 /// * `project` - The name of the cloud project that subscriptions belong to.
821 pub fn subscriptions_list(&self, project: &str) -> ProjectSubscriptionListCall<'a, C> {
822 ProjectSubscriptionListCall {
823 hub: self.hub,
824 _project: project.to_string(),
825 _page_token: Default::default(),
826 _page_size: Default::default(),
827 _delegate: Default::default(),
828 _additional_params: Default::default(),
829 _scopes: Default::default(),
830 }
831 }
832
833 /// Create a builder to help you perform the following task:
834 ///
835 /// 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.
836 ///
837 /// # Arguments
838 ///
839 /// * `request` - No description provided.
840 /// * `subscription` - The name of the subscription.
841 pub fn subscriptions_modify_ack_deadline(
842 &self,
843 request: ModifyAckDeadlineRequest,
844 subscription: &str,
845 ) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
846 ProjectSubscriptionModifyAckDeadlineCall {
847 hub: self.hub,
848 _request: request,
849 _subscription: subscription.to_string(),
850 _delegate: Default::default(),
851 _additional_params: Default::default(),
852 _scopes: Default::default(),
853 }
854 }
855
856 /// Create a builder to help you perform the following task:
857 ///
858 /// 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`.
859 ///
860 /// # Arguments
861 ///
862 /// * `request` - No description provided.
863 /// * `subscription` - The name of the subscription.
864 pub fn subscriptions_modify_push_config(
865 &self,
866 request: ModifyPushConfigRequest,
867 subscription: &str,
868 ) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
869 ProjectSubscriptionModifyPushConfigCall {
870 hub: self.hub,
871 _request: request,
872 _subscription: subscription.to_string(),
873 _delegate: Default::default(),
874 _additional_params: Default::default(),
875 _scopes: Default::default(),
876 }
877 }
878
879 /// Create a builder to help you perform the following task:
880 ///
881 /// Pulls messages from the server. Returns an empty list if there are no messages available in the backlog. The server may return `UNAVAILABLE` if there are too many concurrent pull requests pending for the given subscription.
882 ///
883 /// # Arguments
884 ///
885 /// * `request` - No description provided.
886 /// * `subscription` - The subscription from which messages should be pulled.
887 pub fn subscriptions_pull(
888 &self,
889 request: PullRequest,
890 subscription: &str,
891 ) -> ProjectSubscriptionPullCall<'a, C> {
892 ProjectSubscriptionPullCall {
893 hub: self.hub,
894 _request: request,
895 _subscription: subscription.to_string(),
896 _delegate: Default::default(),
897 _additional_params: Default::default(),
898 _scopes: Default::default(),
899 }
900 }
901
902 /// Create a builder to help you perform the following task:
903 ///
904 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
905 ///
906 /// # Arguments
907 ///
908 /// * `request` - No description provided.
909 /// * `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.
910 pub fn subscriptions_set_iam_policy(
911 &self,
912 request: SetIamPolicyRequest,
913 resource: &str,
914 ) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
915 ProjectSubscriptionSetIamPolicyCall {
916 hub: self.hub,
917 _request: request,
918 _resource: resource.to_string(),
919 _delegate: Default::default(),
920 _additional_params: Default::default(),
921 _scopes: Default::default(),
922 }
923 }
924
925 /// Create a builder to help you perform the following task:
926 ///
927 /// 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.
928 ///
929 /// # Arguments
930 ///
931 /// * `request` - No description provided.
932 /// * `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.
933 pub fn subscriptions_test_iam_permissions(
934 &self,
935 request: TestIamPermissionsRequest,
936 resource: &str,
937 ) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
938 ProjectSubscriptionTestIamPermissionCall {
939 hub: self.hub,
940 _request: request,
941 _resource: resource.to_string(),
942 _delegate: Default::default(),
943 _additional_params: Default::default(),
944 _scopes: Default::default(),
945 }
946 }
947
948 /// Create a builder to help you perform the following task:
949 ///
950 /// Lists the name of the subscriptions for this topic.
951 ///
952 /// # Arguments
953 ///
954 /// * `topic` - The name of the topic that subscriptions are attached to.
955 pub fn topics_subscriptions_list(
956 &self,
957 topic: &str,
958 ) -> ProjectTopicSubscriptionListCall<'a, C> {
959 ProjectTopicSubscriptionListCall {
960 hub: self.hub,
961 _topic: topic.to_string(),
962 _page_token: Default::default(),
963 _page_size: Default::default(),
964 _delegate: Default::default(),
965 _additional_params: Default::default(),
966 _scopes: Default::default(),
967 }
968 }
969
970 /// Create a builder to help you perform the following task:
971 ///
972 /// Creates the given topic with the given name.
973 ///
974 /// # Arguments
975 ///
976 /// * `request` - No description provided.
977 /// * `name` - 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"`.
978 pub fn topics_create(&self, request: Topic, name: &str) -> ProjectTopicCreateCall<'a, C> {
979 ProjectTopicCreateCall {
980 hub: self.hub,
981 _request: request,
982 _name: name.to_string(),
983 _delegate: Default::default(),
984 _additional_params: Default::default(),
985 _scopes: Default::default(),
986 }
987 }
988
989 /// Create a builder to help you perform the following task:
990 ///
991 /// 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_`.
992 ///
993 /// # Arguments
994 ///
995 /// * `topic` - Name of the topic to delete.
996 pub fn topics_delete(&self, topic: &str) -> ProjectTopicDeleteCall<'a, C> {
997 ProjectTopicDeleteCall {
998 hub: self.hub,
999 _topic: topic.to_string(),
1000 _delegate: Default::default(),
1001 _additional_params: Default::default(),
1002 _scopes: Default::default(),
1003 }
1004 }
1005
1006 /// Create a builder to help you perform the following task:
1007 ///
1008 /// Gets the configuration of a topic.
1009 ///
1010 /// # Arguments
1011 ///
1012 /// * `topic` - The name of the topic to get.
1013 pub fn topics_get(&self, topic: &str) -> ProjectTopicGetCall<'a, C> {
1014 ProjectTopicGetCall {
1015 hub: self.hub,
1016 _topic: topic.to_string(),
1017 _delegate: Default::default(),
1018 _additional_params: Default::default(),
1019 _scopes: Default::default(),
1020 }
1021 }
1022
1023 /// Create a builder to help you perform the following task:
1024 ///
1025 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1026 ///
1027 /// # Arguments
1028 ///
1029 /// * `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.
1030 pub fn topics_get_iam_policy(&self, resource: &str) -> ProjectTopicGetIamPolicyCall<'a, C> {
1031 ProjectTopicGetIamPolicyCall {
1032 hub: self.hub,
1033 _resource: resource.to_string(),
1034 _options_requested_policy_version: Default::default(),
1035 _delegate: Default::default(),
1036 _additional_params: Default::default(),
1037 _scopes: Default::default(),
1038 }
1039 }
1040
1041 /// Create a builder to help you perform the following task:
1042 ///
1043 /// Lists matching topics.
1044 ///
1045 /// # Arguments
1046 ///
1047 /// * `project` - The name of the cloud project that topics belong to.
1048 pub fn topics_list(&self, project: &str) -> ProjectTopicListCall<'a, C> {
1049 ProjectTopicListCall {
1050 hub: self.hub,
1051 _project: project.to_string(),
1052 _page_token: Default::default(),
1053 _page_size: Default::default(),
1054 _delegate: Default::default(),
1055 _additional_params: Default::default(),
1056 _scopes: Default::default(),
1057 }
1058 }
1059
1060 /// Create a builder to help you perform the following task:
1061 ///
1062 /// Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist. The message payload must not be empty; it must contain either a non-empty data field, or at least one attribute.
1063 ///
1064 /// # Arguments
1065 ///
1066 /// * `request` - No description provided.
1067 /// * `topic` - The messages in the request will be published on this topic.
1068 pub fn topics_publish(
1069 &self,
1070 request: PublishRequest,
1071 topic: &str,
1072 ) -> ProjectTopicPublishCall<'a, C> {
1073 ProjectTopicPublishCall {
1074 hub: self.hub,
1075 _request: request,
1076 _topic: topic.to_string(),
1077 _delegate: Default::default(),
1078 _additional_params: Default::default(),
1079 _scopes: Default::default(),
1080 }
1081 }
1082
1083 /// Create a builder to help you perform the following task:
1084 ///
1085 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
1086 ///
1087 /// # Arguments
1088 ///
1089 /// * `request` - No description provided.
1090 /// * `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.
1091 pub fn topics_set_iam_policy(
1092 &self,
1093 request: SetIamPolicyRequest,
1094 resource: &str,
1095 ) -> ProjectTopicSetIamPolicyCall<'a, C> {
1096 ProjectTopicSetIamPolicyCall {
1097 hub: self.hub,
1098 _request: request,
1099 _resource: resource.to_string(),
1100 _delegate: Default::default(),
1101 _additional_params: Default::default(),
1102 _scopes: Default::default(),
1103 }
1104 }
1105
1106 /// Create a builder to help you perform the following task:
1107 ///
1108 /// 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.
1109 ///
1110 /// # Arguments
1111 ///
1112 /// * `request` - No description provided.
1113 /// * `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.
1114 pub fn topics_test_iam_permissions(
1115 &self,
1116 request: TestIamPermissionsRequest,
1117 resource: &str,
1118 ) -> ProjectTopicTestIamPermissionCall<'a, C> {
1119 ProjectTopicTestIamPermissionCall {
1120 hub: self.hub,
1121 _request: request,
1122 _resource: resource.to_string(),
1123 _delegate: Default::default(),
1124 _additional_params: Default::default(),
1125 _scopes: Default::default(),
1126 }
1127 }
1128}
1129
1130// ###################
1131// CallBuilders ###
1132// #################
1133
1134/// 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.
1135///
1136/// A builder for the *subscriptions.acknowledge* method supported by a *project* resource.
1137/// It is not used directly, but through a [`ProjectMethods`] instance.
1138///
1139/// # Example
1140///
1141/// Instantiate a resource method builder
1142///
1143/// ```test_harness,no_run
1144/// # extern crate hyper;
1145/// # extern crate hyper_rustls;
1146/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
1147/// use pubsub1_beta2::api::AcknowledgeRequest;
1148/// # async fn dox() {
1149/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1150///
1151/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1152/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1153/// # .with_native_roots()
1154/// # .unwrap()
1155/// # .https_only()
1156/// # .enable_http2()
1157/// # .build();
1158///
1159/// # let executor = hyper_util::rt::TokioExecutor::new();
1160/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1161/// # secret,
1162/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1163/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1164/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1165/// # ),
1166/// # ).build().await.unwrap();
1167///
1168/// # let client = hyper_util::client::legacy::Client::builder(
1169/// # hyper_util::rt::TokioExecutor::new()
1170/// # )
1171/// # .build(
1172/// # hyper_rustls::HttpsConnectorBuilder::new()
1173/// # .with_native_roots()
1174/// # .unwrap()
1175/// # .https_or_http()
1176/// # .enable_http2()
1177/// # .build()
1178/// # );
1179/// # let mut hub = Pubsub::new(client, auth);
1180/// // As the method needs a request, you would usually fill it with the desired information
1181/// // into the respective structure. Some of the parts shown here might not be applicable !
1182/// // Values shown here are possibly random and not representative !
1183/// let mut req = AcknowledgeRequest::default();
1184///
1185/// // You can configure optional parameters by calling the respective setters at will, and
1186/// // execute the final call using `doit()`.
1187/// // Values shown here are possibly random and not representative !
1188/// let result = hub.projects().subscriptions_acknowledge(req, "subscription")
1189/// .doit().await;
1190/// # }
1191/// ```
1192pub struct ProjectSubscriptionAcknowledgeCall<'a, C>
1193where
1194 C: 'a,
1195{
1196 hub: &'a Pubsub<C>,
1197 _request: AcknowledgeRequest,
1198 _subscription: String,
1199 _delegate: Option<&'a mut dyn common::Delegate>,
1200 _additional_params: HashMap<String, String>,
1201 _scopes: BTreeSet<String>,
1202}
1203
1204impl<'a, C> common::CallBuilder for ProjectSubscriptionAcknowledgeCall<'a, C> {}
1205
1206impl<'a, C> ProjectSubscriptionAcknowledgeCall<'a, C>
1207where
1208 C: common::Connector,
1209{
1210 /// Perform the operation you have build so far.
1211 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1212 use std::borrow::Cow;
1213 use std::io::{Read, Seek};
1214
1215 use common::{url::Params, ToParts};
1216 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1217
1218 let mut dd = common::DefaultDelegate;
1219 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1220 dlg.begin(common::MethodInfo {
1221 id: "pubsub.projects.subscriptions.acknowledge",
1222 http_method: hyper::Method::POST,
1223 });
1224
1225 for &field in ["alt", "subscription"].iter() {
1226 if self._additional_params.contains_key(field) {
1227 dlg.finished(false);
1228 return Err(common::Error::FieldClash(field));
1229 }
1230 }
1231
1232 let mut params = Params::with_capacity(4 + self._additional_params.len());
1233 params.push("subscription", self._subscription);
1234
1235 params.extend(self._additional_params.iter());
1236
1237 params.push("alt", "json");
1238 let mut url = self.hub._base_url.clone() + "v1beta2/{+subscription}:acknowledge";
1239 if self._scopes.is_empty() {
1240 self._scopes
1241 .insert(Scope::CloudPlatform.as_ref().to_string());
1242 }
1243
1244 #[allow(clippy::single_element_loop)]
1245 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
1246 url = params.uri_replacement(url, param_name, find_this, true);
1247 }
1248 {
1249 let to_remove = ["subscription"];
1250 params.remove_params(&to_remove);
1251 }
1252
1253 let url = params.parse_with_url(&url);
1254
1255 let mut json_mime_type = mime::APPLICATION_JSON;
1256 let mut request_value_reader = {
1257 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1258 common::remove_json_null_values(&mut value);
1259 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1260 serde_json::to_writer(&mut dst, &value).unwrap();
1261 dst
1262 };
1263 let request_size = request_value_reader
1264 .seek(std::io::SeekFrom::End(0))
1265 .unwrap();
1266 request_value_reader
1267 .seek(std::io::SeekFrom::Start(0))
1268 .unwrap();
1269
1270 loop {
1271 let token = match self
1272 .hub
1273 .auth
1274 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1275 .await
1276 {
1277 Ok(token) => token,
1278 Err(e) => match dlg.token(e) {
1279 Ok(token) => token,
1280 Err(e) => {
1281 dlg.finished(false);
1282 return Err(common::Error::MissingToken(e));
1283 }
1284 },
1285 };
1286 request_value_reader
1287 .seek(std::io::SeekFrom::Start(0))
1288 .unwrap();
1289 let mut req_result = {
1290 let client = &self.hub.client;
1291 dlg.pre_request();
1292 let mut req_builder = hyper::Request::builder()
1293 .method(hyper::Method::POST)
1294 .uri(url.as_str())
1295 .header(USER_AGENT, self.hub._user_agent.clone());
1296
1297 if let Some(token) = token.as_ref() {
1298 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1299 }
1300
1301 let request = req_builder
1302 .header(CONTENT_TYPE, json_mime_type.to_string())
1303 .header(CONTENT_LENGTH, request_size as u64)
1304 .body(common::to_body(
1305 request_value_reader.get_ref().clone().into(),
1306 ));
1307
1308 client.request(request.unwrap()).await
1309 };
1310
1311 match req_result {
1312 Err(err) => {
1313 if let common::Retry::After(d) = dlg.http_error(&err) {
1314 sleep(d).await;
1315 continue;
1316 }
1317 dlg.finished(false);
1318 return Err(common::Error::HttpError(err));
1319 }
1320 Ok(res) => {
1321 let (mut parts, body) = res.into_parts();
1322 let mut body = common::Body::new(body);
1323 if !parts.status.is_success() {
1324 let bytes = common::to_bytes(body).await.unwrap_or_default();
1325 let error = serde_json::from_str(&common::to_string(&bytes));
1326 let response = common::to_response(parts, bytes.into());
1327
1328 if let common::Retry::After(d) =
1329 dlg.http_failure(&response, error.as_ref().ok())
1330 {
1331 sleep(d).await;
1332 continue;
1333 }
1334
1335 dlg.finished(false);
1336
1337 return Err(match error {
1338 Ok(value) => common::Error::BadRequest(value),
1339 _ => common::Error::Failure(response),
1340 });
1341 }
1342 let response = {
1343 let bytes = common::to_bytes(body).await.unwrap_or_default();
1344 let encoded = common::to_string(&bytes);
1345 match serde_json::from_str(&encoded) {
1346 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1347 Err(error) => {
1348 dlg.response_json_decode_error(&encoded, &error);
1349 return Err(common::Error::JsonDecodeError(
1350 encoded.to_string(),
1351 error,
1352 ));
1353 }
1354 }
1355 };
1356
1357 dlg.finished(true);
1358 return Ok(response);
1359 }
1360 }
1361 }
1362 }
1363
1364 ///
1365 /// Sets the *request* property to the given value.
1366 ///
1367 /// Even though the property as already been set when instantiating this call,
1368 /// we provide this method for API completeness.
1369 pub fn request(
1370 mut self,
1371 new_value: AcknowledgeRequest,
1372 ) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
1373 self._request = new_value;
1374 self
1375 }
1376 /// The subscription whose message is being acknowledged.
1377 ///
1378 /// Sets the *subscription* path property to the given value.
1379 ///
1380 /// Even though the property as already been set when instantiating this call,
1381 /// we provide this method for API completeness.
1382 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
1383 self._subscription = new_value.to_string();
1384 self
1385 }
1386 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1387 /// while executing the actual API request.
1388 ///
1389 /// ````text
1390 /// It should be used to handle progress information, and to implement a certain level of resilience.
1391 /// ````
1392 ///
1393 /// Sets the *delegate* property to the given value.
1394 pub fn delegate(
1395 mut self,
1396 new_value: &'a mut dyn common::Delegate,
1397 ) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
1398 self._delegate = Some(new_value);
1399 self
1400 }
1401
1402 /// Set any additional parameter of the query string used in the request.
1403 /// It should be used to set parameters which are not yet available through their own
1404 /// setters.
1405 ///
1406 /// Please note that this method must not be used to set any of the known parameters
1407 /// which have their own setter method. If done anyway, the request will fail.
1408 ///
1409 /// # Additional Parameters
1410 ///
1411 /// * *$.xgafv* (query-string) - V1 error format.
1412 /// * *access_token* (query-string) - OAuth access token.
1413 /// * *alt* (query-string) - Data format for response.
1414 /// * *callback* (query-string) - JSONP
1415 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1416 /// * *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.
1417 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1418 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1419 /// * *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.
1420 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1421 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1422 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionAcknowledgeCall<'a, C>
1423 where
1424 T: AsRef<str>,
1425 {
1426 self._additional_params
1427 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1428 self
1429 }
1430
1431 /// Identifies the authorization scope for the method you are building.
1432 ///
1433 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1434 /// [`Scope::CloudPlatform`].
1435 ///
1436 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1437 /// tokens for more than one scope.
1438 ///
1439 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1440 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1441 /// sufficient, a read-write scope will do as well.
1442 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionAcknowledgeCall<'a, C>
1443 where
1444 St: AsRef<str>,
1445 {
1446 self._scopes.insert(String::from(scope.as_ref()));
1447 self
1448 }
1449 /// Identifies the authorization scope(s) for the method you are building.
1450 ///
1451 /// See [`Self::add_scope()`] for details.
1452 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionAcknowledgeCall<'a, C>
1453 where
1454 I: IntoIterator<Item = St>,
1455 St: AsRef<str>,
1456 {
1457 self._scopes
1458 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1459 self
1460 }
1461
1462 /// Removes all scopes, and no default scope will be used either.
1463 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1464 /// for details).
1465 pub fn clear_scopes(mut self) -> ProjectSubscriptionAcknowledgeCall<'a, C> {
1466 self._scopes.clear();
1467 self
1468 }
1469}
1470
1471/// Creates a subscription to a given topic. 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. Note that for REST API requests, you must specify a name.
1472///
1473/// A builder for the *subscriptions.create* method supported by a *project* resource.
1474/// It is not used directly, but through a [`ProjectMethods`] instance.
1475///
1476/// # Example
1477///
1478/// Instantiate a resource method builder
1479///
1480/// ```test_harness,no_run
1481/// # extern crate hyper;
1482/// # extern crate hyper_rustls;
1483/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
1484/// use pubsub1_beta2::api::Subscription;
1485/// # async fn dox() {
1486/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1487///
1488/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1489/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1490/// # .with_native_roots()
1491/// # .unwrap()
1492/// # .https_only()
1493/// # .enable_http2()
1494/// # .build();
1495///
1496/// # let executor = hyper_util::rt::TokioExecutor::new();
1497/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1498/// # secret,
1499/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1500/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1501/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1502/// # ),
1503/// # ).build().await.unwrap();
1504///
1505/// # let client = hyper_util::client::legacy::Client::builder(
1506/// # hyper_util::rt::TokioExecutor::new()
1507/// # )
1508/// # .build(
1509/// # hyper_rustls::HttpsConnectorBuilder::new()
1510/// # .with_native_roots()
1511/// # .unwrap()
1512/// # .https_or_http()
1513/// # .enable_http2()
1514/// # .build()
1515/// # );
1516/// # let mut hub = Pubsub::new(client, auth);
1517/// // As the method needs a request, you would usually fill it with the desired information
1518/// // into the respective structure. Some of the parts shown here might not be applicable !
1519/// // Values shown here are possibly random and not representative !
1520/// let mut req = Subscription::default();
1521///
1522/// // You can configure optional parameters by calling the respective setters at will, and
1523/// // execute the final call using `doit()`.
1524/// // Values shown here are possibly random and not representative !
1525/// let result = hub.projects().subscriptions_create(req, "name")
1526/// .doit().await;
1527/// # }
1528/// ```
1529pub struct ProjectSubscriptionCreateCall<'a, C>
1530where
1531 C: 'a,
1532{
1533 hub: &'a Pubsub<C>,
1534 _request: Subscription,
1535 _name: String,
1536 _delegate: Option<&'a mut dyn common::Delegate>,
1537 _additional_params: HashMap<String, String>,
1538 _scopes: BTreeSet<String>,
1539}
1540
1541impl<'a, C> common::CallBuilder for ProjectSubscriptionCreateCall<'a, C> {}
1542
1543impl<'a, C> ProjectSubscriptionCreateCall<'a, C>
1544where
1545 C: common::Connector,
1546{
1547 /// Perform the operation you have build so far.
1548 pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
1549 use std::borrow::Cow;
1550 use std::io::{Read, Seek};
1551
1552 use common::{url::Params, ToParts};
1553 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1554
1555 let mut dd = common::DefaultDelegate;
1556 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1557 dlg.begin(common::MethodInfo {
1558 id: "pubsub.projects.subscriptions.create",
1559 http_method: hyper::Method::PUT,
1560 });
1561
1562 for &field in ["alt", "name"].iter() {
1563 if self._additional_params.contains_key(field) {
1564 dlg.finished(false);
1565 return Err(common::Error::FieldClash(field));
1566 }
1567 }
1568
1569 let mut params = Params::with_capacity(4 + self._additional_params.len());
1570 params.push("name", self._name);
1571
1572 params.extend(self._additional_params.iter());
1573
1574 params.push("alt", "json");
1575 let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
1576 if self._scopes.is_empty() {
1577 self._scopes
1578 .insert(Scope::CloudPlatform.as_ref().to_string());
1579 }
1580
1581 #[allow(clippy::single_element_loop)]
1582 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1583 url = params.uri_replacement(url, param_name, find_this, true);
1584 }
1585 {
1586 let to_remove = ["name"];
1587 params.remove_params(&to_remove);
1588 }
1589
1590 let url = params.parse_with_url(&url);
1591
1592 let mut json_mime_type = mime::APPLICATION_JSON;
1593 let mut request_value_reader = {
1594 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1595 common::remove_json_null_values(&mut value);
1596 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1597 serde_json::to_writer(&mut dst, &value).unwrap();
1598 dst
1599 };
1600 let request_size = request_value_reader
1601 .seek(std::io::SeekFrom::End(0))
1602 .unwrap();
1603 request_value_reader
1604 .seek(std::io::SeekFrom::Start(0))
1605 .unwrap();
1606
1607 loop {
1608 let token = match self
1609 .hub
1610 .auth
1611 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1612 .await
1613 {
1614 Ok(token) => token,
1615 Err(e) => match dlg.token(e) {
1616 Ok(token) => token,
1617 Err(e) => {
1618 dlg.finished(false);
1619 return Err(common::Error::MissingToken(e));
1620 }
1621 },
1622 };
1623 request_value_reader
1624 .seek(std::io::SeekFrom::Start(0))
1625 .unwrap();
1626 let mut req_result = {
1627 let client = &self.hub.client;
1628 dlg.pre_request();
1629 let mut req_builder = hyper::Request::builder()
1630 .method(hyper::Method::PUT)
1631 .uri(url.as_str())
1632 .header(USER_AGENT, self.hub._user_agent.clone());
1633
1634 if let Some(token) = token.as_ref() {
1635 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1636 }
1637
1638 let request = req_builder
1639 .header(CONTENT_TYPE, json_mime_type.to_string())
1640 .header(CONTENT_LENGTH, request_size as u64)
1641 .body(common::to_body(
1642 request_value_reader.get_ref().clone().into(),
1643 ));
1644
1645 client.request(request.unwrap()).await
1646 };
1647
1648 match req_result {
1649 Err(err) => {
1650 if let common::Retry::After(d) = dlg.http_error(&err) {
1651 sleep(d).await;
1652 continue;
1653 }
1654 dlg.finished(false);
1655 return Err(common::Error::HttpError(err));
1656 }
1657 Ok(res) => {
1658 let (mut parts, body) = res.into_parts();
1659 let mut body = common::Body::new(body);
1660 if !parts.status.is_success() {
1661 let bytes = common::to_bytes(body).await.unwrap_or_default();
1662 let error = serde_json::from_str(&common::to_string(&bytes));
1663 let response = common::to_response(parts, bytes.into());
1664
1665 if let common::Retry::After(d) =
1666 dlg.http_failure(&response, error.as_ref().ok())
1667 {
1668 sleep(d).await;
1669 continue;
1670 }
1671
1672 dlg.finished(false);
1673
1674 return Err(match error {
1675 Ok(value) => common::Error::BadRequest(value),
1676 _ => common::Error::Failure(response),
1677 });
1678 }
1679 let response = {
1680 let bytes = common::to_bytes(body).await.unwrap_or_default();
1681 let encoded = common::to_string(&bytes);
1682 match serde_json::from_str(&encoded) {
1683 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1684 Err(error) => {
1685 dlg.response_json_decode_error(&encoded, &error);
1686 return Err(common::Error::JsonDecodeError(
1687 encoded.to_string(),
1688 error,
1689 ));
1690 }
1691 }
1692 };
1693
1694 dlg.finished(true);
1695 return Ok(response);
1696 }
1697 }
1698 }
1699 }
1700
1701 ///
1702 /// Sets the *request* property to the given value.
1703 ///
1704 /// Even though the property as already been set when instantiating this call,
1705 /// we provide this method for API completeness.
1706 pub fn request(mut self, new_value: Subscription) -> ProjectSubscriptionCreateCall<'a, C> {
1707 self._request = new_value;
1708 self
1709 }
1710 /// 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"`.
1711 ///
1712 /// Sets the *name* path property to the given value.
1713 ///
1714 /// Even though the property as already been set when instantiating this call,
1715 /// we provide this method for API completeness.
1716 pub fn name(mut self, new_value: &str) -> ProjectSubscriptionCreateCall<'a, C> {
1717 self._name = new_value.to_string();
1718 self
1719 }
1720 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1721 /// while executing the actual API request.
1722 ///
1723 /// ````text
1724 /// It should be used to handle progress information, and to implement a certain level of resilience.
1725 /// ````
1726 ///
1727 /// Sets the *delegate* property to the given value.
1728 pub fn delegate(
1729 mut self,
1730 new_value: &'a mut dyn common::Delegate,
1731 ) -> ProjectSubscriptionCreateCall<'a, C> {
1732 self._delegate = Some(new_value);
1733 self
1734 }
1735
1736 /// Set any additional parameter of the query string used in the request.
1737 /// It should be used to set parameters which are not yet available through their own
1738 /// setters.
1739 ///
1740 /// Please note that this method must not be used to set any of the known parameters
1741 /// which have their own setter method. If done anyway, the request will fail.
1742 ///
1743 /// # Additional Parameters
1744 ///
1745 /// * *$.xgafv* (query-string) - V1 error format.
1746 /// * *access_token* (query-string) - OAuth access token.
1747 /// * *alt* (query-string) - Data format for response.
1748 /// * *callback* (query-string) - JSONP
1749 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1750 /// * *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.
1751 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1752 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1753 /// * *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.
1754 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1755 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1756 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionCreateCall<'a, C>
1757 where
1758 T: AsRef<str>,
1759 {
1760 self._additional_params
1761 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1762 self
1763 }
1764
1765 /// Identifies the authorization scope for the method you are building.
1766 ///
1767 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1768 /// [`Scope::CloudPlatform`].
1769 ///
1770 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1771 /// tokens for more than one scope.
1772 ///
1773 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1774 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1775 /// sufficient, a read-write scope will do as well.
1776 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionCreateCall<'a, C>
1777 where
1778 St: AsRef<str>,
1779 {
1780 self._scopes.insert(String::from(scope.as_ref()));
1781 self
1782 }
1783 /// Identifies the authorization scope(s) for the method you are building.
1784 ///
1785 /// See [`Self::add_scope()`] for details.
1786 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionCreateCall<'a, C>
1787 where
1788 I: IntoIterator<Item = St>,
1789 St: AsRef<str>,
1790 {
1791 self._scopes
1792 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1793 self
1794 }
1795
1796 /// Removes all scopes, and no default scope will be used either.
1797 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1798 /// for details).
1799 pub fn clear_scopes(mut self) -> ProjectSubscriptionCreateCall<'a, C> {
1800 self._scopes.clear();
1801 self
1802 }
1803}
1804
1805/// Deletes an existing subscription. All pending messages 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.
1806///
1807/// A builder for the *subscriptions.delete* method supported by a *project* resource.
1808/// It is not used directly, but through a [`ProjectMethods`] instance.
1809///
1810/// # Example
1811///
1812/// Instantiate a resource method builder
1813///
1814/// ```test_harness,no_run
1815/// # extern crate hyper;
1816/// # extern crate hyper_rustls;
1817/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
1818/// # async fn dox() {
1819/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1820///
1821/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1822/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1823/// # .with_native_roots()
1824/// # .unwrap()
1825/// # .https_only()
1826/// # .enable_http2()
1827/// # .build();
1828///
1829/// # let executor = hyper_util::rt::TokioExecutor::new();
1830/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1831/// # secret,
1832/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1833/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1834/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1835/// # ),
1836/// # ).build().await.unwrap();
1837///
1838/// # let client = hyper_util::client::legacy::Client::builder(
1839/// # hyper_util::rt::TokioExecutor::new()
1840/// # )
1841/// # .build(
1842/// # hyper_rustls::HttpsConnectorBuilder::new()
1843/// # .with_native_roots()
1844/// # .unwrap()
1845/// # .https_or_http()
1846/// # .enable_http2()
1847/// # .build()
1848/// # );
1849/// # let mut hub = Pubsub::new(client, auth);
1850/// // You can configure optional parameters by calling the respective setters at will, and
1851/// // execute the final call using `doit()`.
1852/// // Values shown here are possibly random and not representative !
1853/// let result = hub.projects().subscriptions_delete("subscription")
1854/// .doit().await;
1855/// # }
1856/// ```
1857pub struct ProjectSubscriptionDeleteCall<'a, C>
1858where
1859 C: 'a,
1860{
1861 hub: &'a Pubsub<C>,
1862 _subscription: String,
1863 _delegate: Option<&'a mut dyn common::Delegate>,
1864 _additional_params: HashMap<String, String>,
1865 _scopes: BTreeSet<String>,
1866}
1867
1868impl<'a, C> common::CallBuilder for ProjectSubscriptionDeleteCall<'a, C> {}
1869
1870impl<'a, C> ProjectSubscriptionDeleteCall<'a, C>
1871where
1872 C: common::Connector,
1873{
1874 /// Perform the operation you have build so far.
1875 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1876 use std::borrow::Cow;
1877 use std::io::{Read, Seek};
1878
1879 use common::{url::Params, ToParts};
1880 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1881
1882 let mut dd = common::DefaultDelegate;
1883 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1884 dlg.begin(common::MethodInfo {
1885 id: "pubsub.projects.subscriptions.delete",
1886 http_method: hyper::Method::DELETE,
1887 });
1888
1889 for &field in ["alt", "subscription"].iter() {
1890 if self._additional_params.contains_key(field) {
1891 dlg.finished(false);
1892 return Err(common::Error::FieldClash(field));
1893 }
1894 }
1895
1896 let mut params = Params::with_capacity(3 + self._additional_params.len());
1897 params.push("subscription", self._subscription);
1898
1899 params.extend(self._additional_params.iter());
1900
1901 params.push("alt", "json");
1902 let mut url = self.hub._base_url.clone() + "v1beta2/{+subscription}";
1903 if self._scopes.is_empty() {
1904 self._scopes
1905 .insert(Scope::CloudPlatform.as_ref().to_string());
1906 }
1907
1908 #[allow(clippy::single_element_loop)]
1909 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
1910 url = params.uri_replacement(url, param_name, find_this, true);
1911 }
1912 {
1913 let to_remove = ["subscription"];
1914 params.remove_params(&to_remove);
1915 }
1916
1917 let url = params.parse_with_url(&url);
1918
1919 loop {
1920 let token = match self
1921 .hub
1922 .auth
1923 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1924 .await
1925 {
1926 Ok(token) => token,
1927 Err(e) => match dlg.token(e) {
1928 Ok(token) => token,
1929 Err(e) => {
1930 dlg.finished(false);
1931 return Err(common::Error::MissingToken(e));
1932 }
1933 },
1934 };
1935 let mut req_result = {
1936 let client = &self.hub.client;
1937 dlg.pre_request();
1938 let mut req_builder = hyper::Request::builder()
1939 .method(hyper::Method::DELETE)
1940 .uri(url.as_str())
1941 .header(USER_AGENT, self.hub._user_agent.clone());
1942
1943 if let Some(token) = token.as_ref() {
1944 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1945 }
1946
1947 let request = req_builder
1948 .header(CONTENT_LENGTH, 0_u64)
1949 .body(common::to_body::<String>(None));
1950
1951 client.request(request.unwrap()).await
1952 };
1953
1954 match req_result {
1955 Err(err) => {
1956 if let common::Retry::After(d) = dlg.http_error(&err) {
1957 sleep(d).await;
1958 continue;
1959 }
1960 dlg.finished(false);
1961 return Err(common::Error::HttpError(err));
1962 }
1963 Ok(res) => {
1964 let (mut parts, body) = res.into_parts();
1965 let mut body = common::Body::new(body);
1966 if !parts.status.is_success() {
1967 let bytes = common::to_bytes(body).await.unwrap_or_default();
1968 let error = serde_json::from_str(&common::to_string(&bytes));
1969 let response = common::to_response(parts, bytes.into());
1970
1971 if let common::Retry::After(d) =
1972 dlg.http_failure(&response, error.as_ref().ok())
1973 {
1974 sleep(d).await;
1975 continue;
1976 }
1977
1978 dlg.finished(false);
1979
1980 return Err(match error {
1981 Ok(value) => common::Error::BadRequest(value),
1982 _ => common::Error::Failure(response),
1983 });
1984 }
1985 let response = {
1986 let bytes = common::to_bytes(body).await.unwrap_or_default();
1987 let encoded = common::to_string(&bytes);
1988 match serde_json::from_str(&encoded) {
1989 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1990 Err(error) => {
1991 dlg.response_json_decode_error(&encoded, &error);
1992 return Err(common::Error::JsonDecodeError(
1993 encoded.to_string(),
1994 error,
1995 ));
1996 }
1997 }
1998 };
1999
2000 dlg.finished(true);
2001 return Ok(response);
2002 }
2003 }
2004 }
2005 }
2006
2007 /// The subscription to delete.
2008 ///
2009 /// Sets the *subscription* path property to the given value.
2010 ///
2011 /// Even though the property as already been set when instantiating this call,
2012 /// we provide this method for API completeness.
2013 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionDeleteCall<'a, C> {
2014 self._subscription = new_value.to_string();
2015 self
2016 }
2017 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2018 /// while executing the actual API request.
2019 ///
2020 /// ````text
2021 /// It should be used to handle progress information, and to implement a certain level of resilience.
2022 /// ````
2023 ///
2024 /// Sets the *delegate* property to the given value.
2025 pub fn delegate(
2026 mut self,
2027 new_value: &'a mut dyn common::Delegate,
2028 ) -> ProjectSubscriptionDeleteCall<'a, C> {
2029 self._delegate = Some(new_value);
2030 self
2031 }
2032
2033 /// Set any additional parameter of the query string used in the request.
2034 /// It should be used to set parameters which are not yet available through their own
2035 /// setters.
2036 ///
2037 /// Please note that this method must not be used to set any of the known parameters
2038 /// which have their own setter method. If done anyway, the request will fail.
2039 ///
2040 /// # Additional Parameters
2041 ///
2042 /// * *$.xgafv* (query-string) - V1 error format.
2043 /// * *access_token* (query-string) - OAuth access token.
2044 /// * *alt* (query-string) - Data format for response.
2045 /// * *callback* (query-string) - JSONP
2046 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2047 /// * *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.
2048 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2049 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2050 /// * *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.
2051 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2052 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2053 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionDeleteCall<'a, C>
2054 where
2055 T: AsRef<str>,
2056 {
2057 self._additional_params
2058 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2059 self
2060 }
2061
2062 /// Identifies the authorization scope for the method you are building.
2063 ///
2064 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2065 /// [`Scope::CloudPlatform`].
2066 ///
2067 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2068 /// tokens for more than one scope.
2069 ///
2070 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2071 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2072 /// sufficient, a read-write scope will do as well.
2073 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionDeleteCall<'a, C>
2074 where
2075 St: AsRef<str>,
2076 {
2077 self._scopes.insert(String::from(scope.as_ref()));
2078 self
2079 }
2080 /// Identifies the authorization scope(s) for the method you are building.
2081 ///
2082 /// See [`Self::add_scope()`] for details.
2083 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionDeleteCall<'a, C>
2084 where
2085 I: IntoIterator<Item = St>,
2086 St: AsRef<str>,
2087 {
2088 self._scopes
2089 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2090 self
2091 }
2092
2093 /// Removes all scopes, and no default scope will be used either.
2094 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2095 /// for details).
2096 pub fn clear_scopes(mut self) -> ProjectSubscriptionDeleteCall<'a, C> {
2097 self._scopes.clear();
2098 self
2099 }
2100}
2101
2102/// Gets the configuration details of a subscription.
2103///
2104/// A builder for the *subscriptions.get* method supported by a *project* resource.
2105/// It is not used directly, but through a [`ProjectMethods`] instance.
2106///
2107/// # Example
2108///
2109/// Instantiate a resource method builder
2110///
2111/// ```test_harness,no_run
2112/// # extern crate hyper;
2113/// # extern crate hyper_rustls;
2114/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
2115/// # async fn dox() {
2116/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2117///
2118/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2119/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2120/// # .with_native_roots()
2121/// # .unwrap()
2122/// # .https_only()
2123/// # .enable_http2()
2124/// # .build();
2125///
2126/// # let executor = hyper_util::rt::TokioExecutor::new();
2127/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2128/// # secret,
2129/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2130/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2131/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2132/// # ),
2133/// # ).build().await.unwrap();
2134///
2135/// # let client = hyper_util::client::legacy::Client::builder(
2136/// # hyper_util::rt::TokioExecutor::new()
2137/// # )
2138/// # .build(
2139/// # hyper_rustls::HttpsConnectorBuilder::new()
2140/// # .with_native_roots()
2141/// # .unwrap()
2142/// # .https_or_http()
2143/// # .enable_http2()
2144/// # .build()
2145/// # );
2146/// # let mut hub = Pubsub::new(client, auth);
2147/// // You can configure optional parameters by calling the respective setters at will, and
2148/// // execute the final call using `doit()`.
2149/// // Values shown here are possibly random and not representative !
2150/// let result = hub.projects().subscriptions_get("subscription")
2151/// .doit().await;
2152/// # }
2153/// ```
2154pub struct ProjectSubscriptionGetCall<'a, C>
2155where
2156 C: 'a,
2157{
2158 hub: &'a Pubsub<C>,
2159 _subscription: String,
2160 _delegate: Option<&'a mut dyn common::Delegate>,
2161 _additional_params: HashMap<String, String>,
2162 _scopes: BTreeSet<String>,
2163}
2164
2165impl<'a, C> common::CallBuilder for ProjectSubscriptionGetCall<'a, C> {}
2166
2167impl<'a, C> ProjectSubscriptionGetCall<'a, C>
2168where
2169 C: common::Connector,
2170{
2171 /// Perform the operation you have build so far.
2172 pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
2173 use std::borrow::Cow;
2174 use std::io::{Read, Seek};
2175
2176 use common::{url::Params, ToParts};
2177 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2178
2179 let mut dd = common::DefaultDelegate;
2180 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2181 dlg.begin(common::MethodInfo {
2182 id: "pubsub.projects.subscriptions.get",
2183 http_method: hyper::Method::GET,
2184 });
2185
2186 for &field in ["alt", "subscription"].iter() {
2187 if self._additional_params.contains_key(field) {
2188 dlg.finished(false);
2189 return Err(common::Error::FieldClash(field));
2190 }
2191 }
2192
2193 let mut params = Params::with_capacity(3 + self._additional_params.len());
2194 params.push("subscription", self._subscription);
2195
2196 params.extend(self._additional_params.iter());
2197
2198 params.push("alt", "json");
2199 let mut url = self.hub._base_url.clone() + "v1beta2/{+subscription}";
2200 if self._scopes.is_empty() {
2201 self._scopes
2202 .insert(Scope::CloudPlatform.as_ref().to_string());
2203 }
2204
2205 #[allow(clippy::single_element_loop)]
2206 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
2207 url = params.uri_replacement(url, param_name, find_this, true);
2208 }
2209 {
2210 let to_remove = ["subscription"];
2211 params.remove_params(&to_remove);
2212 }
2213
2214 let url = params.parse_with_url(&url);
2215
2216 loop {
2217 let token = match self
2218 .hub
2219 .auth
2220 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2221 .await
2222 {
2223 Ok(token) => token,
2224 Err(e) => match dlg.token(e) {
2225 Ok(token) => token,
2226 Err(e) => {
2227 dlg.finished(false);
2228 return Err(common::Error::MissingToken(e));
2229 }
2230 },
2231 };
2232 let mut req_result = {
2233 let client = &self.hub.client;
2234 dlg.pre_request();
2235 let mut req_builder = hyper::Request::builder()
2236 .method(hyper::Method::GET)
2237 .uri(url.as_str())
2238 .header(USER_AGENT, self.hub._user_agent.clone());
2239
2240 if let Some(token) = token.as_ref() {
2241 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2242 }
2243
2244 let request = req_builder
2245 .header(CONTENT_LENGTH, 0_u64)
2246 .body(common::to_body::<String>(None));
2247
2248 client.request(request.unwrap()).await
2249 };
2250
2251 match req_result {
2252 Err(err) => {
2253 if let common::Retry::After(d) = dlg.http_error(&err) {
2254 sleep(d).await;
2255 continue;
2256 }
2257 dlg.finished(false);
2258 return Err(common::Error::HttpError(err));
2259 }
2260 Ok(res) => {
2261 let (mut parts, body) = res.into_parts();
2262 let mut body = common::Body::new(body);
2263 if !parts.status.is_success() {
2264 let bytes = common::to_bytes(body).await.unwrap_or_default();
2265 let error = serde_json::from_str(&common::to_string(&bytes));
2266 let response = common::to_response(parts, bytes.into());
2267
2268 if let common::Retry::After(d) =
2269 dlg.http_failure(&response, error.as_ref().ok())
2270 {
2271 sleep(d).await;
2272 continue;
2273 }
2274
2275 dlg.finished(false);
2276
2277 return Err(match error {
2278 Ok(value) => common::Error::BadRequest(value),
2279 _ => common::Error::Failure(response),
2280 });
2281 }
2282 let response = {
2283 let bytes = common::to_bytes(body).await.unwrap_or_default();
2284 let encoded = common::to_string(&bytes);
2285 match serde_json::from_str(&encoded) {
2286 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2287 Err(error) => {
2288 dlg.response_json_decode_error(&encoded, &error);
2289 return Err(common::Error::JsonDecodeError(
2290 encoded.to_string(),
2291 error,
2292 ));
2293 }
2294 }
2295 };
2296
2297 dlg.finished(true);
2298 return Ok(response);
2299 }
2300 }
2301 }
2302 }
2303
2304 /// The name of the subscription to get.
2305 ///
2306 /// Sets the *subscription* path property to the given value.
2307 ///
2308 /// Even though the property as already been set when instantiating this call,
2309 /// we provide this method for API completeness.
2310 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionGetCall<'a, C> {
2311 self._subscription = new_value.to_string();
2312 self
2313 }
2314 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2315 /// while executing the actual API request.
2316 ///
2317 /// ````text
2318 /// It should be used to handle progress information, and to implement a certain level of resilience.
2319 /// ````
2320 ///
2321 /// Sets the *delegate* property to the given value.
2322 pub fn delegate(
2323 mut self,
2324 new_value: &'a mut dyn common::Delegate,
2325 ) -> ProjectSubscriptionGetCall<'a, C> {
2326 self._delegate = Some(new_value);
2327 self
2328 }
2329
2330 /// Set any additional parameter of the query string used in the request.
2331 /// It should be used to set parameters which are not yet available through their own
2332 /// setters.
2333 ///
2334 /// Please note that this method must not be used to set any of the known parameters
2335 /// which have their own setter method. If done anyway, the request will fail.
2336 ///
2337 /// # Additional Parameters
2338 ///
2339 /// * *$.xgafv* (query-string) - V1 error format.
2340 /// * *access_token* (query-string) - OAuth access token.
2341 /// * *alt* (query-string) - Data format for response.
2342 /// * *callback* (query-string) - JSONP
2343 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2344 /// * *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.
2345 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2346 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2347 /// * *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.
2348 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2349 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2350 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionGetCall<'a, C>
2351 where
2352 T: AsRef<str>,
2353 {
2354 self._additional_params
2355 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2356 self
2357 }
2358
2359 /// Identifies the authorization scope for the method you are building.
2360 ///
2361 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2362 /// [`Scope::CloudPlatform`].
2363 ///
2364 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2365 /// tokens for more than one scope.
2366 ///
2367 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2368 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2369 /// sufficient, a read-write scope will do as well.
2370 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionGetCall<'a, C>
2371 where
2372 St: AsRef<str>,
2373 {
2374 self._scopes.insert(String::from(scope.as_ref()));
2375 self
2376 }
2377 /// Identifies the authorization scope(s) for the method you are building.
2378 ///
2379 /// See [`Self::add_scope()`] for details.
2380 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionGetCall<'a, C>
2381 where
2382 I: IntoIterator<Item = St>,
2383 St: AsRef<str>,
2384 {
2385 self._scopes
2386 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2387 self
2388 }
2389
2390 /// Removes all scopes, and no default scope will be used either.
2391 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2392 /// for details).
2393 pub fn clear_scopes(mut self) -> ProjectSubscriptionGetCall<'a, C> {
2394 self._scopes.clear();
2395 self
2396 }
2397}
2398
2399/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2400///
2401/// A builder for the *subscriptions.getIamPolicy* method supported by a *project* resource.
2402/// It is not used directly, but through a [`ProjectMethods`] instance.
2403///
2404/// # Example
2405///
2406/// Instantiate a resource method builder
2407///
2408/// ```test_harness,no_run
2409/// # extern crate hyper;
2410/// # extern crate hyper_rustls;
2411/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
2412/// # async fn dox() {
2413/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2414///
2415/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2416/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2417/// # .with_native_roots()
2418/// # .unwrap()
2419/// # .https_only()
2420/// # .enable_http2()
2421/// # .build();
2422///
2423/// # let executor = hyper_util::rt::TokioExecutor::new();
2424/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2425/// # secret,
2426/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2427/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2428/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2429/// # ),
2430/// # ).build().await.unwrap();
2431///
2432/// # let client = hyper_util::client::legacy::Client::builder(
2433/// # hyper_util::rt::TokioExecutor::new()
2434/// # )
2435/// # .build(
2436/// # hyper_rustls::HttpsConnectorBuilder::new()
2437/// # .with_native_roots()
2438/// # .unwrap()
2439/// # .https_or_http()
2440/// # .enable_http2()
2441/// # .build()
2442/// # );
2443/// # let mut hub = Pubsub::new(client, auth);
2444/// // You can configure optional parameters by calling the respective setters at will, and
2445/// // execute the final call using `doit()`.
2446/// // Values shown here are possibly random and not representative !
2447/// let result = hub.projects().subscriptions_get_iam_policy("resource")
2448/// .options_requested_policy_version(-2)
2449/// .doit().await;
2450/// # }
2451/// ```
2452pub struct ProjectSubscriptionGetIamPolicyCall<'a, C>
2453where
2454 C: 'a,
2455{
2456 hub: &'a Pubsub<C>,
2457 _resource: String,
2458 _options_requested_policy_version: Option<i32>,
2459 _delegate: Option<&'a mut dyn common::Delegate>,
2460 _additional_params: HashMap<String, String>,
2461 _scopes: BTreeSet<String>,
2462}
2463
2464impl<'a, C> common::CallBuilder for ProjectSubscriptionGetIamPolicyCall<'a, C> {}
2465
2466impl<'a, C> ProjectSubscriptionGetIamPolicyCall<'a, C>
2467where
2468 C: common::Connector,
2469{
2470 /// Perform the operation you have build so far.
2471 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
2472 use std::borrow::Cow;
2473 use std::io::{Read, Seek};
2474
2475 use common::{url::Params, ToParts};
2476 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2477
2478 let mut dd = common::DefaultDelegate;
2479 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2480 dlg.begin(common::MethodInfo {
2481 id: "pubsub.projects.subscriptions.getIamPolicy",
2482 http_method: hyper::Method::GET,
2483 });
2484
2485 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
2486 if self._additional_params.contains_key(field) {
2487 dlg.finished(false);
2488 return Err(common::Error::FieldClash(field));
2489 }
2490 }
2491
2492 let mut params = Params::with_capacity(4 + self._additional_params.len());
2493 params.push("resource", self._resource);
2494 if let Some(value) = self._options_requested_policy_version.as_ref() {
2495 params.push("options.requestedPolicyVersion", value.to_string());
2496 }
2497
2498 params.extend(self._additional_params.iter());
2499
2500 params.push("alt", "json");
2501 let mut url = self.hub._base_url.clone() + "v1beta2/{+resource}:getIamPolicy";
2502 if self._scopes.is_empty() {
2503 self._scopes
2504 .insert(Scope::CloudPlatform.as_ref().to_string());
2505 }
2506
2507 #[allow(clippy::single_element_loop)]
2508 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2509 url = params.uri_replacement(url, param_name, find_this, true);
2510 }
2511 {
2512 let to_remove = ["resource"];
2513 params.remove_params(&to_remove);
2514 }
2515
2516 let url = params.parse_with_url(&url);
2517
2518 loop {
2519 let token = match self
2520 .hub
2521 .auth
2522 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2523 .await
2524 {
2525 Ok(token) => token,
2526 Err(e) => match dlg.token(e) {
2527 Ok(token) => token,
2528 Err(e) => {
2529 dlg.finished(false);
2530 return Err(common::Error::MissingToken(e));
2531 }
2532 },
2533 };
2534 let mut req_result = {
2535 let client = &self.hub.client;
2536 dlg.pre_request();
2537 let mut req_builder = hyper::Request::builder()
2538 .method(hyper::Method::GET)
2539 .uri(url.as_str())
2540 .header(USER_AGENT, self.hub._user_agent.clone());
2541
2542 if let Some(token) = token.as_ref() {
2543 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2544 }
2545
2546 let request = req_builder
2547 .header(CONTENT_LENGTH, 0_u64)
2548 .body(common::to_body::<String>(None));
2549
2550 client.request(request.unwrap()).await
2551 };
2552
2553 match req_result {
2554 Err(err) => {
2555 if let common::Retry::After(d) = dlg.http_error(&err) {
2556 sleep(d).await;
2557 continue;
2558 }
2559 dlg.finished(false);
2560 return Err(common::Error::HttpError(err));
2561 }
2562 Ok(res) => {
2563 let (mut parts, body) = res.into_parts();
2564 let mut body = common::Body::new(body);
2565 if !parts.status.is_success() {
2566 let bytes = common::to_bytes(body).await.unwrap_or_default();
2567 let error = serde_json::from_str(&common::to_string(&bytes));
2568 let response = common::to_response(parts, bytes.into());
2569
2570 if let common::Retry::After(d) =
2571 dlg.http_failure(&response, error.as_ref().ok())
2572 {
2573 sleep(d).await;
2574 continue;
2575 }
2576
2577 dlg.finished(false);
2578
2579 return Err(match error {
2580 Ok(value) => common::Error::BadRequest(value),
2581 _ => common::Error::Failure(response),
2582 });
2583 }
2584 let response = {
2585 let bytes = common::to_bytes(body).await.unwrap_or_default();
2586 let encoded = common::to_string(&bytes);
2587 match serde_json::from_str(&encoded) {
2588 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2589 Err(error) => {
2590 dlg.response_json_decode_error(&encoded, &error);
2591 return Err(common::Error::JsonDecodeError(
2592 encoded.to_string(),
2593 error,
2594 ));
2595 }
2596 }
2597 };
2598
2599 dlg.finished(true);
2600 return Ok(response);
2601 }
2602 }
2603 }
2604 }
2605
2606 /// 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.
2607 ///
2608 /// Sets the *resource* path property to the given value.
2609 ///
2610 /// Even though the property as already been set when instantiating this call,
2611 /// we provide this method for API completeness.
2612 pub fn resource(mut self, new_value: &str) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
2613 self._resource = new_value.to_string();
2614 self
2615 }
2616 /// 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).
2617 ///
2618 /// Sets the *options.requested policy version* query property to the given value.
2619 pub fn options_requested_policy_version(
2620 mut self,
2621 new_value: i32,
2622 ) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
2623 self._options_requested_policy_version = Some(new_value);
2624 self
2625 }
2626 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2627 /// while executing the actual API request.
2628 ///
2629 /// ````text
2630 /// It should be used to handle progress information, and to implement a certain level of resilience.
2631 /// ````
2632 ///
2633 /// Sets the *delegate* property to the given value.
2634 pub fn delegate(
2635 mut self,
2636 new_value: &'a mut dyn common::Delegate,
2637 ) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
2638 self._delegate = Some(new_value);
2639 self
2640 }
2641
2642 /// Set any additional parameter of the query string used in the request.
2643 /// It should be used to set parameters which are not yet available through their own
2644 /// setters.
2645 ///
2646 /// Please note that this method must not be used to set any of the known parameters
2647 /// which have their own setter method. If done anyway, the request will fail.
2648 ///
2649 /// # Additional Parameters
2650 ///
2651 /// * *$.xgafv* (query-string) - V1 error format.
2652 /// * *access_token* (query-string) - OAuth access token.
2653 /// * *alt* (query-string) - Data format for response.
2654 /// * *callback* (query-string) - JSONP
2655 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2656 /// * *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.
2657 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2658 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2659 /// * *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.
2660 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2661 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2662 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionGetIamPolicyCall<'a, C>
2663 where
2664 T: AsRef<str>,
2665 {
2666 self._additional_params
2667 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2668 self
2669 }
2670
2671 /// Identifies the authorization scope for the method you are building.
2672 ///
2673 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2674 /// [`Scope::CloudPlatform`].
2675 ///
2676 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2677 /// tokens for more than one scope.
2678 ///
2679 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2680 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2681 /// sufficient, a read-write scope will do as well.
2682 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionGetIamPolicyCall<'a, C>
2683 where
2684 St: AsRef<str>,
2685 {
2686 self._scopes.insert(String::from(scope.as_ref()));
2687 self
2688 }
2689 /// Identifies the authorization scope(s) for the method you are building.
2690 ///
2691 /// See [`Self::add_scope()`] for details.
2692 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionGetIamPolicyCall<'a, C>
2693 where
2694 I: IntoIterator<Item = St>,
2695 St: AsRef<str>,
2696 {
2697 self._scopes
2698 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2699 self
2700 }
2701
2702 /// Removes all scopes, and no default scope will be used either.
2703 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2704 /// for details).
2705 pub fn clear_scopes(mut self) -> ProjectSubscriptionGetIamPolicyCall<'a, C> {
2706 self._scopes.clear();
2707 self
2708 }
2709}
2710
2711/// Lists matching subscriptions.
2712///
2713/// A builder for the *subscriptions.list* method supported by a *project* resource.
2714/// It is not used directly, but through a [`ProjectMethods`] instance.
2715///
2716/// # Example
2717///
2718/// Instantiate a resource method builder
2719///
2720/// ```test_harness,no_run
2721/// # extern crate hyper;
2722/// # extern crate hyper_rustls;
2723/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
2724/// # async fn dox() {
2725/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2726///
2727/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2728/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2729/// # .with_native_roots()
2730/// # .unwrap()
2731/// # .https_only()
2732/// # .enable_http2()
2733/// # .build();
2734///
2735/// # let executor = hyper_util::rt::TokioExecutor::new();
2736/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2737/// # secret,
2738/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2739/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2740/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2741/// # ),
2742/// # ).build().await.unwrap();
2743///
2744/// # let client = hyper_util::client::legacy::Client::builder(
2745/// # hyper_util::rt::TokioExecutor::new()
2746/// # )
2747/// # .build(
2748/// # hyper_rustls::HttpsConnectorBuilder::new()
2749/// # .with_native_roots()
2750/// # .unwrap()
2751/// # .https_or_http()
2752/// # .enable_http2()
2753/// # .build()
2754/// # );
2755/// # let mut hub = Pubsub::new(client, auth);
2756/// // You can configure optional parameters by calling the respective setters at will, and
2757/// // execute the final call using `doit()`.
2758/// // Values shown here are possibly random and not representative !
2759/// let result = hub.projects().subscriptions_list("project")
2760/// .page_token("amet.")
2761/// .page_size(-20)
2762/// .doit().await;
2763/// # }
2764/// ```
2765pub struct ProjectSubscriptionListCall<'a, C>
2766where
2767 C: 'a,
2768{
2769 hub: &'a Pubsub<C>,
2770 _project: String,
2771 _page_token: Option<String>,
2772 _page_size: Option<i32>,
2773 _delegate: Option<&'a mut dyn common::Delegate>,
2774 _additional_params: HashMap<String, String>,
2775 _scopes: BTreeSet<String>,
2776}
2777
2778impl<'a, C> common::CallBuilder for ProjectSubscriptionListCall<'a, C> {}
2779
2780impl<'a, C> ProjectSubscriptionListCall<'a, C>
2781where
2782 C: common::Connector,
2783{
2784 /// Perform the operation you have build so far.
2785 pub async fn doit(mut self) -> common::Result<(common::Response, ListSubscriptionsResponse)> {
2786 use std::borrow::Cow;
2787 use std::io::{Read, Seek};
2788
2789 use common::{url::Params, ToParts};
2790 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2791
2792 let mut dd = common::DefaultDelegate;
2793 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2794 dlg.begin(common::MethodInfo {
2795 id: "pubsub.projects.subscriptions.list",
2796 http_method: hyper::Method::GET,
2797 });
2798
2799 for &field in ["alt", "project", "pageToken", "pageSize"].iter() {
2800 if self._additional_params.contains_key(field) {
2801 dlg.finished(false);
2802 return Err(common::Error::FieldClash(field));
2803 }
2804 }
2805
2806 let mut params = Params::with_capacity(5 + self._additional_params.len());
2807 params.push("project", self._project);
2808 if let Some(value) = self._page_token.as_ref() {
2809 params.push("pageToken", value);
2810 }
2811 if let Some(value) = self._page_size.as_ref() {
2812 params.push("pageSize", value.to_string());
2813 }
2814
2815 params.extend(self._additional_params.iter());
2816
2817 params.push("alt", "json");
2818 let mut url = self.hub._base_url.clone() + "v1beta2/{+project}/subscriptions";
2819 if self._scopes.is_empty() {
2820 self._scopes
2821 .insert(Scope::CloudPlatform.as_ref().to_string());
2822 }
2823
2824 #[allow(clippy::single_element_loop)]
2825 for &(find_this, param_name) in [("{+project}", "project")].iter() {
2826 url = params.uri_replacement(url, param_name, find_this, true);
2827 }
2828 {
2829 let to_remove = ["project"];
2830 params.remove_params(&to_remove);
2831 }
2832
2833 let url = params.parse_with_url(&url);
2834
2835 loop {
2836 let token = match self
2837 .hub
2838 .auth
2839 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2840 .await
2841 {
2842 Ok(token) => token,
2843 Err(e) => match dlg.token(e) {
2844 Ok(token) => token,
2845 Err(e) => {
2846 dlg.finished(false);
2847 return Err(common::Error::MissingToken(e));
2848 }
2849 },
2850 };
2851 let mut req_result = {
2852 let client = &self.hub.client;
2853 dlg.pre_request();
2854 let mut req_builder = hyper::Request::builder()
2855 .method(hyper::Method::GET)
2856 .uri(url.as_str())
2857 .header(USER_AGENT, self.hub._user_agent.clone());
2858
2859 if let Some(token) = token.as_ref() {
2860 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2861 }
2862
2863 let request = req_builder
2864 .header(CONTENT_LENGTH, 0_u64)
2865 .body(common::to_body::<String>(None));
2866
2867 client.request(request.unwrap()).await
2868 };
2869
2870 match req_result {
2871 Err(err) => {
2872 if let common::Retry::After(d) = dlg.http_error(&err) {
2873 sleep(d).await;
2874 continue;
2875 }
2876 dlg.finished(false);
2877 return Err(common::Error::HttpError(err));
2878 }
2879 Ok(res) => {
2880 let (mut parts, body) = res.into_parts();
2881 let mut body = common::Body::new(body);
2882 if !parts.status.is_success() {
2883 let bytes = common::to_bytes(body).await.unwrap_or_default();
2884 let error = serde_json::from_str(&common::to_string(&bytes));
2885 let response = common::to_response(parts, bytes.into());
2886
2887 if let common::Retry::After(d) =
2888 dlg.http_failure(&response, error.as_ref().ok())
2889 {
2890 sleep(d).await;
2891 continue;
2892 }
2893
2894 dlg.finished(false);
2895
2896 return Err(match error {
2897 Ok(value) => common::Error::BadRequest(value),
2898 _ => common::Error::Failure(response),
2899 });
2900 }
2901 let response = {
2902 let bytes = common::to_bytes(body).await.unwrap_or_default();
2903 let encoded = common::to_string(&bytes);
2904 match serde_json::from_str(&encoded) {
2905 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2906 Err(error) => {
2907 dlg.response_json_decode_error(&encoded, &error);
2908 return Err(common::Error::JsonDecodeError(
2909 encoded.to_string(),
2910 error,
2911 ));
2912 }
2913 }
2914 };
2915
2916 dlg.finished(true);
2917 return Ok(response);
2918 }
2919 }
2920 }
2921 }
2922
2923 /// The name of the cloud project that subscriptions belong to.
2924 ///
2925 /// Sets the *project* path property to the given value.
2926 ///
2927 /// Even though the property as already been set when instantiating this call,
2928 /// we provide this method for API completeness.
2929 pub fn project(mut self, new_value: &str) -> ProjectSubscriptionListCall<'a, C> {
2930 self._project = new_value.to_string();
2931 self
2932 }
2933 /// 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.
2934 ///
2935 /// Sets the *page token* query property to the given value.
2936 pub fn page_token(mut self, new_value: &str) -> ProjectSubscriptionListCall<'a, C> {
2937 self._page_token = Some(new_value.to_string());
2938 self
2939 }
2940 /// Maximum number of subscriptions to return.
2941 ///
2942 /// Sets the *page size* query property to the given value.
2943 pub fn page_size(mut self, new_value: i32) -> ProjectSubscriptionListCall<'a, C> {
2944 self._page_size = Some(new_value);
2945 self
2946 }
2947 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2948 /// while executing the actual API request.
2949 ///
2950 /// ````text
2951 /// It should be used to handle progress information, and to implement a certain level of resilience.
2952 /// ````
2953 ///
2954 /// Sets the *delegate* property to the given value.
2955 pub fn delegate(
2956 mut self,
2957 new_value: &'a mut dyn common::Delegate,
2958 ) -> ProjectSubscriptionListCall<'a, C> {
2959 self._delegate = Some(new_value);
2960 self
2961 }
2962
2963 /// Set any additional parameter of the query string used in the request.
2964 /// It should be used to set parameters which are not yet available through their own
2965 /// setters.
2966 ///
2967 /// Please note that this method must not be used to set any of the known parameters
2968 /// which have their own setter method. If done anyway, the request will fail.
2969 ///
2970 /// # Additional Parameters
2971 ///
2972 /// * *$.xgafv* (query-string) - V1 error format.
2973 /// * *access_token* (query-string) - OAuth access token.
2974 /// * *alt* (query-string) - Data format for response.
2975 /// * *callback* (query-string) - JSONP
2976 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2977 /// * *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.
2978 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2979 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2980 /// * *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.
2981 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2982 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2983 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionListCall<'a, C>
2984 where
2985 T: AsRef<str>,
2986 {
2987 self._additional_params
2988 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2989 self
2990 }
2991
2992 /// Identifies the authorization scope for the method you are building.
2993 ///
2994 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2995 /// [`Scope::CloudPlatform`].
2996 ///
2997 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2998 /// tokens for more than one scope.
2999 ///
3000 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3001 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3002 /// sufficient, a read-write scope will do as well.
3003 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionListCall<'a, C>
3004 where
3005 St: AsRef<str>,
3006 {
3007 self._scopes.insert(String::from(scope.as_ref()));
3008 self
3009 }
3010 /// Identifies the authorization scope(s) for the method you are building.
3011 ///
3012 /// See [`Self::add_scope()`] for details.
3013 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionListCall<'a, C>
3014 where
3015 I: IntoIterator<Item = St>,
3016 St: AsRef<str>,
3017 {
3018 self._scopes
3019 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3020 self
3021 }
3022
3023 /// Removes all scopes, and no default scope will be used either.
3024 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3025 /// for details).
3026 pub fn clear_scopes(mut self) -> ProjectSubscriptionListCall<'a, C> {
3027 self._scopes.clear();
3028 self
3029 }
3030}
3031
3032/// 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.
3033///
3034/// A builder for the *subscriptions.modifyAckDeadline* method supported by a *project* resource.
3035/// It is not used directly, but through a [`ProjectMethods`] instance.
3036///
3037/// # Example
3038///
3039/// Instantiate a resource method builder
3040///
3041/// ```test_harness,no_run
3042/// # extern crate hyper;
3043/// # extern crate hyper_rustls;
3044/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
3045/// use pubsub1_beta2::api::ModifyAckDeadlineRequest;
3046/// # async fn dox() {
3047/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3048///
3049/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3050/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3051/// # .with_native_roots()
3052/// # .unwrap()
3053/// # .https_only()
3054/// # .enable_http2()
3055/// # .build();
3056///
3057/// # let executor = hyper_util::rt::TokioExecutor::new();
3058/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3059/// # secret,
3060/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3061/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3062/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3063/// # ),
3064/// # ).build().await.unwrap();
3065///
3066/// # let client = hyper_util::client::legacy::Client::builder(
3067/// # hyper_util::rt::TokioExecutor::new()
3068/// # )
3069/// # .build(
3070/// # hyper_rustls::HttpsConnectorBuilder::new()
3071/// # .with_native_roots()
3072/// # .unwrap()
3073/// # .https_or_http()
3074/// # .enable_http2()
3075/// # .build()
3076/// # );
3077/// # let mut hub = Pubsub::new(client, auth);
3078/// // As the method needs a request, you would usually fill it with the desired information
3079/// // into the respective structure. Some of the parts shown here might not be applicable !
3080/// // Values shown here are possibly random and not representative !
3081/// let mut req = ModifyAckDeadlineRequest::default();
3082///
3083/// // You can configure optional parameters by calling the respective setters at will, and
3084/// // execute the final call using `doit()`.
3085/// // Values shown here are possibly random and not representative !
3086/// let result = hub.projects().subscriptions_modify_ack_deadline(req, "subscription")
3087/// .doit().await;
3088/// # }
3089/// ```
3090pub struct ProjectSubscriptionModifyAckDeadlineCall<'a, C>
3091where
3092 C: 'a,
3093{
3094 hub: &'a Pubsub<C>,
3095 _request: ModifyAckDeadlineRequest,
3096 _subscription: String,
3097 _delegate: Option<&'a mut dyn common::Delegate>,
3098 _additional_params: HashMap<String, String>,
3099 _scopes: BTreeSet<String>,
3100}
3101
3102impl<'a, C> common::CallBuilder for ProjectSubscriptionModifyAckDeadlineCall<'a, C> {}
3103
3104impl<'a, C> ProjectSubscriptionModifyAckDeadlineCall<'a, C>
3105where
3106 C: common::Connector,
3107{
3108 /// Perform the operation you have build so far.
3109 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3110 use std::borrow::Cow;
3111 use std::io::{Read, Seek};
3112
3113 use common::{url::Params, ToParts};
3114 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3115
3116 let mut dd = common::DefaultDelegate;
3117 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3118 dlg.begin(common::MethodInfo {
3119 id: "pubsub.projects.subscriptions.modifyAckDeadline",
3120 http_method: hyper::Method::POST,
3121 });
3122
3123 for &field in ["alt", "subscription"].iter() {
3124 if self._additional_params.contains_key(field) {
3125 dlg.finished(false);
3126 return Err(common::Error::FieldClash(field));
3127 }
3128 }
3129
3130 let mut params = Params::with_capacity(4 + self._additional_params.len());
3131 params.push("subscription", self._subscription);
3132
3133 params.extend(self._additional_params.iter());
3134
3135 params.push("alt", "json");
3136 let mut url = self.hub._base_url.clone() + "v1beta2/{+subscription}:modifyAckDeadline";
3137 if self._scopes.is_empty() {
3138 self._scopes
3139 .insert(Scope::CloudPlatform.as_ref().to_string());
3140 }
3141
3142 #[allow(clippy::single_element_loop)]
3143 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
3144 url = params.uri_replacement(url, param_name, find_this, true);
3145 }
3146 {
3147 let to_remove = ["subscription"];
3148 params.remove_params(&to_remove);
3149 }
3150
3151 let url = params.parse_with_url(&url);
3152
3153 let mut json_mime_type = mime::APPLICATION_JSON;
3154 let mut request_value_reader = {
3155 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3156 common::remove_json_null_values(&mut value);
3157 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3158 serde_json::to_writer(&mut dst, &value).unwrap();
3159 dst
3160 };
3161 let request_size = request_value_reader
3162 .seek(std::io::SeekFrom::End(0))
3163 .unwrap();
3164 request_value_reader
3165 .seek(std::io::SeekFrom::Start(0))
3166 .unwrap();
3167
3168 loop {
3169 let token = match self
3170 .hub
3171 .auth
3172 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3173 .await
3174 {
3175 Ok(token) => token,
3176 Err(e) => match dlg.token(e) {
3177 Ok(token) => token,
3178 Err(e) => {
3179 dlg.finished(false);
3180 return Err(common::Error::MissingToken(e));
3181 }
3182 },
3183 };
3184 request_value_reader
3185 .seek(std::io::SeekFrom::Start(0))
3186 .unwrap();
3187 let mut req_result = {
3188 let client = &self.hub.client;
3189 dlg.pre_request();
3190 let mut req_builder = hyper::Request::builder()
3191 .method(hyper::Method::POST)
3192 .uri(url.as_str())
3193 .header(USER_AGENT, self.hub._user_agent.clone());
3194
3195 if let Some(token) = token.as_ref() {
3196 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3197 }
3198
3199 let request = req_builder
3200 .header(CONTENT_TYPE, json_mime_type.to_string())
3201 .header(CONTENT_LENGTH, request_size as u64)
3202 .body(common::to_body(
3203 request_value_reader.get_ref().clone().into(),
3204 ));
3205
3206 client.request(request.unwrap()).await
3207 };
3208
3209 match req_result {
3210 Err(err) => {
3211 if let common::Retry::After(d) = dlg.http_error(&err) {
3212 sleep(d).await;
3213 continue;
3214 }
3215 dlg.finished(false);
3216 return Err(common::Error::HttpError(err));
3217 }
3218 Ok(res) => {
3219 let (mut parts, body) = res.into_parts();
3220 let mut body = common::Body::new(body);
3221 if !parts.status.is_success() {
3222 let bytes = common::to_bytes(body).await.unwrap_or_default();
3223 let error = serde_json::from_str(&common::to_string(&bytes));
3224 let response = common::to_response(parts, bytes.into());
3225
3226 if let common::Retry::After(d) =
3227 dlg.http_failure(&response, error.as_ref().ok())
3228 {
3229 sleep(d).await;
3230 continue;
3231 }
3232
3233 dlg.finished(false);
3234
3235 return Err(match error {
3236 Ok(value) => common::Error::BadRequest(value),
3237 _ => common::Error::Failure(response),
3238 });
3239 }
3240 let response = {
3241 let bytes = common::to_bytes(body).await.unwrap_or_default();
3242 let encoded = common::to_string(&bytes);
3243 match serde_json::from_str(&encoded) {
3244 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3245 Err(error) => {
3246 dlg.response_json_decode_error(&encoded, &error);
3247 return Err(common::Error::JsonDecodeError(
3248 encoded.to_string(),
3249 error,
3250 ));
3251 }
3252 }
3253 };
3254
3255 dlg.finished(true);
3256 return Ok(response);
3257 }
3258 }
3259 }
3260 }
3261
3262 ///
3263 /// Sets the *request* property to the given value.
3264 ///
3265 /// Even though the property as already been set when instantiating this call,
3266 /// we provide this method for API completeness.
3267 pub fn request(
3268 mut self,
3269 new_value: ModifyAckDeadlineRequest,
3270 ) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
3271 self._request = new_value;
3272 self
3273 }
3274 /// The name of the subscription.
3275 ///
3276 /// Sets the *subscription* path property to the given value.
3277 ///
3278 /// Even though the property as already been set when instantiating this call,
3279 /// we provide this method for API completeness.
3280 pub fn subscription(
3281 mut self,
3282 new_value: &str,
3283 ) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
3284 self._subscription = new_value.to_string();
3285 self
3286 }
3287 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3288 /// while executing the actual API request.
3289 ///
3290 /// ````text
3291 /// It should be used to handle progress information, and to implement a certain level of resilience.
3292 /// ````
3293 ///
3294 /// Sets the *delegate* property to the given value.
3295 pub fn delegate(
3296 mut self,
3297 new_value: &'a mut dyn common::Delegate,
3298 ) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
3299 self._delegate = Some(new_value);
3300 self
3301 }
3302
3303 /// Set any additional parameter of the query string used in the request.
3304 /// It should be used to set parameters which are not yet available through their own
3305 /// setters.
3306 ///
3307 /// Please note that this method must not be used to set any of the known parameters
3308 /// which have their own setter method. If done anyway, the request will fail.
3309 ///
3310 /// # Additional Parameters
3311 ///
3312 /// * *$.xgafv* (query-string) - V1 error format.
3313 /// * *access_token* (query-string) - OAuth access token.
3314 /// * *alt* (query-string) - Data format for response.
3315 /// * *callback* (query-string) - JSONP
3316 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3317 /// * *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.
3318 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3319 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3320 /// * *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.
3321 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3322 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3323 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C>
3324 where
3325 T: AsRef<str>,
3326 {
3327 self._additional_params
3328 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3329 self
3330 }
3331
3332 /// Identifies the authorization scope for the method you are building.
3333 ///
3334 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3335 /// [`Scope::CloudPlatform`].
3336 ///
3337 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3338 /// tokens for more than one scope.
3339 ///
3340 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3341 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3342 /// sufficient, a read-write scope will do as well.
3343 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C>
3344 where
3345 St: AsRef<str>,
3346 {
3347 self._scopes.insert(String::from(scope.as_ref()));
3348 self
3349 }
3350 /// Identifies the authorization scope(s) for the method you are building.
3351 ///
3352 /// See [`Self::add_scope()`] for details.
3353 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C>
3354 where
3355 I: IntoIterator<Item = St>,
3356 St: AsRef<str>,
3357 {
3358 self._scopes
3359 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3360 self
3361 }
3362
3363 /// Removes all scopes, and no default scope will be used either.
3364 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3365 /// for details).
3366 pub fn clear_scopes(mut self) -> ProjectSubscriptionModifyAckDeadlineCall<'a, C> {
3367 self._scopes.clear();
3368 self
3369 }
3370}
3371
3372/// 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`.
3373///
3374/// A builder for the *subscriptions.modifyPushConfig* method supported by a *project* resource.
3375/// It is not used directly, but through a [`ProjectMethods`] instance.
3376///
3377/// # Example
3378///
3379/// Instantiate a resource method builder
3380///
3381/// ```test_harness,no_run
3382/// # extern crate hyper;
3383/// # extern crate hyper_rustls;
3384/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
3385/// use pubsub1_beta2::api::ModifyPushConfigRequest;
3386/// # async fn dox() {
3387/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3388///
3389/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3390/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3391/// # .with_native_roots()
3392/// # .unwrap()
3393/// # .https_only()
3394/// # .enable_http2()
3395/// # .build();
3396///
3397/// # let executor = hyper_util::rt::TokioExecutor::new();
3398/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3399/// # secret,
3400/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3401/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3402/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3403/// # ),
3404/// # ).build().await.unwrap();
3405///
3406/// # let client = hyper_util::client::legacy::Client::builder(
3407/// # hyper_util::rt::TokioExecutor::new()
3408/// # )
3409/// # .build(
3410/// # hyper_rustls::HttpsConnectorBuilder::new()
3411/// # .with_native_roots()
3412/// # .unwrap()
3413/// # .https_or_http()
3414/// # .enable_http2()
3415/// # .build()
3416/// # );
3417/// # let mut hub = Pubsub::new(client, auth);
3418/// // As the method needs a request, you would usually fill it with the desired information
3419/// // into the respective structure. Some of the parts shown here might not be applicable !
3420/// // Values shown here are possibly random and not representative !
3421/// let mut req = ModifyPushConfigRequest::default();
3422///
3423/// // You can configure optional parameters by calling the respective setters at will, and
3424/// // execute the final call using `doit()`.
3425/// // Values shown here are possibly random and not representative !
3426/// let result = hub.projects().subscriptions_modify_push_config(req, "subscription")
3427/// .doit().await;
3428/// # }
3429/// ```
3430pub struct ProjectSubscriptionModifyPushConfigCall<'a, C>
3431where
3432 C: 'a,
3433{
3434 hub: &'a Pubsub<C>,
3435 _request: ModifyPushConfigRequest,
3436 _subscription: String,
3437 _delegate: Option<&'a mut dyn common::Delegate>,
3438 _additional_params: HashMap<String, String>,
3439 _scopes: BTreeSet<String>,
3440}
3441
3442impl<'a, C> common::CallBuilder for ProjectSubscriptionModifyPushConfigCall<'a, C> {}
3443
3444impl<'a, C> ProjectSubscriptionModifyPushConfigCall<'a, C>
3445where
3446 C: common::Connector,
3447{
3448 /// Perform the operation you have build so far.
3449 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3450 use std::borrow::Cow;
3451 use std::io::{Read, Seek};
3452
3453 use common::{url::Params, ToParts};
3454 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3455
3456 let mut dd = common::DefaultDelegate;
3457 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3458 dlg.begin(common::MethodInfo {
3459 id: "pubsub.projects.subscriptions.modifyPushConfig",
3460 http_method: hyper::Method::POST,
3461 });
3462
3463 for &field in ["alt", "subscription"].iter() {
3464 if self._additional_params.contains_key(field) {
3465 dlg.finished(false);
3466 return Err(common::Error::FieldClash(field));
3467 }
3468 }
3469
3470 let mut params = Params::with_capacity(4 + self._additional_params.len());
3471 params.push("subscription", self._subscription);
3472
3473 params.extend(self._additional_params.iter());
3474
3475 params.push("alt", "json");
3476 let mut url = self.hub._base_url.clone() + "v1beta2/{+subscription}:modifyPushConfig";
3477 if self._scopes.is_empty() {
3478 self._scopes
3479 .insert(Scope::CloudPlatform.as_ref().to_string());
3480 }
3481
3482 #[allow(clippy::single_element_loop)]
3483 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
3484 url = params.uri_replacement(url, param_name, find_this, true);
3485 }
3486 {
3487 let to_remove = ["subscription"];
3488 params.remove_params(&to_remove);
3489 }
3490
3491 let url = params.parse_with_url(&url);
3492
3493 let mut json_mime_type = mime::APPLICATION_JSON;
3494 let mut request_value_reader = {
3495 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3496 common::remove_json_null_values(&mut value);
3497 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3498 serde_json::to_writer(&mut dst, &value).unwrap();
3499 dst
3500 };
3501 let request_size = request_value_reader
3502 .seek(std::io::SeekFrom::End(0))
3503 .unwrap();
3504 request_value_reader
3505 .seek(std::io::SeekFrom::Start(0))
3506 .unwrap();
3507
3508 loop {
3509 let token = match self
3510 .hub
3511 .auth
3512 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3513 .await
3514 {
3515 Ok(token) => token,
3516 Err(e) => match dlg.token(e) {
3517 Ok(token) => token,
3518 Err(e) => {
3519 dlg.finished(false);
3520 return Err(common::Error::MissingToken(e));
3521 }
3522 },
3523 };
3524 request_value_reader
3525 .seek(std::io::SeekFrom::Start(0))
3526 .unwrap();
3527 let mut req_result = {
3528 let client = &self.hub.client;
3529 dlg.pre_request();
3530 let mut req_builder = hyper::Request::builder()
3531 .method(hyper::Method::POST)
3532 .uri(url.as_str())
3533 .header(USER_AGENT, self.hub._user_agent.clone());
3534
3535 if let Some(token) = token.as_ref() {
3536 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3537 }
3538
3539 let request = req_builder
3540 .header(CONTENT_TYPE, json_mime_type.to_string())
3541 .header(CONTENT_LENGTH, request_size as u64)
3542 .body(common::to_body(
3543 request_value_reader.get_ref().clone().into(),
3544 ));
3545
3546 client.request(request.unwrap()).await
3547 };
3548
3549 match req_result {
3550 Err(err) => {
3551 if let common::Retry::After(d) = dlg.http_error(&err) {
3552 sleep(d).await;
3553 continue;
3554 }
3555 dlg.finished(false);
3556 return Err(common::Error::HttpError(err));
3557 }
3558 Ok(res) => {
3559 let (mut parts, body) = res.into_parts();
3560 let mut body = common::Body::new(body);
3561 if !parts.status.is_success() {
3562 let bytes = common::to_bytes(body).await.unwrap_or_default();
3563 let error = serde_json::from_str(&common::to_string(&bytes));
3564 let response = common::to_response(parts, bytes.into());
3565
3566 if let common::Retry::After(d) =
3567 dlg.http_failure(&response, error.as_ref().ok())
3568 {
3569 sleep(d).await;
3570 continue;
3571 }
3572
3573 dlg.finished(false);
3574
3575 return Err(match error {
3576 Ok(value) => common::Error::BadRequest(value),
3577 _ => common::Error::Failure(response),
3578 });
3579 }
3580 let response = {
3581 let bytes = common::to_bytes(body).await.unwrap_or_default();
3582 let encoded = common::to_string(&bytes);
3583 match serde_json::from_str(&encoded) {
3584 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3585 Err(error) => {
3586 dlg.response_json_decode_error(&encoded, &error);
3587 return Err(common::Error::JsonDecodeError(
3588 encoded.to_string(),
3589 error,
3590 ));
3591 }
3592 }
3593 };
3594
3595 dlg.finished(true);
3596 return Ok(response);
3597 }
3598 }
3599 }
3600 }
3601
3602 ///
3603 /// Sets the *request* property to the given value.
3604 ///
3605 /// Even though the property as already been set when instantiating this call,
3606 /// we provide this method for API completeness.
3607 pub fn request(
3608 mut self,
3609 new_value: ModifyPushConfigRequest,
3610 ) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
3611 self._request = new_value;
3612 self
3613 }
3614 /// The name of the subscription.
3615 ///
3616 /// Sets the *subscription* path property to the given value.
3617 ///
3618 /// Even though the property as already been set when instantiating this call,
3619 /// we provide this method for API completeness.
3620 pub fn subscription(
3621 mut self,
3622 new_value: &str,
3623 ) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
3624 self._subscription = new_value.to_string();
3625 self
3626 }
3627 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3628 /// while executing the actual API request.
3629 ///
3630 /// ````text
3631 /// It should be used to handle progress information, and to implement a certain level of resilience.
3632 /// ````
3633 ///
3634 /// Sets the *delegate* property to the given value.
3635 pub fn delegate(
3636 mut self,
3637 new_value: &'a mut dyn common::Delegate,
3638 ) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
3639 self._delegate = Some(new_value);
3640 self
3641 }
3642
3643 /// Set any additional parameter of the query string used in the request.
3644 /// It should be used to set parameters which are not yet available through their own
3645 /// setters.
3646 ///
3647 /// Please note that this method must not be used to set any of the known parameters
3648 /// which have their own setter method. If done anyway, the request will fail.
3649 ///
3650 /// # Additional Parameters
3651 ///
3652 /// * *$.xgafv* (query-string) - V1 error format.
3653 /// * *access_token* (query-string) - OAuth access token.
3654 /// * *alt* (query-string) - Data format for response.
3655 /// * *callback* (query-string) - JSONP
3656 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3657 /// * *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.
3658 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3659 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3660 /// * *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.
3661 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3662 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3663 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionModifyPushConfigCall<'a, C>
3664 where
3665 T: AsRef<str>,
3666 {
3667 self._additional_params
3668 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3669 self
3670 }
3671
3672 /// Identifies the authorization scope for the method you are building.
3673 ///
3674 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3675 /// [`Scope::CloudPlatform`].
3676 ///
3677 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3678 /// tokens for more than one scope.
3679 ///
3680 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3681 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3682 /// sufficient, a read-write scope will do as well.
3683 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionModifyPushConfigCall<'a, C>
3684 where
3685 St: AsRef<str>,
3686 {
3687 self._scopes.insert(String::from(scope.as_ref()));
3688 self
3689 }
3690 /// Identifies the authorization scope(s) for the method you are building.
3691 ///
3692 /// See [`Self::add_scope()`] for details.
3693 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionModifyPushConfigCall<'a, C>
3694 where
3695 I: IntoIterator<Item = St>,
3696 St: AsRef<str>,
3697 {
3698 self._scopes
3699 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3700 self
3701 }
3702
3703 /// Removes all scopes, and no default scope will be used either.
3704 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3705 /// for details).
3706 pub fn clear_scopes(mut self) -> ProjectSubscriptionModifyPushConfigCall<'a, C> {
3707 self._scopes.clear();
3708 self
3709 }
3710}
3711
3712/// Pulls messages from the server. Returns an empty list if there are no messages available in the backlog. The server may return `UNAVAILABLE` if there are too many concurrent pull requests pending for the given subscription.
3713///
3714/// A builder for the *subscriptions.pull* method supported by a *project* resource.
3715/// It is not used directly, but through a [`ProjectMethods`] instance.
3716///
3717/// # Example
3718///
3719/// Instantiate a resource method builder
3720///
3721/// ```test_harness,no_run
3722/// # extern crate hyper;
3723/// # extern crate hyper_rustls;
3724/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
3725/// use pubsub1_beta2::api::PullRequest;
3726/// # async fn dox() {
3727/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3728///
3729/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3730/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3731/// # .with_native_roots()
3732/// # .unwrap()
3733/// # .https_only()
3734/// # .enable_http2()
3735/// # .build();
3736///
3737/// # let executor = hyper_util::rt::TokioExecutor::new();
3738/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3739/// # secret,
3740/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3741/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3742/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3743/// # ),
3744/// # ).build().await.unwrap();
3745///
3746/// # let client = hyper_util::client::legacy::Client::builder(
3747/// # hyper_util::rt::TokioExecutor::new()
3748/// # )
3749/// # .build(
3750/// # hyper_rustls::HttpsConnectorBuilder::new()
3751/// # .with_native_roots()
3752/// # .unwrap()
3753/// # .https_or_http()
3754/// # .enable_http2()
3755/// # .build()
3756/// # );
3757/// # let mut hub = Pubsub::new(client, auth);
3758/// // As the method needs a request, you would usually fill it with the desired information
3759/// // into the respective structure. Some of the parts shown here might not be applicable !
3760/// // Values shown here are possibly random and not representative !
3761/// let mut req = PullRequest::default();
3762///
3763/// // You can configure optional parameters by calling the respective setters at will, and
3764/// // execute the final call using `doit()`.
3765/// // Values shown here are possibly random and not representative !
3766/// let result = hub.projects().subscriptions_pull(req, "subscription")
3767/// .doit().await;
3768/// # }
3769/// ```
3770pub struct ProjectSubscriptionPullCall<'a, C>
3771where
3772 C: 'a,
3773{
3774 hub: &'a Pubsub<C>,
3775 _request: PullRequest,
3776 _subscription: String,
3777 _delegate: Option<&'a mut dyn common::Delegate>,
3778 _additional_params: HashMap<String, String>,
3779 _scopes: BTreeSet<String>,
3780}
3781
3782impl<'a, C> common::CallBuilder for ProjectSubscriptionPullCall<'a, C> {}
3783
3784impl<'a, C> ProjectSubscriptionPullCall<'a, C>
3785where
3786 C: common::Connector,
3787{
3788 /// Perform the operation you have build so far.
3789 pub async fn doit(mut self) -> common::Result<(common::Response, PullResponse)> {
3790 use std::borrow::Cow;
3791 use std::io::{Read, Seek};
3792
3793 use common::{url::Params, ToParts};
3794 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3795
3796 let mut dd = common::DefaultDelegate;
3797 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3798 dlg.begin(common::MethodInfo {
3799 id: "pubsub.projects.subscriptions.pull",
3800 http_method: hyper::Method::POST,
3801 });
3802
3803 for &field in ["alt", "subscription"].iter() {
3804 if self._additional_params.contains_key(field) {
3805 dlg.finished(false);
3806 return Err(common::Error::FieldClash(field));
3807 }
3808 }
3809
3810 let mut params = Params::with_capacity(4 + self._additional_params.len());
3811 params.push("subscription", self._subscription);
3812
3813 params.extend(self._additional_params.iter());
3814
3815 params.push("alt", "json");
3816 let mut url = self.hub._base_url.clone() + "v1beta2/{+subscription}:pull";
3817 if self._scopes.is_empty() {
3818 self._scopes
3819 .insert(Scope::CloudPlatform.as_ref().to_string());
3820 }
3821
3822 #[allow(clippy::single_element_loop)]
3823 for &(find_this, param_name) in [("{+subscription}", "subscription")].iter() {
3824 url = params.uri_replacement(url, param_name, find_this, true);
3825 }
3826 {
3827 let to_remove = ["subscription"];
3828 params.remove_params(&to_remove);
3829 }
3830
3831 let url = params.parse_with_url(&url);
3832
3833 let mut json_mime_type = mime::APPLICATION_JSON;
3834 let mut request_value_reader = {
3835 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3836 common::remove_json_null_values(&mut value);
3837 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3838 serde_json::to_writer(&mut dst, &value).unwrap();
3839 dst
3840 };
3841 let request_size = request_value_reader
3842 .seek(std::io::SeekFrom::End(0))
3843 .unwrap();
3844 request_value_reader
3845 .seek(std::io::SeekFrom::Start(0))
3846 .unwrap();
3847
3848 loop {
3849 let token = match self
3850 .hub
3851 .auth
3852 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3853 .await
3854 {
3855 Ok(token) => token,
3856 Err(e) => match dlg.token(e) {
3857 Ok(token) => token,
3858 Err(e) => {
3859 dlg.finished(false);
3860 return Err(common::Error::MissingToken(e));
3861 }
3862 },
3863 };
3864 request_value_reader
3865 .seek(std::io::SeekFrom::Start(0))
3866 .unwrap();
3867 let mut req_result = {
3868 let client = &self.hub.client;
3869 dlg.pre_request();
3870 let mut req_builder = hyper::Request::builder()
3871 .method(hyper::Method::POST)
3872 .uri(url.as_str())
3873 .header(USER_AGENT, self.hub._user_agent.clone());
3874
3875 if let Some(token) = token.as_ref() {
3876 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3877 }
3878
3879 let request = req_builder
3880 .header(CONTENT_TYPE, json_mime_type.to_string())
3881 .header(CONTENT_LENGTH, request_size as u64)
3882 .body(common::to_body(
3883 request_value_reader.get_ref().clone().into(),
3884 ));
3885
3886 client.request(request.unwrap()).await
3887 };
3888
3889 match req_result {
3890 Err(err) => {
3891 if let common::Retry::After(d) = dlg.http_error(&err) {
3892 sleep(d).await;
3893 continue;
3894 }
3895 dlg.finished(false);
3896 return Err(common::Error::HttpError(err));
3897 }
3898 Ok(res) => {
3899 let (mut parts, body) = res.into_parts();
3900 let mut body = common::Body::new(body);
3901 if !parts.status.is_success() {
3902 let bytes = common::to_bytes(body).await.unwrap_or_default();
3903 let error = serde_json::from_str(&common::to_string(&bytes));
3904 let response = common::to_response(parts, bytes.into());
3905
3906 if let common::Retry::After(d) =
3907 dlg.http_failure(&response, error.as_ref().ok())
3908 {
3909 sleep(d).await;
3910 continue;
3911 }
3912
3913 dlg.finished(false);
3914
3915 return Err(match error {
3916 Ok(value) => common::Error::BadRequest(value),
3917 _ => common::Error::Failure(response),
3918 });
3919 }
3920 let response = {
3921 let bytes = common::to_bytes(body).await.unwrap_or_default();
3922 let encoded = common::to_string(&bytes);
3923 match serde_json::from_str(&encoded) {
3924 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3925 Err(error) => {
3926 dlg.response_json_decode_error(&encoded, &error);
3927 return Err(common::Error::JsonDecodeError(
3928 encoded.to_string(),
3929 error,
3930 ));
3931 }
3932 }
3933 };
3934
3935 dlg.finished(true);
3936 return Ok(response);
3937 }
3938 }
3939 }
3940 }
3941
3942 ///
3943 /// Sets the *request* property to the given value.
3944 ///
3945 /// Even though the property as already been set when instantiating this call,
3946 /// we provide this method for API completeness.
3947 pub fn request(mut self, new_value: PullRequest) -> ProjectSubscriptionPullCall<'a, C> {
3948 self._request = new_value;
3949 self
3950 }
3951 /// The subscription from which messages should be pulled.
3952 ///
3953 /// Sets the *subscription* path property to the given value.
3954 ///
3955 /// Even though the property as already been set when instantiating this call,
3956 /// we provide this method for API completeness.
3957 pub fn subscription(mut self, new_value: &str) -> ProjectSubscriptionPullCall<'a, C> {
3958 self._subscription = new_value.to_string();
3959 self
3960 }
3961 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3962 /// while executing the actual API request.
3963 ///
3964 /// ````text
3965 /// It should be used to handle progress information, and to implement a certain level of resilience.
3966 /// ````
3967 ///
3968 /// Sets the *delegate* property to the given value.
3969 pub fn delegate(
3970 mut self,
3971 new_value: &'a mut dyn common::Delegate,
3972 ) -> ProjectSubscriptionPullCall<'a, C> {
3973 self._delegate = Some(new_value);
3974 self
3975 }
3976
3977 /// Set any additional parameter of the query string used in the request.
3978 /// It should be used to set parameters which are not yet available through their own
3979 /// setters.
3980 ///
3981 /// Please note that this method must not be used to set any of the known parameters
3982 /// which have their own setter method. If done anyway, the request will fail.
3983 ///
3984 /// # Additional Parameters
3985 ///
3986 /// * *$.xgafv* (query-string) - V1 error format.
3987 /// * *access_token* (query-string) - OAuth access token.
3988 /// * *alt* (query-string) - Data format for response.
3989 /// * *callback* (query-string) - JSONP
3990 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3991 /// * *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.
3992 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3993 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3994 /// * *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.
3995 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3996 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3997 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionPullCall<'a, C>
3998 where
3999 T: AsRef<str>,
4000 {
4001 self._additional_params
4002 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4003 self
4004 }
4005
4006 /// Identifies the authorization scope for the method you are building.
4007 ///
4008 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4009 /// [`Scope::CloudPlatform`].
4010 ///
4011 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4012 /// tokens for more than one scope.
4013 ///
4014 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4015 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4016 /// sufficient, a read-write scope will do as well.
4017 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionPullCall<'a, C>
4018 where
4019 St: AsRef<str>,
4020 {
4021 self._scopes.insert(String::from(scope.as_ref()));
4022 self
4023 }
4024 /// Identifies the authorization scope(s) for the method you are building.
4025 ///
4026 /// See [`Self::add_scope()`] for details.
4027 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionPullCall<'a, C>
4028 where
4029 I: IntoIterator<Item = St>,
4030 St: AsRef<str>,
4031 {
4032 self._scopes
4033 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4034 self
4035 }
4036
4037 /// Removes all scopes, and no default scope will be used either.
4038 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4039 /// for details).
4040 pub fn clear_scopes(mut self) -> ProjectSubscriptionPullCall<'a, C> {
4041 self._scopes.clear();
4042 self
4043 }
4044}
4045
4046/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
4047///
4048/// A builder for the *subscriptions.setIamPolicy* method supported by a *project* resource.
4049/// It is not used directly, but through a [`ProjectMethods`] instance.
4050///
4051/// # Example
4052///
4053/// Instantiate a resource method builder
4054///
4055/// ```test_harness,no_run
4056/// # extern crate hyper;
4057/// # extern crate hyper_rustls;
4058/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
4059/// use pubsub1_beta2::api::SetIamPolicyRequest;
4060/// # async fn dox() {
4061/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4062///
4063/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4064/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4065/// # .with_native_roots()
4066/// # .unwrap()
4067/// # .https_only()
4068/// # .enable_http2()
4069/// # .build();
4070///
4071/// # let executor = hyper_util::rt::TokioExecutor::new();
4072/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4073/// # secret,
4074/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4075/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4076/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4077/// # ),
4078/// # ).build().await.unwrap();
4079///
4080/// # let client = hyper_util::client::legacy::Client::builder(
4081/// # hyper_util::rt::TokioExecutor::new()
4082/// # )
4083/// # .build(
4084/// # hyper_rustls::HttpsConnectorBuilder::new()
4085/// # .with_native_roots()
4086/// # .unwrap()
4087/// # .https_or_http()
4088/// # .enable_http2()
4089/// # .build()
4090/// # );
4091/// # let mut hub = Pubsub::new(client, auth);
4092/// // As the method needs a request, you would usually fill it with the desired information
4093/// // into the respective structure. Some of the parts shown here might not be applicable !
4094/// // Values shown here are possibly random and not representative !
4095/// let mut req = SetIamPolicyRequest::default();
4096///
4097/// // You can configure optional parameters by calling the respective setters at will, and
4098/// // execute the final call using `doit()`.
4099/// // Values shown here are possibly random and not representative !
4100/// let result = hub.projects().subscriptions_set_iam_policy(req, "resource")
4101/// .doit().await;
4102/// # }
4103/// ```
4104pub struct ProjectSubscriptionSetIamPolicyCall<'a, C>
4105where
4106 C: 'a,
4107{
4108 hub: &'a Pubsub<C>,
4109 _request: SetIamPolicyRequest,
4110 _resource: String,
4111 _delegate: Option<&'a mut dyn common::Delegate>,
4112 _additional_params: HashMap<String, String>,
4113 _scopes: BTreeSet<String>,
4114}
4115
4116impl<'a, C> common::CallBuilder for ProjectSubscriptionSetIamPolicyCall<'a, C> {}
4117
4118impl<'a, C> ProjectSubscriptionSetIamPolicyCall<'a, C>
4119where
4120 C: common::Connector,
4121{
4122 /// Perform the operation you have build so far.
4123 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4124 use std::borrow::Cow;
4125 use std::io::{Read, Seek};
4126
4127 use common::{url::Params, ToParts};
4128 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4129
4130 let mut dd = common::DefaultDelegate;
4131 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4132 dlg.begin(common::MethodInfo {
4133 id: "pubsub.projects.subscriptions.setIamPolicy",
4134 http_method: hyper::Method::POST,
4135 });
4136
4137 for &field in ["alt", "resource"].iter() {
4138 if self._additional_params.contains_key(field) {
4139 dlg.finished(false);
4140 return Err(common::Error::FieldClash(field));
4141 }
4142 }
4143
4144 let mut params = Params::with_capacity(4 + self._additional_params.len());
4145 params.push("resource", self._resource);
4146
4147 params.extend(self._additional_params.iter());
4148
4149 params.push("alt", "json");
4150 let mut url = self.hub._base_url.clone() + "v1beta2/{+resource}:setIamPolicy";
4151 if self._scopes.is_empty() {
4152 self._scopes
4153 .insert(Scope::CloudPlatform.as_ref().to_string());
4154 }
4155
4156 #[allow(clippy::single_element_loop)]
4157 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4158 url = params.uri_replacement(url, param_name, find_this, true);
4159 }
4160 {
4161 let to_remove = ["resource"];
4162 params.remove_params(&to_remove);
4163 }
4164
4165 let url = params.parse_with_url(&url);
4166
4167 let mut json_mime_type = mime::APPLICATION_JSON;
4168 let mut request_value_reader = {
4169 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4170 common::remove_json_null_values(&mut value);
4171 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4172 serde_json::to_writer(&mut dst, &value).unwrap();
4173 dst
4174 };
4175 let request_size = request_value_reader
4176 .seek(std::io::SeekFrom::End(0))
4177 .unwrap();
4178 request_value_reader
4179 .seek(std::io::SeekFrom::Start(0))
4180 .unwrap();
4181
4182 loop {
4183 let token = match self
4184 .hub
4185 .auth
4186 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4187 .await
4188 {
4189 Ok(token) => token,
4190 Err(e) => match dlg.token(e) {
4191 Ok(token) => token,
4192 Err(e) => {
4193 dlg.finished(false);
4194 return Err(common::Error::MissingToken(e));
4195 }
4196 },
4197 };
4198 request_value_reader
4199 .seek(std::io::SeekFrom::Start(0))
4200 .unwrap();
4201 let mut req_result = {
4202 let client = &self.hub.client;
4203 dlg.pre_request();
4204 let mut req_builder = hyper::Request::builder()
4205 .method(hyper::Method::POST)
4206 .uri(url.as_str())
4207 .header(USER_AGENT, self.hub._user_agent.clone());
4208
4209 if let Some(token) = token.as_ref() {
4210 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4211 }
4212
4213 let request = req_builder
4214 .header(CONTENT_TYPE, json_mime_type.to_string())
4215 .header(CONTENT_LENGTH, request_size as u64)
4216 .body(common::to_body(
4217 request_value_reader.get_ref().clone().into(),
4218 ));
4219
4220 client.request(request.unwrap()).await
4221 };
4222
4223 match req_result {
4224 Err(err) => {
4225 if let common::Retry::After(d) = dlg.http_error(&err) {
4226 sleep(d).await;
4227 continue;
4228 }
4229 dlg.finished(false);
4230 return Err(common::Error::HttpError(err));
4231 }
4232 Ok(res) => {
4233 let (mut parts, body) = res.into_parts();
4234 let mut body = common::Body::new(body);
4235 if !parts.status.is_success() {
4236 let bytes = common::to_bytes(body).await.unwrap_or_default();
4237 let error = serde_json::from_str(&common::to_string(&bytes));
4238 let response = common::to_response(parts, bytes.into());
4239
4240 if let common::Retry::After(d) =
4241 dlg.http_failure(&response, error.as_ref().ok())
4242 {
4243 sleep(d).await;
4244 continue;
4245 }
4246
4247 dlg.finished(false);
4248
4249 return Err(match error {
4250 Ok(value) => common::Error::BadRequest(value),
4251 _ => common::Error::Failure(response),
4252 });
4253 }
4254 let response = {
4255 let bytes = common::to_bytes(body).await.unwrap_or_default();
4256 let encoded = common::to_string(&bytes);
4257 match serde_json::from_str(&encoded) {
4258 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4259 Err(error) => {
4260 dlg.response_json_decode_error(&encoded, &error);
4261 return Err(common::Error::JsonDecodeError(
4262 encoded.to_string(),
4263 error,
4264 ));
4265 }
4266 }
4267 };
4268
4269 dlg.finished(true);
4270 return Ok(response);
4271 }
4272 }
4273 }
4274 }
4275
4276 ///
4277 /// Sets the *request* property to the given value.
4278 ///
4279 /// Even though the property as already been set when instantiating this call,
4280 /// we provide this method for API completeness.
4281 pub fn request(
4282 mut self,
4283 new_value: SetIamPolicyRequest,
4284 ) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
4285 self._request = new_value;
4286 self
4287 }
4288 /// 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.
4289 ///
4290 /// Sets the *resource* path property to the given value.
4291 ///
4292 /// Even though the property as already been set when instantiating this call,
4293 /// we provide this method for API completeness.
4294 pub fn resource(mut self, new_value: &str) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
4295 self._resource = new_value.to_string();
4296 self
4297 }
4298 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4299 /// while executing the actual API request.
4300 ///
4301 /// ````text
4302 /// It should be used to handle progress information, and to implement a certain level of resilience.
4303 /// ````
4304 ///
4305 /// Sets the *delegate* property to the given value.
4306 pub fn delegate(
4307 mut self,
4308 new_value: &'a mut dyn common::Delegate,
4309 ) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
4310 self._delegate = Some(new_value);
4311 self
4312 }
4313
4314 /// Set any additional parameter of the query string used in the request.
4315 /// It should be used to set parameters which are not yet available through their own
4316 /// setters.
4317 ///
4318 /// Please note that this method must not be used to set any of the known parameters
4319 /// which have their own setter method. If done anyway, the request will fail.
4320 ///
4321 /// # Additional Parameters
4322 ///
4323 /// * *$.xgafv* (query-string) - V1 error format.
4324 /// * *access_token* (query-string) - OAuth access token.
4325 /// * *alt* (query-string) - Data format for response.
4326 /// * *callback* (query-string) - JSONP
4327 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4328 /// * *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.
4329 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4330 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4331 /// * *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.
4332 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4333 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4334 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionSetIamPolicyCall<'a, C>
4335 where
4336 T: AsRef<str>,
4337 {
4338 self._additional_params
4339 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4340 self
4341 }
4342
4343 /// Identifies the authorization scope for the method you are building.
4344 ///
4345 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4346 /// [`Scope::CloudPlatform`].
4347 ///
4348 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4349 /// tokens for more than one scope.
4350 ///
4351 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4352 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4353 /// sufficient, a read-write scope will do as well.
4354 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionSetIamPolicyCall<'a, C>
4355 where
4356 St: AsRef<str>,
4357 {
4358 self._scopes.insert(String::from(scope.as_ref()));
4359 self
4360 }
4361 /// Identifies the authorization scope(s) for the method you are building.
4362 ///
4363 /// See [`Self::add_scope()`] for details.
4364 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionSetIamPolicyCall<'a, C>
4365 where
4366 I: IntoIterator<Item = St>,
4367 St: AsRef<str>,
4368 {
4369 self._scopes
4370 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4371 self
4372 }
4373
4374 /// Removes all scopes, and no default scope will be used either.
4375 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4376 /// for details).
4377 pub fn clear_scopes(mut self) -> ProjectSubscriptionSetIamPolicyCall<'a, C> {
4378 self._scopes.clear();
4379 self
4380 }
4381}
4382
4383/// 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.
4384///
4385/// A builder for the *subscriptions.testIamPermissions* method supported by a *project* resource.
4386/// It is not used directly, but through a [`ProjectMethods`] instance.
4387///
4388/// # Example
4389///
4390/// Instantiate a resource method builder
4391///
4392/// ```test_harness,no_run
4393/// # extern crate hyper;
4394/// # extern crate hyper_rustls;
4395/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
4396/// use pubsub1_beta2::api::TestIamPermissionsRequest;
4397/// # async fn dox() {
4398/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4399///
4400/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4401/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4402/// # .with_native_roots()
4403/// # .unwrap()
4404/// # .https_only()
4405/// # .enable_http2()
4406/// # .build();
4407///
4408/// # let executor = hyper_util::rt::TokioExecutor::new();
4409/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4410/// # secret,
4411/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4412/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4413/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4414/// # ),
4415/// # ).build().await.unwrap();
4416///
4417/// # let client = hyper_util::client::legacy::Client::builder(
4418/// # hyper_util::rt::TokioExecutor::new()
4419/// # )
4420/// # .build(
4421/// # hyper_rustls::HttpsConnectorBuilder::new()
4422/// # .with_native_roots()
4423/// # .unwrap()
4424/// # .https_or_http()
4425/// # .enable_http2()
4426/// # .build()
4427/// # );
4428/// # let mut hub = Pubsub::new(client, auth);
4429/// // As the method needs a request, you would usually fill it with the desired information
4430/// // into the respective structure. Some of the parts shown here might not be applicable !
4431/// // Values shown here are possibly random and not representative !
4432/// let mut req = TestIamPermissionsRequest::default();
4433///
4434/// // You can configure optional parameters by calling the respective setters at will, and
4435/// // execute the final call using `doit()`.
4436/// // Values shown here are possibly random and not representative !
4437/// let result = hub.projects().subscriptions_test_iam_permissions(req, "resource")
4438/// .doit().await;
4439/// # }
4440/// ```
4441pub struct ProjectSubscriptionTestIamPermissionCall<'a, C>
4442where
4443 C: 'a,
4444{
4445 hub: &'a Pubsub<C>,
4446 _request: TestIamPermissionsRequest,
4447 _resource: String,
4448 _delegate: Option<&'a mut dyn common::Delegate>,
4449 _additional_params: HashMap<String, String>,
4450 _scopes: BTreeSet<String>,
4451}
4452
4453impl<'a, C> common::CallBuilder for ProjectSubscriptionTestIamPermissionCall<'a, C> {}
4454
4455impl<'a, C> ProjectSubscriptionTestIamPermissionCall<'a, C>
4456where
4457 C: common::Connector,
4458{
4459 /// Perform the operation you have build so far.
4460 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
4461 use std::borrow::Cow;
4462 use std::io::{Read, Seek};
4463
4464 use common::{url::Params, ToParts};
4465 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4466
4467 let mut dd = common::DefaultDelegate;
4468 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4469 dlg.begin(common::MethodInfo {
4470 id: "pubsub.projects.subscriptions.testIamPermissions",
4471 http_method: hyper::Method::POST,
4472 });
4473
4474 for &field in ["alt", "resource"].iter() {
4475 if self._additional_params.contains_key(field) {
4476 dlg.finished(false);
4477 return Err(common::Error::FieldClash(field));
4478 }
4479 }
4480
4481 let mut params = Params::with_capacity(4 + self._additional_params.len());
4482 params.push("resource", self._resource);
4483
4484 params.extend(self._additional_params.iter());
4485
4486 params.push("alt", "json");
4487 let mut url = self.hub._base_url.clone() + "v1beta2/{+resource}:testIamPermissions";
4488 if self._scopes.is_empty() {
4489 self._scopes
4490 .insert(Scope::CloudPlatform.as_ref().to_string());
4491 }
4492
4493 #[allow(clippy::single_element_loop)]
4494 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4495 url = params.uri_replacement(url, param_name, find_this, true);
4496 }
4497 {
4498 let to_remove = ["resource"];
4499 params.remove_params(&to_remove);
4500 }
4501
4502 let url = params.parse_with_url(&url);
4503
4504 let mut json_mime_type = mime::APPLICATION_JSON;
4505 let mut request_value_reader = {
4506 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4507 common::remove_json_null_values(&mut value);
4508 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4509 serde_json::to_writer(&mut dst, &value).unwrap();
4510 dst
4511 };
4512 let request_size = request_value_reader
4513 .seek(std::io::SeekFrom::End(0))
4514 .unwrap();
4515 request_value_reader
4516 .seek(std::io::SeekFrom::Start(0))
4517 .unwrap();
4518
4519 loop {
4520 let token = match self
4521 .hub
4522 .auth
4523 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4524 .await
4525 {
4526 Ok(token) => token,
4527 Err(e) => match dlg.token(e) {
4528 Ok(token) => token,
4529 Err(e) => {
4530 dlg.finished(false);
4531 return Err(common::Error::MissingToken(e));
4532 }
4533 },
4534 };
4535 request_value_reader
4536 .seek(std::io::SeekFrom::Start(0))
4537 .unwrap();
4538 let mut req_result = {
4539 let client = &self.hub.client;
4540 dlg.pre_request();
4541 let mut req_builder = hyper::Request::builder()
4542 .method(hyper::Method::POST)
4543 .uri(url.as_str())
4544 .header(USER_AGENT, self.hub._user_agent.clone());
4545
4546 if let Some(token) = token.as_ref() {
4547 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4548 }
4549
4550 let request = req_builder
4551 .header(CONTENT_TYPE, json_mime_type.to_string())
4552 .header(CONTENT_LENGTH, request_size as u64)
4553 .body(common::to_body(
4554 request_value_reader.get_ref().clone().into(),
4555 ));
4556
4557 client.request(request.unwrap()).await
4558 };
4559
4560 match req_result {
4561 Err(err) => {
4562 if let common::Retry::After(d) = dlg.http_error(&err) {
4563 sleep(d).await;
4564 continue;
4565 }
4566 dlg.finished(false);
4567 return Err(common::Error::HttpError(err));
4568 }
4569 Ok(res) => {
4570 let (mut parts, body) = res.into_parts();
4571 let mut body = common::Body::new(body);
4572 if !parts.status.is_success() {
4573 let bytes = common::to_bytes(body).await.unwrap_or_default();
4574 let error = serde_json::from_str(&common::to_string(&bytes));
4575 let response = common::to_response(parts, bytes.into());
4576
4577 if let common::Retry::After(d) =
4578 dlg.http_failure(&response, error.as_ref().ok())
4579 {
4580 sleep(d).await;
4581 continue;
4582 }
4583
4584 dlg.finished(false);
4585
4586 return Err(match error {
4587 Ok(value) => common::Error::BadRequest(value),
4588 _ => common::Error::Failure(response),
4589 });
4590 }
4591 let response = {
4592 let bytes = common::to_bytes(body).await.unwrap_or_default();
4593 let encoded = common::to_string(&bytes);
4594 match serde_json::from_str(&encoded) {
4595 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4596 Err(error) => {
4597 dlg.response_json_decode_error(&encoded, &error);
4598 return Err(common::Error::JsonDecodeError(
4599 encoded.to_string(),
4600 error,
4601 ));
4602 }
4603 }
4604 };
4605
4606 dlg.finished(true);
4607 return Ok(response);
4608 }
4609 }
4610 }
4611 }
4612
4613 ///
4614 /// Sets the *request* property to the given value.
4615 ///
4616 /// Even though the property as already been set when instantiating this call,
4617 /// we provide this method for API completeness.
4618 pub fn request(
4619 mut self,
4620 new_value: TestIamPermissionsRequest,
4621 ) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
4622 self._request = new_value;
4623 self
4624 }
4625 /// 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.
4626 ///
4627 /// Sets the *resource* path property to the given value.
4628 ///
4629 /// Even though the property as already been set when instantiating this call,
4630 /// we provide this method for API completeness.
4631 pub fn resource(mut self, new_value: &str) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
4632 self._resource = new_value.to_string();
4633 self
4634 }
4635 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4636 /// while executing the actual API request.
4637 ///
4638 /// ````text
4639 /// It should be used to handle progress information, and to implement a certain level of resilience.
4640 /// ````
4641 ///
4642 /// Sets the *delegate* property to the given value.
4643 pub fn delegate(
4644 mut self,
4645 new_value: &'a mut dyn common::Delegate,
4646 ) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
4647 self._delegate = Some(new_value);
4648 self
4649 }
4650
4651 /// Set any additional parameter of the query string used in the request.
4652 /// It should be used to set parameters which are not yet available through their own
4653 /// setters.
4654 ///
4655 /// Please note that this method must not be used to set any of the known parameters
4656 /// which have their own setter method. If done anyway, the request will fail.
4657 ///
4658 /// # Additional Parameters
4659 ///
4660 /// * *$.xgafv* (query-string) - V1 error format.
4661 /// * *access_token* (query-string) - OAuth access token.
4662 /// * *alt* (query-string) - Data format for response.
4663 /// * *callback* (query-string) - JSONP
4664 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4665 /// * *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.
4666 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4667 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4668 /// * *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.
4669 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4670 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4671 pub fn param<T>(mut self, name: T, value: T) -> ProjectSubscriptionTestIamPermissionCall<'a, C>
4672 where
4673 T: AsRef<str>,
4674 {
4675 self._additional_params
4676 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4677 self
4678 }
4679
4680 /// Identifies the authorization scope for the method you are building.
4681 ///
4682 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4683 /// [`Scope::CloudPlatform`].
4684 ///
4685 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4686 /// tokens for more than one scope.
4687 ///
4688 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4689 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4690 /// sufficient, a read-write scope will do as well.
4691 pub fn add_scope<St>(mut self, scope: St) -> ProjectSubscriptionTestIamPermissionCall<'a, C>
4692 where
4693 St: AsRef<str>,
4694 {
4695 self._scopes.insert(String::from(scope.as_ref()));
4696 self
4697 }
4698 /// Identifies the authorization scope(s) for the method you are building.
4699 ///
4700 /// See [`Self::add_scope()`] for details.
4701 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSubscriptionTestIamPermissionCall<'a, C>
4702 where
4703 I: IntoIterator<Item = St>,
4704 St: AsRef<str>,
4705 {
4706 self._scopes
4707 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4708 self
4709 }
4710
4711 /// Removes all scopes, and no default scope will be used either.
4712 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4713 /// for details).
4714 pub fn clear_scopes(mut self) -> ProjectSubscriptionTestIamPermissionCall<'a, C> {
4715 self._scopes.clear();
4716 self
4717 }
4718}
4719
4720/// Lists the name of the subscriptions for this topic.
4721///
4722/// A builder for the *topics.subscriptions.list* method supported by a *project* resource.
4723/// It is not used directly, but through a [`ProjectMethods`] instance.
4724///
4725/// # Example
4726///
4727/// Instantiate a resource method builder
4728///
4729/// ```test_harness,no_run
4730/// # extern crate hyper;
4731/// # extern crate hyper_rustls;
4732/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
4733/// # async fn dox() {
4734/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4735///
4736/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4737/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4738/// # .with_native_roots()
4739/// # .unwrap()
4740/// # .https_only()
4741/// # .enable_http2()
4742/// # .build();
4743///
4744/// # let executor = hyper_util::rt::TokioExecutor::new();
4745/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4746/// # secret,
4747/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4748/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4749/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4750/// # ),
4751/// # ).build().await.unwrap();
4752///
4753/// # let client = hyper_util::client::legacy::Client::builder(
4754/// # hyper_util::rt::TokioExecutor::new()
4755/// # )
4756/// # .build(
4757/// # hyper_rustls::HttpsConnectorBuilder::new()
4758/// # .with_native_roots()
4759/// # .unwrap()
4760/// # .https_or_http()
4761/// # .enable_http2()
4762/// # .build()
4763/// # );
4764/// # let mut hub = Pubsub::new(client, auth);
4765/// // You can configure optional parameters by calling the respective setters at will, and
4766/// // execute the final call using `doit()`.
4767/// // Values shown here are possibly random and not representative !
4768/// let result = hub.projects().topics_subscriptions_list("topic")
4769/// .page_token("ea")
4770/// .page_size(-55)
4771/// .doit().await;
4772/// # }
4773/// ```
4774pub struct ProjectTopicSubscriptionListCall<'a, C>
4775where
4776 C: 'a,
4777{
4778 hub: &'a Pubsub<C>,
4779 _topic: String,
4780 _page_token: Option<String>,
4781 _page_size: Option<i32>,
4782 _delegate: Option<&'a mut dyn common::Delegate>,
4783 _additional_params: HashMap<String, String>,
4784 _scopes: BTreeSet<String>,
4785}
4786
4787impl<'a, C> common::CallBuilder for ProjectTopicSubscriptionListCall<'a, C> {}
4788
4789impl<'a, C> ProjectTopicSubscriptionListCall<'a, C>
4790where
4791 C: common::Connector,
4792{
4793 /// Perform the operation you have build so far.
4794 pub async fn doit(
4795 mut self,
4796 ) -> common::Result<(common::Response, ListTopicSubscriptionsResponse)> {
4797 use std::borrow::Cow;
4798 use std::io::{Read, Seek};
4799
4800 use common::{url::Params, ToParts};
4801 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4802
4803 let mut dd = common::DefaultDelegate;
4804 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4805 dlg.begin(common::MethodInfo {
4806 id: "pubsub.projects.topics.subscriptions.list",
4807 http_method: hyper::Method::GET,
4808 });
4809
4810 for &field in ["alt", "topic", "pageToken", "pageSize"].iter() {
4811 if self._additional_params.contains_key(field) {
4812 dlg.finished(false);
4813 return Err(common::Error::FieldClash(field));
4814 }
4815 }
4816
4817 let mut params = Params::with_capacity(5 + self._additional_params.len());
4818 params.push("topic", self._topic);
4819 if let Some(value) = self._page_token.as_ref() {
4820 params.push("pageToken", value);
4821 }
4822 if let Some(value) = self._page_size.as_ref() {
4823 params.push("pageSize", value.to_string());
4824 }
4825
4826 params.extend(self._additional_params.iter());
4827
4828 params.push("alt", "json");
4829 let mut url = self.hub._base_url.clone() + "v1beta2/{+topic}/subscriptions";
4830 if self._scopes.is_empty() {
4831 self._scopes
4832 .insert(Scope::CloudPlatform.as_ref().to_string());
4833 }
4834
4835 #[allow(clippy::single_element_loop)]
4836 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
4837 url = params.uri_replacement(url, param_name, find_this, true);
4838 }
4839 {
4840 let to_remove = ["topic"];
4841 params.remove_params(&to_remove);
4842 }
4843
4844 let url = params.parse_with_url(&url);
4845
4846 loop {
4847 let token = match self
4848 .hub
4849 .auth
4850 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4851 .await
4852 {
4853 Ok(token) => token,
4854 Err(e) => match dlg.token(e) {
4855 Ok(token) => token,
4856 Err(e) => {
4857 dlg.finished(false);
4858 return Err(common::Error::MissingToken(e));
4859 }
4860 },
4861 };
4862 let mut req_result = {
4863 let client = &self.hub.client;
4864 dlg.pre_request();
4865 let mut req_builder = hyper::Request::builder()
4866 .method(hyper::Method::GET)
4867 .uri(url.as_str())
4868 .header(USER_AGENT, self.hub._user_agent.clone());
4869
4870 if let Some(token) = token.as_ref() {
4871 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4872 }
4873
4874 let request = req_builder
4875 .header(CONTENT_LENGTH, 0_u64)
4876 .body(common::to_body::<String>(None));
4877
4878 client.request(request.unwrap()).await
4879 };
4880
4881 match req_result {
4882 Err(err) => {
4883 if let common::Retry::After(d) = dlg.http_error(&err) {
4884 sleep(d).await;
4885 continue;
4886 }
4887 dlg.finished(false);
4888 return Err(common::Error::HttpError(err));
4889 }
4890 Ok(res) => {
4891 let (mut parts, body) = res.into_parts();
4892 let mut body = common::Body::new(body);
4893 if !parts.status.is_success() {
4894 let bytes = common::to_bytes(body).await.unwrap_or_default();
4895 let error = serde_json::from_str(&common::to_string(&bytes));
4896 let response = common::to_response(parts, bytes.into());
4897
4898 if let common::Retry::After(d) =
4899 dlg.http_failure(&response, error.as_ref().ok())
4900 {
4901 sleep(d).await;
4902 continue;
4903 }
4904
4905 dlg.finished(false);
4906
4907 return Err(match error {
4908 Ok(value) => common::Error::BadRequest(value),
4909 _ => common::Error::Failure(response),
4910 });
4911 }
4912 let response = {
4913 let bytes = common::to_bytes(body).await.unwrap_or_default();
4914 let encoded = common::to_string(&bytes);
4915 match serde_json::from_str(&encoded) {
4916 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4917 Err(error) => {
4918 dlg.response_json_decode_error(&encoded, &error);
4919 return Err(common::Error::JsonDecodeError(
4920 encoded.to_string(),
4921 error,
4922 ));
4923 }
4924 }
4925 };
4926
4927 dlg.finished(true);
4928 return Ok(response);
4929 }
4930 }
4931 }
4932 }
4933
4934 /// The name of the topic that subscriptions are attached to.
4935 ///
4936 /// Sets the *topic* path property to the given value.
4937 ///
4938 /// Even though the property as already been set when instantiating this call,
4939 /// we provide this method for API completeness.
4940 pub fn topic(mut self, new_value: &str) -> ProjectTopicSubscriptionListCall<'a, C> {
4941 self._topic = new_value.to_string();
4942 self
4943 }
4944 /// 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.
4945 ///
4946 /// Sets the *page token* query property to the given value.
4947 pub fn page_token(mut self, new_value: &str) -> ProjectTopicSubscriptionListCall<'a, C> {
4948 self._page_token = Some(new_value.to_string());
4949 self
4950 }
4951 /// Maximum number of subscription names to return.
4952 ///
4953 /// Sets the *page size* query property to the given value.
4954 pub fn page_size(mut self, new_value: i32) -> ProjectTopicSubscriptionListCall<'a, C> {
4955 self._page_size = Some(new_value);
4956 self
4957 }
4958 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4959 /// while executing the actual API request.
4960 ///
4961 /// ````text
4962 /// It should be used to handle progress information, and to implement a certain level of resilience.
4963 /// ````
4964 ///
4965 /// Sets the *delegate* property to the given value.
4966 pub fn delegate(
4967 mut self,
4968 new_value: &'a mut dyn common::Delegate,
4969 ) -> ProjectTopicSubscriptionListCall<'a, C> {
4970 self._delegate = Some(new_value);
4971 self
4972 }
4973
4974 /// Set any additional parameter of the query string used in the request.
4975 /// It should be used to set parameters which are not yet available through their own
4976 /// setters.
4977 ///
4978 /// Please note that this method must not be used to set any of the known parameters
4979 /// which have their own setter method. If done anyway, the request will fail.
4980 ///
4981 /// # Additional Parameters
4982 ///
4983 /// * *$.xgafv* (query-string) - V1 error format.
4984 /// * *access_token* (query-string) - OAuth access token.
4985 /// * *alt* (query-string) - Data format for response.
4986 /// * *callback* (query-string) - JSONP
4987 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4988 /// * *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.
4989 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4990 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4991 /// * *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.
4992 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4993 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4994 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicSubscriptionListCall<'a, C>
4995 where
4996 T: AsRef<str>,
4997 {
4998 self._additional_params
4999 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5000 self
5001 }
5002
5003 /// Identifies the authorization scope for the method you are building.
5004 ///
5005 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5006 /// [`Scope::CloudPlatform`].
5007 ///
5008 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5009 /// tokens for more than one scope.
5010 ///
5011 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5012 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5013 /// sufficient, a read-write scope will do as well.
5014 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicSubscriptionListCall<'a, C>
5015 where
5016 St: AsRef<str>,
5017 {
5018 self._scopes.insert(String::from(scope.as_ref()));
5019 self
5020 }
5021 /// Identifies the authorization scope(s) for the method you are building.
5022 ///
5023 /// See [`Self::add_scope()`] for details.
5024 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicSubscriptionListCall<'a, C>
5025 where
5026 I: IntoIterator<Item = St>,
5027 St: AsRef<str>,
5028 {
5029 self._scopes
5030 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5031 self
5032 }
5033
5034 /// Removes all scopes, and no default scope will be used either.
5035 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5036 /// for details).
5037 pub fn clear_scopes(mut self) -> ProjectTopicSubscriptionListCall<'a, C> {
5038 self._scopes.clear();
5039 self
5040 }
5041}
5042
5043/// Creates the given topic with the given name.
5044///
5045/// A builder for the *topics.create* method supported by a *project* resource.
5046/// It is not used directly, but through a [`ProjectMethods`] instance.
5047///
5048/// # Example
5049///
5050/// Instantiate a resource method builder
5051///
5052/// ```test_harness,no_run
5053/// # extern crate hyper;
5054/// # extern crate hyper_rustls;
5055/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
5056/// use pubsub1_beta2::api::Topic;
5057/// # async fn dox() {
5058/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5059///
5060/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5061/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5062/// # .with_native_roots()
5063/// # .unwrap()
5064/// # .https_only()
5065/// # .enable_http2()
5066/// # .build();
5067///
5068/// # let executor = hyper_util::rt::TokioExecutor::new();
5069/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5070/// # secret,
5071/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5072/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5073/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5074/// # ),
5075/// # ).build().await.unwrap();
5076///
5077/// # let client = hyper_util::client::legacy::Client::builder(
5078/// # hyper_util::rt::TokioExecutor::new()
5079/// # )
5080/// # .build(
5081/// # hyper_rustls::HttpsConnectorBuilder::new()
5082/// # .with_native_roots()
5083/// # .unwrap()
5084/// # .https_or_http()
5085/// # .enable_http2()
5086/// # .build()
5087/// # );
5088/// # let mut hub = Pubsub::new(client, auth);
5089/// // As the method needs a request, you would usually fill it with the desired information
5090/// // into the respective structure. Some of the parts shown here might not be applicable !
5091/// // Values shown here are possibly random and not representative !
5092/// let mut req = Topic::default();
5093///
5094/// // You can configure optional parameters by calling the respective setters at will, and
5095/// // execute the final call using `doit()`.
5096/// // Values shown here are possibly random and not representative !
5097/// let result = hub.projects().topics_create(req, "name")
5098/// .doit().await;
5099/// # }
5100/// ```
5101pub struct ProjectTopicCreateCall<'a, C>
5102where
5103 C: 'a,
5104{
5105 hub: &'a Pubsub<C>,
5106 _request: Topic,
5107 _name: String,
5108 _delegate: Option<&'a mut dyn common::Delegate>,
5109 _additional_params: HashMap<String, String>,
5110 _scopes: BTreeSet<String>,
5111}
5112
5113impl<'a, C> common::CallBuilder for ProjectTopicCreateCall<'a, C> {}
5114
5115impl<'a, C> ProjectTopicCreateCall<'a, C>
5116where
5117 C: common::Connector,
5118{
5119 /// Perform the operation you have build so far.
5120 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
5121 use std::borrow::Cow;
5122 use std::io::{Read, Seek};
5123
5124 use common::{url::Params, ToParts};
5125 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5126
5127 let mut dd = common::DefaultDelegate;
5128 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5129 dlg.begin(common::MethodInfo {
5130 id: "pubsub.projects.topics.create",
5131 http_method: hyper::Method::PUT,
5132 });
5133
5134 for &field in ["alt", "name"].iter() {
5135 if self._additional_params.contains_key(field) {
5136 dlg.finished(false);
5137 return Err(common::Error::FieldClash(field));
5138 }
5139 }
5140
5141 let mut params = Params::with_capacity(4 + self._additional_params.len());
5142 params.push("name", self._name);
5143
5144 params.extend(self._additional_params.iter());
5145
5146 params.push("alt", "json");
5147 let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
5148 if self._scopes.is_empty() {
5149 self._scopes
5150 .insert(Scope::CloudPlatform.as_ref().to_string());
5151 }
5152
5153 #[allow(clippy::single_element_loop)]
5154 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5155 url = params.uri_replacement(url, param_name, find_this, true);
5156 }
5157 {
5158 let to_remove = ["name"];
5159 params.remove_params(&to_remove);
5160 }
5161
5162 let url = params.parse_with_url(&url);
5163
5164 let mut json_mime_type = mime::APPLICATION_JSON;
5165 let mut request_value_reader = {
5166 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5167 common::remove_json_null_values(&mut value);
5168 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5169 serde_json::to_writer(&mut dst, &value).unwrap();
5170 dst
5171 };
5172 let request_size = request_value_reader
5173 .seek(std::io::SeekFrom::End(0))
5174 .unwrap();
5175 request_value_reader
5176 .seek(std::io::SeekFrom::Start(0))
5177 .unwrap();
5178
5179 loop {
5180 let token = match self
5181 .hub
5182 .auth
5183 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5184 .await
5185 {
5186 Ok(token) => token,
5187 Err(e) => match dlg.token(e) {
5188 Ok(token) => token,
5189 Err(e) => {
5190 dlg.finished(false);
5191 return Err(common::Error::MissingToken(e));
5192 }
5193 },
5194 };
5195 request_value_reader
5196 .seek(std::io::SeekFrom::Start(0))
5197 .unwrap();
5198 let mut req_result = {
5199 let client = &self.hub.client;
5200 dlg.pre_request();
5201 let mut req_builder = hyper::Request::builder()
5202 .method(hyper::Method::PUT)
5203 .uri(url.as_str())
5204 .header(USER_AGENT, self.hub._user_agent.clone());
5205
5206 if let Some(token) = token.as_ref() {
5207 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5208 }
5209
5210 let request = req_builder
5211 .header(CONTENT_TYPE, json_mime_type.to_string())
5212 .header(CONTENT_LENGTH, request_size as u64)
5213 .body(common::to_body(
5214 request_value_reader.get_ref().clone().into(),
5215 ));
5216
5217 client.request(request.unwrap()).await
5218 };
5219
5220 match req_result {
5221 Err(err) => {
5222 if let common::Retry::After(d) = dlg.http_error(&err) {
5223 sleep(d).await;
5224 continue;
5225 }
5226 dlg.finished(false);
5227 return Err(common::Error::HttpError(err));
5228 }
5229 Ok(res) => {
5230 let (mut parts, body) = res.into_parts();
5231 let mut body = common::Body::new(body);
5232 if !parts.status.is_success() {
5233 let bytes = common::to_bytes(body).await.unwrap_or_default();
5234 let error = serde_json::from_str(&common::to_string(&bytes));
5235 let response = common::to_response(parts, bytes.into());
5236
5237 if let common::Retry::After(d) =
5238 dlg.http_failure(&response, error.as_ref().ok())
5239 {
5240 sleep(d).await;
5241 continue;
5242 }
5243
5244 dlg.finished(false);
5245
5246 return Err(match error {
5247 Ok(value) => common::Error::BadRequest(value),
5248 _ => common::Error::Failure(response),
5249 });
5250 }
5251 let response = {
5252 let bytes = common::to_bytes(body).await.unwrap_or_default();
5253 let encoded = common::to_string(&bytes);
5254 match serde_json::from_str(&encoded) {
5255 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5256 Err(error) => {
5257 dlg.response_json_decode_error(&encoded, &error);
5258 return Err(common::Error::JsonDecodeError(
5259 encoded.to_string(),
5260 error,
5261 ));
5262 }
5263 }
5264 };
5265
5266 dlg.finished(true);
5267 return Ok(response);
5268 }
5269 }
5270 }
5271 }
5272
5273 ///
5274 /// Sets the *request* property to the given value.
5275 ///
5276 /// Even though the property as already been set when instantiating this call,
5277 /// we provide this method for API completeness.
5278 pub fn request(mut self, new_value: Topic) -> ProjectTopicCreateCall<'a, C> {
5279 self._request = new_value;
5280 self
5281 }
5282 /// 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"`.
5283 ///
5284 /// Sets the *name* path property to the given value.
5285 ///
5286 /// Even though the property as already been set when instantiating this call,
5287 /// we provide this method for API completeness.
5288 pub fn name(mut self, new_value: &str) -> ProjectTopicCreateCall<'a, C> {
5289 self._name = new_value.to_string();
5290 self
5291 }
5292 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5293 /// while executing the actual API request.
5294 ///
5295 /// ````text
5296 /// It should be used to handle progress information, and to implement a certain level of resilience.
5297 /// ````
5298 ///
5299 /// Sets the *delegate* property to the given value.
5300 pub fn delegate(
5301 mut self,
5302 new_value: &'a mut dyn common::Delegate,
5303 ) -> ProjectTopicCreateCall<'a, C> {
5304 self._delegate = Some(new_value);
5305 self
5306 }
5307
5308 /// Set any additional parameter of the query string used in the request.
5309 /// It should be used to set parameters which are not yet available through their own
5310 /// setters.
5311 ///
5312 /// Please note that this method must not be used to set any of the known parameters
5313 /// which have their own setter method. If done anyway, the request will fail.
5314 ///
5315 /// # Additional Parameters
5316 ///
5317 /// * *$.xgafv* (query-string) - V1 error format.
5318 /// * *access_token* (query-string) - OAuth access token.
5319 /// * *alt* (query-string) - Data format for response.
5320 /// * *callback* (query-string) - JSONP
5321 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5322 /// * *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.
5323 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5324 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5325 /// * *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.
5326 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5327 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5328 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicCreateCall<'a, C>
5329 where
5330 T: AsRef<str>,
5331 {
5332 self._additional_params
5333 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5334 self
5335 }
5336
5337 /// Identifies the authorization scope for the method you are building.
5338 ///
5339 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5340 /// [`Scope::CloudPlatform`].
5341 ///
5342 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5343 /// tokens for more than one scope.
5344 ///
5345 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5346 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5347 /// sufficient, a read-write scope will do as well.
5348 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicCreateCall<'a, C>
5349 where
5350 St: AsRef<str>,
5351 {
5352 self._scopes.insert(String::from(scope.as_ref()));
5353 self
5354 }
5355 /// Identifies the authorization scope(s) for the method you are building.
5356 ///
5357 /// See [`Self::add_scope()`] for details.
5358 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicCreateCall<'a, C>
5359 where
5360 I: IntoIterator<Item = St>,
5361 St: AsRef<str>,
5362 {
5363 self._scopes
5364 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5365 self
5366 }
5367
5368 /// Removes all scopes, and no default scope will be used either.
5369 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5370 /// for details).
5371 pub fn clear_scopes(mut self) -> ProjectTopicCreateCall<'a, C> {
5372 self._scopes.clear();
5373 self
5374 }
5375}
5376
5377/// 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_`.
5378///
5379/// A builder for the *topics.delete* method supported by a *project* resource.
5380/// It is not used directly, but through a [`ProjectMethods`] instance.
5381///
5382/// # Example
5383///
5384/// Instantiate a resource method builder
5385///
5386/// ```test_harness,no_run
5387/// # extern crate hyper;
5388/// # extern crate hyper_rustls;
5389/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
5390/// # async fn dox() {
5391/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5392///
5393/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5394/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5395/// # .with_native_roots()
5396/// # .unwrap()
5397/// # .https_only()
5398/// # .enable_http2()
5399/// # .build();
5400///
5401/// # let executor = hyper_util::rt::TokioExecutor::new();
5402/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5403/// # secret,
5404/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5405/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5406/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5407/// # ),
5408/// # ).build().await.unwrap();
5409///
5410/// # let client = hyper_util::client::legacy::Client::builder(
5411/// # hyper_util::rt::TokioExecutor::new()
5412/// # )
5413/// # .build(
5414/// # hyper_rustls::HttpsConnectorBuilder::new()
5415/// # .with_native_roots()
5416/// # .unwrap()
5417/// # .https_or_http()
5418/// # .enable_http2()
5419/// # .build()
5420/// # );
5421/// # let mut hub = Pubsub::new(client, auth);
5422/// // You can configure optional parameters by calling the respective setters at will, and
5423/// // execute the final call using `doit()`.
5424/// // Values shown here are possibly random and not representative !
5425/// let result = hub.projects().topics_delete("topic")
5426/// .doit().await;
5427/// # }
5428/// ```
5429pub struct ProjectTopicDeleteCall<'a, C>
5430where
5431 C: 'a,
5432{
5433 hub: &'a Pubsub<C>,
5434 _topic: String,
5435 _delegate: Option<&'a mut dyn common::Delegate>,
5436 _additional_params: HashMap<String, String>,
5437 _scopes: BTreeSet<String>,
5438}
5439
5440impl<'a, C> common::CallBuilder for ProjectTopicDeleteCall<'a, C> {}
5441
5442impl<'a, C> ProjectTopicDeleteCall<'a, C>
5443where
5444 C: common::Connector,
5445{
5446 /// Perform the operation you have build so far.
5447 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5448 use std::borrow::Cow;
5449 use std::io::{Read, Seek};
5450
5451 use common::{url::Params, ToParts};
5452 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5453
5454 let mut dd = common::DefaultDelegate;
5455 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5456 dlg.begin(common::MethodInfo {
5457 id: "pubsub.projects.topics.delete",
5458 http_method: hyper::Method::DELETE,
5459 });
5460
5461 for &field in ["alt", "topic"].iter() {
5462 if self._additional_params.contains_key(field) {
5463 dlg.finished(false);
5464 return Err(common::Error::FieldClash(field));
5465 }
5466 }
5467
5468 let mut params = Params::with_capacity(3 + self._additional_params.len());
5469 params.push("topic", self._topic);
5470
5471 params.extend(self._additional_params.iter());
5472
5473 params.push("alt", "json");
5474 let mut url = self.hub._base_url.clone() + "v1beta2/{+topic}";
5475 if self._scopes.is_empty() {
5476 self._scopes
5477 .insert(Scope::CloudPlatform.as_ref().to_string());
5478 }
5479
5480 #[allow(clippy::single_element_loop)]
5481 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
5482 url = params.uri_replacement(url, param_name, find_this, true);
5483 }
5484 {
5485 let to_remove = ["topic"];
5486 params.remove_params(&to_remove);
5487 }
5488
5489 let url = params.parse_with_url(&url);
5490
5491 loop {
5492 let token = match self
5493 .hub
5494 .auth
5495 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5496 .await
5497 {
5498 Ok(token) => token,
5499 Err(e) => match dlg.token(e) {
5500 Ok(token) => token,
5501 Err(e) => {
5502 dlg.finished(false);
5503 return Err(common::Error::MissingToken(e));
5504 }
5505 },
5506 };
5507 let mut req_result = {
5508 let client = &self.hub.client;
5509 dlg.pre_request();
5510 let mut req_builder = hyper::Request::builder()
5511 .method(hyper::Method::DELETE)
5512 .uri(url.as_str())
5513 .header(USER_AGENT, self.hub._user_agent.clone());
5514
5515 if let Some(token) = token.as_ref() {
5516 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5517 }
5518
5519 let request = req_builder
5520 .header(CONTENT_LENGTH, 0_u64)
5521 .body(common::to_body::<String>(None));
5522
5523 client.request(request.unwrap()).await
5524 };
5525
5526 match req_result {
5527 Err(err) => {
5528 if let common::Retry::After(d) = dlg.http_error(&err) {
5529 sleep(d).await;
5530 continue;
5531 }
5532 dlg.finished(false);
5533 return Err(common::Error::HttpError(err));
5534 }
5535 Ok(res) => {
5536 let (mut parts, body) = res.into_parts();
5537 let mut body = common::Body::new(body);
5538 if !parts.status.is_success() {
5539 let bytes = common::to_bytes(body).await.unwrap_or_default();
5540 let error = serde_json::from_str(&common::to_string(&bytes));
5541 let response = common::to_response(parts, bytes.into());
5542
5543 if let common::Retry::After(d) =
5544 dlg.http_failure(&response, error.as_ref().ok())
5545 {
5546 sleep(d).await;
5547 continue;
5548 }
5549
5550 dlg.finished(false);
5551
5552 return Err(match error {
5553 Ok(value) => common::Error::BadRequest(value),
5554 _ => common::Error::Failure(response),
5555 });
5556 }
5557 let response = {
5558 let bytes = common::to_bytes(body).await.unwrap_or_default();
5559 let encoded = common::to_string(&bytes);
5560 match serde_json::from_str(&encoded) {
5561 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5562 Err(error) => {
5563 dlg.response_json_decode_error(&encoded, &error);
5564 return Err(common::Error::JsonDecodeError(
5565 encoded.to_string(),
5566 error,
5567 ));
5568 }
5569 }
5570 };
5571
5572 dlg.finished(true);
5573 return Ok(response);
5574 }
5575 }
5576 }
5577 }
5578
5579 /// Name of the topic to delete.
5580 ///
5581 /// Sets the *topic* path property to the given value.
5582 ///
5583 /// Even though the property as already been set when instantiating this call,
5584 /// we provide this method for API completeness.
5585 pub fn topic(mut self, new_value: &str) -> ProjectTopicDeleteCall<'a, C> {
5586 self._topic = new_value.to_string();
5587 self
5588 }
5589 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5590 /// while executing the actual API request.
5591 ///
5592 /// ````text
5593 /// It should be used to handle progress information, and to implement a certain level of resilience.
5594 /// ````
5595 ///
5596 /// Sets the *delegate* property to the given value.
5597 pub fn delegate(
5598 mut self,
5599 new_value: &'a mut dyn common::Delegate,
5600 ) -> ProjectTopicDeleteCall<'a, C> {
5601 self._delegate = Some(new_value);
5602 self
5603 }
5604
5605 /// Set any additional parameter of the query string used in the request.
5606 /// It should be used to set parameters which are not yet available through their own
5607 /// setters.
5608 ///
5609 /// Please note that this method must not be used to set any of the known parameters
5610 /// which have their own setter method. If done anyway, the request will fail.
5611 ///
5612 /// # Additional Parameters
5613 ///
5614 /// * *$.xgafv* (query-string) - V1 error format.
5615 /// * *access_token* (query-string) - OAuth access token.
5616 /// * *alt* (query-string) - Data format for response.
5617 /// * *callback* (query-string) - JSONP
5618 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5619 /// * *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.
5620 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5621 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5622 /// * *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.
5623 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5624 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5625 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicDeleteCall<'a, C>
5626 where
5627 T: AsRef<str>,
5628 {
5629 self._additional_params
5630 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5631 self
5632 }
5633
5634 /// Identifies the authorization scope for the method you are building.
5635 ///
5636 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5637 /// [`Scope::CloudPlatform`].
5638 ///
5639 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5640 /// tokens for more than one scope.
5641 ///
5642 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5643 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5644 /// sufficient, a read-write scope will do as well.
5645 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicDeleteCall<'a, C>
5646 where
5647 St: AsRef<str>,
5648 {
5649 self._scopes.insert(String::from(scope.as_ref()));
5650 self
5651 }
5652 /// Identifies the authorization scope(s) for the method you are building.
5653 ///
5654 /// See [`Self::add_scope()`] for details.
5655 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicDeleteCall<'a, C>
5656 where
5657 I: IntoIterator<Item = St>,
5658 St: AsRef<str>,
5659 {
5660 self._scopes
5661 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5662 self
5663 }
5664
5665 /// Removes all scopes, and no default scope will be used either.
5666 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5667 /// for details).
5668 pub fn clear_scopes(mut self) -> ProjectTopicDeleteCall<'a, C> {
5669 self._scopes.clear();
5670 self
5671 }
5672}
5673
5674/// Gets the configuration of a topic.
5675///
5676/// A builder for the *topics.get* method supported by a *project* resource.
5677/// It is not used directly, but through a [`ProjectMethods`] instance.
5678///
5679/// # Example
5680///
5681/// Instantiate a resource method builder
5682///
5683/// ```test_harness,no_run
5684/// # extern crate hyper;
5685/// # extern crate hyper_rustls;
5686/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
5687/// # async fn dox() {
5688/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5689///
5690/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5691/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5692/// # .with_native_roots()
5693/// # .unwrap()
5694/// # .https_only()
5695/// # .enable_http2()
5696/// # .build();
5697///
5698/// # let executor = hyper_util::rt::TokioExecutor::new();
5699/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5700/// # secret,
5701/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5702/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5703/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5704/// # ),
5705/// # ).build().await.unwrap();
5706///
5707/// # let client = hyper_util::client::legacy::Client::builder(
5708/// # hyper_util::rt::TokioExecutor::new()
5709/// # )
5710/// # .build(
5711/// # hyper_rustls::HttpsConnectorBuilder::new()
5712/// # .with_native_roots()
5713/// # .unwrap()
5714/// # .https_or_http()
5715/// # .enable_http2()
5716/// # .build()
5717/// # );
5718/// # let mut hub = Pubsub::new(client, auth);
5719/// // You can configure optional parameters by calling the respective setters at will, and
5720/// // execute the final call using `doit()`.
5721/// // Values shown here are possibly random and not representative !
5722/// let result = hub.projects().topics_get("topic")
5723/// .doit().await;
5724/// # }
5725/// ```
5726pub struct ProjectTopicGetCall<'a, C>
5727where
5728 C: 'a,
5729{
5730 hub: &'a Pubsub<C>,
5731 _topic: String,
5732 _delegate: Option<&'a mut dyn common::Delegate>,
5733 _additional_params: HashMap<String, String>,
5734 _scopes: BTreeSet<String>,
5735}
5736
5737impl<'a, C> common::CallBuilder for ProjectTopicGetCall<'a, C> {}
5738
5739impl<'a, C> ProjectTopicGetCall<'a, C>
5740where
5741 C: common::Connector,
5742{
5743 /// Perform the operation you have build so far.
5744 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
5745 use std::borrow::Cow;
5746 use std::io::{Read, Seek};
5747
5748 use common::{url::Params, ToParts};
5749 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5750
5751 let mut dd = common::DefaultDelegate;
5752 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5753 dlg.begin(common::MethodInfo {
5754 id: "pubsub.projects.topics.get",
5755 http_method: hyper::Method::GET,
5756 });
5757
5758 for &field in ["alt", "topic"].iter() {
5759 if self._additional_params.contains_key(field) {
5760 dlg.finished(false);
5761 return Err(common::Error::FieldClash(field));
5762 }
5763 }
5764
5765 let mut params = Params::with_capacity(3 + self._additional_params.len());
5766 params.push("topic", self._topic);
5767
5768 params.extend(self._additional_params.iter());
5769
5770 params.push("alt", "json");
5771 let mut url = self.hub._base_url.clone() + "v1beta2/{+topic}";
5772 if self._scopes.is_empty() {
5773 self._scopes
5774 .insert(Scope::CloudPlatform.as_ref().to_string());
5775 }
5776
5777 #[allow(clippy::single_element_loop)]
5778 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
5779 url = params.uri_replacement(url, param_name, find_this, true);
5780 }
5781 {
5782 let to_remove = ["topic"];
5783 params.remove_params(&to_remove);
5784 }
5785
5786 let url = params.parse_with_url(&url);
5787
5788 loop {
5789 let token = match self
5790 .hub
5791 .auth
5792 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5793 .await
5794 {
5795 Ok(token) => token,
5796 Err(e) => match dlg.token(e) {
5797 Ok(token) => token,
5798 Err(e) => {
5799 dlg.finished(false);
5800 return Err(common::Error::MissingToken(e));
5801 }
5802 },
5803 };
5804 let mut req_result = {
5805 let client = &self.hub.client;
5806 dlg.pre_request();
5807 let mut req_builder = hyper::Request::builder()
5808 .method(hyper::Method::GET)
5809 .uri(url.as_str())
5810 .header(USER_AGENT, self.hub._user_agent.clone());
5811
5812 if let Some(token) = token.as_ref() {
5813 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5814 }
5815
5816 let request = req_builder
5817 .header(CONTENT_LENGTH, 0_u64)
5818 .body(common::to_body::<String>(None));
5819
5820 client.request(request.unwrap()).await
5821 };
5822
5823 match req_result {
5824 Err(err) => {
5825 if let common::Retry::After(d) = dlg.http_error(&err) {
5826 sleep(d).await;
5827 continue;
5828 }
5829 dlg.finished(false);
5830 return Err(common::Error::HttpError(err));
5831 }
5832 Ok(res) => {
5833 let (mut parts, body) = res.into_parts();
5834 let mut body = common::Body::new(body);
5835 if !parts.status.is_success() {
5836 let bytes = common::to_bytes(body).await.unwrap_or_default();
5837 let error = serde_json::from_str(&common::to_string(&bytes));
5838 let response = common::to_response(parts, bytes.into());
5839
5840 if let common::Retry::After(d) =
5841 dlg.http_failure(&response, error.as_ref().ok())
5842 {
5843 sleep(d).await;
5844 continue;
5845 }
5846
5847 dlg.finished(false);
5848
5849 return Err(match error {
5850 Ok(value) => common::Error::BadRequest(value),
5851 _ => common::Error::Failure(response),
5852 });
5853 }
5854 let response = {
5855 let bytes = common::to_bytes(body).await.unwrap_or_default();
5856 let encoded = common::to_string(&bytes);
5857 match serde_json::from_str(&encoded) {
5858 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5859 Err(error) => {
5860 dlg.response_json_decode_error(&encoded, &error);
5861 return Err(common::Error::JsonDecodeError(
5862 encoded.to_string(),
5863 error,
5864 ));
5865 }
5866 }
5867 };
5868
5869 dlg.finished(true);
5870 return Ok(response);
5871 }
5872 }
5873 }
5874 }
5875
5876 /// The name of the topic to get.
5877 ///
5878 /// Sets the *topic* path property to the given value.
5879 ///
5880 /// Even though the property as already been set when instantiating this call,
5881 /// we provide this method for API completeness.
5882 pub fn topic(mut self, new_value: &str) -> ProjectTopicGetCall<'a, C> {
5883 self._topic = new_value.to_string();
5884 self
5885 }
5886 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5887 /// while executing the actual API request.
5888 ///
5889 /// ````text
5890 /// It should be used to handle progress information, and to implement a certain level of resilience.
5891 /// ````
5892 ///
5893 /// Sets the *delegate* property to the given value.
5894 pub fn delegate(
5895 mut self,
5896 new_value: &'a mut dyn common::Delegate,
5897 ) -> ProjectTopicGetCall<'a, C> {
5898 self._delegate = Some(new_value);
5899 self
5900 }
5901
5902 /// Set any additional parameter of the query string used in the request.
5903 /// It should be used to set parameters which are not yet available through their own
5904 /// setters.
5905 ///
5906 /// Please note that this method must not be used to set any of the known parameters
5907 /// which have their own setter method. If done anyway, the request will fail.
5908 ///
5909 /// # Additional Parameters
5910 ///
5911 /// * *$.xgafv* (query-string) - V1 error format.
5912 /// * *access_token* (query-string) - OAuth access token.
5913 /// * *alt* (query-string) - Data format for response.
5914 /// * *callback* (query-string) - JSONP
5915 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5916 /// * *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.
5917 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5918 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5919 /// * *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.
5920 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5921 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5922 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicGetCall<'a, C>
5923 where
5924 T: AsRef<str>,
5925 {
5926 self._additional_params
5927 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5928 self
5929 }
5930
5931 /// Identifies the authorization scope for the method you are building.
5932 ///
5933 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5934 /// [`Scope::CloudPlatform`].
5935 ///
5936 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5937 /// tokens for more than one scope.
5938 ///
5939 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5940 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5941 /// sufficient, a read-write scope will do as well.
5942 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicGetCall<'a, C>
5943 where
5944 St: AsRef<str>,
5945 {
5946 self._scopes.insert(String::from(scope.as_ref()));
5947 self
5948 }
5949 /// Identifies the authorization scope(s) for the method you are building.
5950 ///
5951 /// See [`Self::add_scope()`] for details.
5952 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicGetCall<'a, C>
5953 where
5954 I: IntoIterator<Item = St>,
5955 St: AsRef<str>,
5956 {
5957 self._scopes
5958 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5959 self
5960 }
5961
5962 /// Removes all scopes, and no default scope will be used either.
5963 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5964 /// for details).
5965 pub fn clear_scopes(mut self) -> ProjectTopicGetCall<'a, C> {
5966 self._scopes.clear();
5967 self
5968 }
5969}
5970
5971/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
5972///
5973/// A builder for the *topics.getIamPolicy* method supported by a *project* resource.
5974/// It is not used directly, but through a [`ProjectMethods`] instance.
5975///
5976/// # Example
5977///
5978/// Instantiate a resource method builder
5979///
5980/// ```test_harness,no_run
5981/// # extern crate hyper;
5982/// # extern crate hyper_rustls;
5983/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
5984/// # async fn dox() {
5985/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5986///
5987/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5988/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5989/// # .with_native_roots()
5990/// # .unwrap()
5991/// # .https_only()
5992/// # .enable_http2()
5993/// # .build();
5994///
5995/// # let executor = hyper_util::rt::TokioExecutor::new();
5996/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5997/// # secret,
5998/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5999/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6000/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6001/// # ),
6002/// # ).build().await.unwrap();
6003///
6004/// # let client = hyper_util::client::legacy::Client::builder(
6005/// # hyper_util::rt::TokioExecutor::new()
6006/// # )
6007/// # .build(
6008/// # hyper_rustls::HttpsConnectorBuilder::new()
6009/// # .with_native_roots()
6010/// # .unwrap()
6011/// # .https_or_http()
6012/// # .enable_http2()
6013/// # .build()
6014/// # );
6015/// # let mut hub = Pubsub::new(client, auth);
6016/// // You can configure optional parameters by calling the respective setters at will, and
6017/// // execute the final call using `doit()`.
6018/// // Values shown here are possibly random and not representative !
6019/// let result = hub.projects().topics_get_iam_policy("resource")
6020/// .options_requested_policy_version(-93)
6021/// .doit().await;
6022/// # }
6023/// ```
6024pub struct ProjectTopicGetIamPolicyCall<'a, C>
6025where
6026 C: 'a,
6027{
6028 hub: &'a Pubsub<C>,
6029 _resource: String,
6030 _options_requested_policy_version: Option<i32>,
6031 _delegate: Option<&'a mut dyn common::Delegate>,
6032 _additional_params: HashMap<String, String>,
6033 _scopes: BTreeSet<String>,
6034}
6035
6036impl<'a, C> common::CallBuilder for ProjectTopicGetIamPolicyCall<'a, C> {}
6037
6038impl<'a, C> ProjectTopicGetIamPolicyCall<'a, C>
6039where
6040 C: common::Connector,
6041{
6042 /// Perform the operation you have build so far.
6043 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6044 use std::borrow::Cow;
6045 use std::io::{Read, Seek};
6046
6047 use common::{url::Params, ToParts};
6048 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6049
6050 let mut dd = common::DefaultDelegate;
6051 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6052 dlg.begin(common::MethodInfo {
6053 id: "pubsub.projects.topics.getIamPolicy",
6054 http_method: hyper::Method::GET,
6055 });
6056
6057 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
6058 if self._additional_params.contains_key(field) {
6059 dlg.finished(false);
6060 return Err(common::Error::FieldClash(field));
6061 }
6062 }
6063
6064 let mut params = Params::with_capacity(4 + self._additional_params.len());
6065 params.push("resource", self._resource);
6066 if let Some(value) = self._options_requested_policy_version.as_ref() {
6067 params.push("options.requestedPolicyVersion", value.to_string());
6068 }
6069
6070 params.extend(self._additional_params.iter());
6071
6072 params.push("alt", "json");
6073 let mut url = self.hub._base_url.clone() + "v1beta2/{+resource}:getIamPolicy";
6074 if self._scopes.is_empty() {
6075 self._scopes
6076 .insert(Scope::CloudPlatform.as_ref().to_string());
6077 }
6078
6079 #[allow(clippy::single_element_loop)]
6080 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6081 url = params.uri_replacement(url, param_name, find_this, true);
6082 }
6083 {
6084 let to_remove = ["resource"];
6085 params.remove_params(&to_remove);
6086 }
6087
6088 let url = params.parse_with_url(&url);
6089
6090 loop {
6091 let token = match self
6092 .hub
6093 .auth
6094 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6095 .await
6096 {
6097 Ok(token) => token,
6098 Err(e) => match dlg.token(e) {
6099 Ok(token) => token,
6100 Err(e) => {
6101 dlg.finished(false);
6102 return Err(common::Error::MissingToken(e));
6103 }
6104 },
6105 };
6106 let mut req_result = {
6107 let client = &self.hub.client;
6108 dlg.pre_request();
6109 let mut req_builder = hyper::Request::builder()
6110 .method(hyper::Method::GET)
6111 .uri(url.as_str())
6112 .header(USER_AGENT, self.hub._user_agent.clone());
6113
6114 if let Some(token) = token.as_ref() {
6115 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6116 }
6117
6118 let request = req_builder
6119 .header(CONTENT_LENGTH, 0_u64)
6120 .body(common::to_body::<String>(None));
6121
6122 client.request(request.unwrap()).await
6123 };
6124
6125 match req_result {
6126 Err(err) => {
6127 if let common::Retry::After(d) = dlg.http_error(&err) {
6128 sleep(d).await;
6129 continue;
6130 }
6131 dlg.finished(false);
6132 return Err(common::Error::HttpError(err));
6133 }
6134 Ok(res) => {
6135 let (mut parts, body) = res.into_parts();
6136 let mut body = common::Body::new(body);
6137 if !parts.status.is_success() {
6138 let bytes = common::to_bytes(body).await.unwrap_or_default();
6139 let error = serde_json::from_str(&common::to_string(&bytes));
6140 let response = common::to_response(parts, bytes.into());
6141
6142 if let common::Retry::After(d) =
6143 dlg.http_failure(&response, error.as_ref().ok())
6144 {
6145 sleep(d).await;
6146 continue;
6147 }
6148
6149 dlg.finished(false);
6150
6151 return Err(match error {
6152 Ok(value) => common::Error::BadRequest(value),
6153 _ => common::Error::Failure(response),
6154 });
6155 }
6156 let response = {
6157 let bytes = common::to_bytes(body).await.unwrap_or_default();
6158 let encoded = common::to_string(&bytes);
6159 match serde_json::from_str(&encoded) {
6160 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6161 Err(error) => {
6162 dlg.response_json_decode_error(&encoded, &error);
6163 return Err(common::Error::JsonDecodeError(
6164 encoded.to_string(),
6165 error,
6166 ));
6167 }
6168 }
6169 };
6170
6171 dlg.finished(true);
6172 return Ok(response);
6173 }
6174 }
6175 }
6176 }
6177
6178 /// 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.
6179 ///
6180 /// Sets the *resource* path property to the given value.
6181 ///
6182 /// Even though the property as already been set when instantiating this call,
6183 /// we provide this method for API completeness.
6184 pub fn resource(mut self, new_value: &str) -> ProjectTopicGetIamPolicyCall<'a, C> {
6185 self._resource = new_value.to_string();
6186 self
6187 }
6188 /// 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).
6189 ///
6190 /// Sets the *options.requested policy version* query property to the given value.
6191 pub fn options_requested_policy_version(
6192 mut self,
6193 new_value: i32,
6194 ) -> ProjectTopicGetIamPolicyCall<'a, C> {
6195 self._options_requested_policy_version = Some(new_value);
6196 self
6197 }
6198 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6199 /// while executing the actual API request.
6200 ///
6201 /// ````text
6202 /// It should be used to handle progress information, and to implement a certain level of resilience.
6203 /// ````
6204 ///
6205 /// Sets the *delegate* property to the given value.
6206 pub fn delegate(
6207 mut self,
6208 new_value: &'a mut dyn common::Delegate,
6209 ) -> ProjectTopicGetIamPolicyCall<'a, C> {
6210 self._delegate = Some(new_value);
6211 self
6212 }
6213
6214 /// Set any additional parameter of the query string used in the request.
6215 /// It should be used to set parameters which are not yet available through their own
6216 /// setters.
6217 ///
6218 /// Please note that this method must not be used to set any of the known parameters
6219 /// which have their own setter method. If done anyway, the request will fail.
6220 ///
6221 /// # Additional Parameters
6222 ///
6223 /// * *$.xgafv* (query-string) - V1 error format.
6224 /// * *access_token* (query-string) - OAuth access token.
6225 /// * *alt* (query-string) - Data format for response.
6226 /// * *callback* (query-string) - JSONP
6227 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6228 /// * *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.
6229 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6230 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6231 /// * *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.
6232 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6233 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6234 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicGetIamPolicyCall<'a, C>
6235 where
6236 T: AsRef<str>,
6237 {
6238 self._additional_params
6239 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6240 self
6241 }
6242
6243 /// Identifies the authorization scope for the method you are building.
6244 ///
6245 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6246 /// [`Scope::CloudPlatform`].
6247 ///
6248 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6249 /// tokens for more than one scope.
6250 ///
6251 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6252 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6253 /// sufficient, a read-write scope will do as well.
6254 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicGetIamPolicyCall<'a, C>
6255 where
6256 St: AsRef<str>,
6257 {
6258 self._scopes.insert(String::from(scope.as_ref()));
6259 self
6260 }
6261 /// Identifies the authorization scope(s) for the method you are building.
6262 ///
6263 /// See [`Self::add_scope()`] for details.
6264 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicGetIamPolicyCall<'a, C>
6265 where
6266 I: IntoIterator<Item = St>,
6267 St: AsRef<str>,
6268 {
6269 self._scopes
6270 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6271 self
6272 }
6273
6274 /// Removes all scopes, and no default scope will be used either.
6275 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6276 /// for details).
6277 pub fn clear_scopes(mut self) -> ProjectTopicGetIamPolicyCall<'a, C> {
6278 self._scopes.clear();
6279 self
6280 }
6281}
6282
6283/// Lists matching topics.
6284///
6285/// A builder for the *topics.list* method supported by a *project* resource.
6286/// It is not used directly, but through a [`ProjectMethods`] instance.
6287///
6288/// # Example
6289///
6290/// Instantiate a resource method builder
6291///
6292/// ```test_harness,no_run
6293/// # extern crate hyper;
6294/// # extern crate hyper_rustls;
6295/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
6296/// # async fn dox() {
6297/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6298///
6299/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6300/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6301/// # .with_native_roots()
6302/// # .unwrap()
6303/// # .https_only()
6304/// # .enable_http2()
6305/// # .build();
6306///
6307/// # let executor = hyper_util::rt::TokioExecutor::new();
6308/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6309/// # secret,
6310/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6311/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6312/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6313/// # ),
6314/// # ).build().await.unwrap();
6315///
6316/// # let client = hyper_util::client::legacy::Client::builder(
6317/// # hyper_util::rt::TokioExecutor::new()
6318/// # )
6319/// # .build(
6320/// # hyper_rustls::HttpsConnectorBuilder::new()
6321/// # .with_native_roots()
6322/// # .unwrap()
6323/// # .https_or_http()
6324/// # .enable_http2()
6325/// # .build()
6326/// # );
6327/// # let mut hub = Pubsub::new(client, auth);
6328/// // You can configure optional parameters by calling the respective setters at will, and
6329/// // execute the final call using `doit()`.
6330/// // Values shown here are possibly random and not representative !
6331/// let result = hub.projects().topics_list("project")
6332/// .page_token("gubergren")
6333/// .page_size(-16)
6334/// .doit().await;
6335/// # }
6336/// ```
6337pub struct ProjectTopicListCall<'a, C>
6338where
6339 C: 'a,
6340{
6341 hub: &'a Pubsub<C>,
6342 _project: String,
6343 _page_token: Option<String>,
6344 _page_size: Option<i32>,
6345 _delegate: Option<&'a mut dyn common::Delegate>,
6346 _additional_params: HashMap<String, String>,
6347 _scopes: BTreeSet<String>,
6348}
6349
6350impl<'a, C> common::CallBuilder for ProjectTopicListCall<'a, C> {}
6351
6352impl<'a, C> ProjectTopicListCall<'a, C>
6353where
6354 C: common::Connector,
6355{
6356 /// Perform the operation you have build so far.
6357 pub async fn doit(mut self) -> common::Result<(common::Response, ListTopicsResponse)> {
6358 use std::borrow::Cow;
6359 use std::io::{Read, Seek};
6360
6361 use common::{url::Params, ToParts};
6362 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6363
6364 let mut dd = common::DefaultDelegate;
6365 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6366 dlg.begin(common::MethodInfo {
6367 id: "pubsub.projects.topics.list",
6368 http_method: hyper::Method::GET,
6369 });
6370
6371 for &field in ["alt", "project", "pageToken", "pageSize"].iter() {
6372 if self._additional_params.contains_key(field) {
6373 dlg.finished(false);
6374 return Err(common::Error::FieldClash(field));
6375 }
6376 }
6377
6378 let mut params = Params::with_capacity(5 + self._additional_params.len());
6379 params.push("project", self._project);
6380 if let Some(value) = self._page_token.as_ref() {
6381 params.push("pageToken", value);
6382 }
6383 if let Some(value) = self._page_size.as_ref() {
6384 params.push("pageSize", value.to_string());
6385 }
6386
6387 params.extend(self._additional_params.iter());
6388
6389 params.push("alt", "json");
6390 let mut url = self.hub._base_url.clone() + "v1beta2/{+project}/topics";
6391 if self._scopes.is_empty() {
6392 self._scopes
6393 .insert(Scope::CloudPlatform.as_ref().to_string());
6394 }
6395
6396 #[allow(clippy::single_element_loop)]
6397 for &(find_this, param_name) in [("{+project}", "project")].iter() {
6398 url = params.uri_replacement(url, param_name, find_this, true);
6399 }
6400 {
6401 let to_remove = ["project"];
6402 params.remove_params(&to_remove);
6403 }
6404
6405 let url = params.parse_with_url(&url);
6406
6407 loop {
6408 let token = match self
6409 .hub
6410 .auth
6411 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6412 .await
6413 {
6414 Ok(token) => token,
6415 Err(e) => match dlg.token(e) {
6416 Ok(token) => token,
6417 Err(e) => {
6418 dlg.finished(false);
6419 return Err(common::Error::MissingToken(e));
6420 }
6421 },
6422 };
6423 let mut req_result = {
6424 let client = &self.hub.client;
6425 dlg.pre_request();
6426 let mut req_builder = hyper::Request::builder()
6427 .method(hyper::Method::GET)
6428 .uri(url.as_str())
6429 .header(USER_AGENT, self.hub._user_agent.clone());
6430
6431 if let Some(token) = token.as_ref() {
6432 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6433 }
6434
6435 let request = req_builder
6436 .header(CONTENT_LENGTH, 0_u64)
6437 .body(common::to_body::<String>(None));
6438
6439 client.request(request.unwrap()).await
6440 };
6441
6442 match req_result {
6443 Err(err) => {
6444 if let common::Retry::After(d) = dlg.http_error(&err) {
6445 sleep(d).await;
6446 continue;
6447 }
6448 dlg.finished(false);
6449 return Err(common::Error::HttpError(err));
6450 }
6451 Ok(res) => {
6452 let (mut parts, body) = res.into_parts();
6453 let mut body = common::Body::new(body);
6454 if !parts.status.is_success() {
6455 let bytes = common::to_bytes(body).await.unwrap_or_default();
6456 let error = serde_json::from_str(&common::to_string(&bytes));
6457 let response = common::to_response(parts, bytes.into());
6458
6459 if let common::Retry::After(d) =
6460 dlg.http_failure(&response, error.as_ref().ok())
6461 {
6462 sleep(d).await;
6463 continue;
6464 }
6465
6466 dlg.finished(false);
6467
6468 return Err(match error {
6469 Ok(value) => common::Error::BadRequest(value),
6470 _ => common::Error::Failure(response),
6471 });
6472 }
6473 let response = {
6474 let bytes = common::to_bytes(body).await.unwrap_or_default();
6475 let encoded = common::to_string(&bytes);
6476 match serde_json::from_str(&encoded) {
6477 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6478 Err(error) => {
6479 dlg.response_json_decode_error(&encoded, &error);
6480 return Err(common::Error::JsonDecodeError(
6481 encoded.to_string(),
6482 error,
6483 ));
6484 }
6485 }
6486 };
6487
6488 dlg.finished(true);
6489 return Ok(response);
6490 }
6491 }
6492 }
6493 }
6494
6495 /// The name of the cloud project that topics belong to.
6496 ///
6497 /// Sets the *project* 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 project(mut self, new_value: &str) -> ProjectTopicListCall<'a, C> {
6502 self._project = new_value.to_string();
6503 self
6504 }
6505 /// 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.
6506 ///
6507 /// Sets the *page token* query property to the given value.
6508 pub fn page_token(mut self, new_value: &str) -> ProjectTopicListCall<'a, C> {
6509 self._page_token = Some(new_value.to_string());
6510 self
6511 }
6512 /// Maximum number of topics to return.
6513 ///
6514 /// Sets the *page size* query property to the given value.
6515 pub fn page_size(mut self, new_value: i32) -> ProjectTopicListCall<'a, C> {
6516 self._page_size = Some(new_value);
6517 self
6518 }
6519 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6520 /// while executing the actual API request.
6521 ///
6522 /// ````text
6523 /// It should be used to handle progress information, and to implement a certain level of resilience.
6524 /// ````
6525 ///
6526 /// Sets the *delegate* property to the given value.
6527 pub fn delegate(
6528 mut self,
6529 new_value: &'a mut dyn common::Delegate,
6530 ) -> ProjectTopicListCall<'a, C> {
6531 self._delegate = Some(new_value);
6532 self
6533 }
6534
6535 /// Set any additional parameter of the query string used in the request.
6536 /// It should be used to set parameters which are not yet available through their own
6537 /// setters.
6538 ///
6539 /// Please note that this method must not be used to set any of the known parameters
6540 /// which have their own setter method. If done anyway, the request will fail.
6541 ///
6542 /// # Additional Parameters
6543 ///
6544 /// * *$.xgafv* (query-string) - V1 error format.
6545 /// * *access_token* (query-string) - OAuth access token.
6546 /// * *alt* (query-string) - Data format for response.
6547 /// * *callback* (query-string) - JSONP
6548 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6549 /// * *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.
6550 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6551 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6552 /// * *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.
6553 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6554 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6555 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicListCall<'a, C>
6556 where
6557 T: AsRef<str>,
6558 {
6559 self._additional_params
6560 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6561 self
6562 }
6563
6564 /// Identifies the authorization scope for the method you are building.
6565 ///
6566 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6567 /// [`Scope::CloudPlatform`].
6568 ///
6569 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6570 /// tokens for more than one scope.
6571 ///
6572 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6573 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6574 /// sufficient, a read-write scope will do as well.
6575 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicListCall<'a, C>
6576 where
6577 St: AsRef<str>,
6578 {
6579 self._scopes.insert(String::from(scope.as_ref()));
6580 self
6581 }
6582 /// Identifies the authorization scope(s) for the method you are building.
6583 ///
6584 /// See [`Self::add_scope()`] for details.
6585 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicListCall<'a, C>
6586 where
6587 I: IntoIterator<Item = St>,
6588 St: AsRef<str>,
6589 {
6590 self._scopes
6591 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6592 self
6593 }
6594
6595 /// Removes all scopes, and no default scope will be used either.
6596 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6597 /// for details).
6598 pub fn clear_scopes(mut self) -> ProjectTopicListCall<'a, C> {
6599 self._scopes.clear();
6600 self
6601 }
6602}
6603
6604/// Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist. The message payload must not be empty; it must contain either a non-empty data field, or at least one attribute.
6605///
6606/// A builder for the *topics.publish* method supported by a *project* resource.
6607/// It is not used directly, but through a [`ProjectMethods`] instance.
6608///
6609/// # Example
6610///
6611/// Instantiate a resource method builder
6612///
6613/// ```test_harness,no_run
6614/// # extern crate hyper;
6615/// # extern crate hyper_rustls;
6616/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
6617/// use pubsub1_beta2::api::PublishRequest;
6618/// # async fn dox() {
6619/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6620///
6621/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6622/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6623/// # .with_native_roots()
6624/// # .unwrap()
6625/// # .https_only()
6626/// # .enable_http2()
6627/// # .build();
6628///
6629/// # let executor = hyper_util::rt::TokioExecutor::new();
6630/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6631/// # secret,
6632/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6633/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6634/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6635/// # ),
6636/// # ).build().await.unwrap();
6637///
6638/// # let client = hyper_util::client::legacy::Client::builder(
6639/// # hyper_util::rt::TokioExecutor::new()
6640/// # )
6641/// # .build(
6642/// # hyper_rustls::HttpsConnectorBuilder::new()
6643/// # .with_native_roots()
6644/// # .unwrap()
6645/// # .https_or_http()
6646/// # .enable_http2()
6647/// # .build()
6648/// # );
6649/// # let mut hub = Pubsub::new(client, auth);
6650/// // As the method needs a request, you would usually fill it with the desired information
6651/// // into the respective structure. Some of the parts shown here might not be applicable !
6652/// // Values shown here are possibly random and not representative !
6653/// let mut req = PublishRequest::default();
6654///
6655/// // You can configure optional parameters by calling the respective setters at will, and
6656/// // execute the final call using `doit()`.
6657/// // Values shown here are possibly random and not representative !
6658/// let result = hub.projects().topics_publish(req, "topic")
6659/// .doit().await;
6660/// # }
6661/// ```
6662pub struct ProjectTopicPublishCall<'a, C>
6663where
6664 C: 'a,
6665{
6666 hub: &'a Pubsub<C>,
6667 _request: PublishRequest,
6668 _topic: String,
6669 _delegate: Option<&'a mut dyn common::Delegate>,
6670 _additional_params: HashMap<String, String>,
6671 _scopes: BTreeSet<String>,
6672}
6673
6674impl<'a, C> common::CallBuilder for ProjectTopicPublishCall<'a, C> {}
6675
6676impl<'a, C> ProjectTopicPublishCall<'a, C>
6677where
6678 C: common::Connector,
6679{
6680 /// Perform the operation you have build so far.
6681 pub async fn doit(mut self) -> common::Result<(common::Response, PublishResponse)> {
6682 use std::borrow::Cow;
6683 use std::io::{Read, Seek};
6684
6685 use common::{url::Params, ToParts};
6686 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6687
6688 let mut dd = common::DefaultDelegate;
6689 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6690 dlg.begin(common::MethodInfo {
6691 id: "pubsub.projects.topics.publish",
6692 http_method: hyper::Method::POST,
6693 });
6694
6695 for &field in ["alt", "topic"].iter() {
6696 if self._additional_params.contains_key(field) {
6697 dlg.finished(false);
6698 return Err(common::Error::FieldClash(field));
6699 }
6700 }
6701
6702 let mut params = Params::with_capacity(4 + self._additional_params.len());
6703 params.push("topic", self._topic);
6704
6705 params.extend(self._additional_params.iter());
6706
6707 params.push("alt", "json");
6708 let mut url = self.hub._base_url.clone() + "v1beta2/{+topic}:publish";
6709 if self._scopes.is_empty() {
6710 self._scopes
6711 .insert(Scope::CloudPlatform.as_ref().to_string());
6712 }
6713
6714 #[allow(clippy::single_element_loop)]
6715 for &(find_this, param_name) in [("{+topic}", "topic")].iter() {
6716 url = params.uri_replacement(url, param_name, find_this, true);
6717 }
6718 {
6719 let to_remove = ["topic"];
6720 params.remove_params(&to_remove);
6721 }
6722
6723 let url = params.parse_with_url(&url);
6724
6725 let mut json_mime_type = mime::APPLICATION_JSON;
6726 let mut request_value_reader = {
6727 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6728 common::remove_json_null_values(&mut value);
6729 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6730 serde_json::to_writer(&mut dst, &value).unwrap();
6731 dst
6732 };
6733 let request_size = request_value_reader
6734 .seek(std::io::SeekFrom::End(0))
6735 .unwrap();
6736 request_value_reader
6737 .seek(std::io::SeekFrom::Start(0))
6738 .unwrap();
6739
6740 loop {
6741 let token = match self
6742 .hub
6743 .auth
6744 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6745 .await
6746 {
6747 Ok(token) => token,
6748 Err(e) => match dlg.token(e) {
6749 Ok(token) => token,
6750 Err(e) => {
6751 dlg.finished(false);
6752 return Err(common::Error::MissingToken(e));
6753 }
6754 },
6755 };
6756 request_value_reader
6757 .seek(std::io::SeekFrom::Start(0))
6758 .unwrap();
6759 let mut req_result = {
6760 let client = &self.hub.client;
6761 dlg.pre_request();
6762 let mut req_builder = hyper::Request::builder()
6763 .method(hyper::Method::POST)
6764 .uri(url.as_str())
6765 .header(USER_AGENT, self.hub._user_agent.clone());
6766
6767 if let Some(token) = token.as_ref() {
6768 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6769 }
6770
6771 let request = req_builder
6772 .header(CONTENT_TYPE, json_mime_type.to_string())
6773 .header(CONTENT_LENGTH, request_size as u64)
6774 .body(common::to_body(
6775 request_value_reader.get_ref().clone().into(),
6776 ));
6777
6778 client.request(request.unwrap()).await
6779 };
6780
6781 match req_result {
6782 Err(err) => {
6783 if let common::Retry::After(d) = dlg.http_error(&err) {
6784 sleep(d).await;
6785 continue;
6786 }
6787 dlg.finished(false);
6788 return Err(common::Error::HttpError(err));
6789 }
6790 Ok(res) => {
6791 let (mut parts, body) = res.into_parts();
6792 let mut body = common::Body::new(body);
6793 if !parts.status.is_success() {
6794 let bytes = common::to_bytes(body).await.unwrap_or_default();
6795 let error = serde_json::from_str(&common::to_string(&bytes));
6796 let response = common::to_response(parts, bytes.into());
6797
6798 if let common::Retry::After(d) =
6799 dlg.http_failure(&response, error.as_ref().ok())
6800 {
6801 sleep(d).await;
6802 continue;
6803 }
6804
6805 dlg.finished(false);
6806
6807 return Err(match error {
6808 Ok(value) => common::Error::BadRequest(value),
6809 _ => common::Error::Failure(response),
6810 });
6811 }
6812 let response = {
6813 let bytes = common::to_bytes(body).await.unwrap_or_default();
6814 let encoded = common::to_string(&bytes);
6815 match serde_json::from_str(&encoded) {
6816 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6817 Err(error) => {
6818 dlg.response_json_decode_error(&encoded, &error);
6819 return Err(common::Error::JsonDecodeError(
6820 encoded.to_string(),
6821 error,
6822 ));
6823 }
6824 }
6825 };
6826
6827 dlg.finished(true);
6828 return Ok(response);
6829 }
6830 }
6831 }
6832 }
6833
6834 ///
6835 /// Sets the *request* property to the given value.
6836 ///
6837 /// Even though the property as already been set when instantiating this call,
6838 /// we provide this method for API completeness.
6839 pub fn request(mut self, new_value: PublishRequest) -> ProjectTopicPublishCall<'a, C> {
6840 self._request = new_value;
6841 self
6842 }
6843 /// The messages in the request will be published on this topic.
6844 ///
6845 /// Sets the *topic* path property to the given value.
6846 ///
6847 /// Even though the property as already been set when instantiating this call,
6848 /// we provide this method for API completeness.
6849 pub fn topic(mut self, new_value: &str) -> ProjectTopicPublishCall<'a, C> {
6850 self._topic = new_value.to_string();
6851 self
6852 }
6853 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6854 /// while executing the actual API request.
6855 ///
6856 /// ````text
6857 /// It should be used to handle progress information, and to implement a certain level of resilience.
6858 /// ````
6859 ///
6860 /// Sets the *delegate* property to the given value.
6861 pub fn delegate(
6862 mut self,
6863 new_value: &'a mut dyn common::Delegate,
6864 ) -> ProjectTopicPublishCall<'a, C> {
6865 self._delegate = Some(new_value);
6866 self
6867 }
6868
6869 /// Set any additional parameter of the query string used in the request.
6870 /// It should be used to set parameters which are not yet available through their own
6871 /// setters.
6872 ///
6873 /// Please note that this method must not be used to set any of the known parameters
6874 /// which have their own setter method. If done anyway, the request will fail.
6875 ///
6876 /// # Additional Parameters
6877 ///
6878 /// * *$.xgafv* (query-string) - V1 error format.
6879 /// * *access_token* (query-string) - OAuth access token.
6880 /// * *alt* (query-string) - Data format for response.
6881 /// * *callback* (query-string) - JSONP
6882 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6883 /// * *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.
6884 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6885 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6886 /// * *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.
6887 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6888 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6889 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicPublishCall<'a, C>
6890 where
6891 T: AsRef<str>,
6892 {
6893 self._additional_params
6894 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6895 self
6896 }
6897
6898 /// Identifies the authorization scope for the method you are building.
6899 ///
6900 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6901 /// [`Scope::CloudPlatform`].
6902 ///
6903 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6904 /// tokens for more than one scope.
6905 ///
6906 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6907 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6908 /// sufficient, a read-write scope will do as well.
6909 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicPublishCall<'a, C>
6910 where
6911 St: AsRef<str>,
6912 {
6913 self._scopes.insert(String::from(scope.as_ref()));
6914 self
6915 }
6916 /// Identifies the authorization scope(s) for the method you are building.
6917 ///
6918 /// See [`Self::add_scope()`] for details.
6919 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicPublishCall<'a, C>
6920 where
6921 I: IntoIterator<Item = St>,
6922 St: AsRef<str>,
6923 {
6924 self._scopes
6925 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6926 self
6927 }
6928
6929 /// Removes all scopes, and no default scope will be used either.
6930 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6931 /// for details).
6932 pub fn clear_scopes(mut self) -> ProjectTopicPublishCall<'a, C> {
6933 self._scopes.clear();
6934 self
6935 }
6936}
6937
6938/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
6939///
6940/// A builder for the *topics.setIamPolicy* method supported by a *project* resource.
6941/// It is not used directly, but through a [`ProjectMethods`] instance.
6942///
6943/// # Example
6944///
6945/// Instantiate a resource method builder
6946///
6947/// ```test_harness,no_run
6948/// # extern crate hyper;
6949/// # extern crate hyper_rustls;
6950/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
6951/// use pubsub1_beta2::api::SetIamPolicyRequest;
6952/// # async fn dox() {
6953/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6954///
6955/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6956/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6957/// # .with_native_roots()
6958/// # .unwrap()
6959/// # .https_only()
6960/// # .enable_http2()
6961/// # .build();
6962///
6963/// # let executor = hyper_util::rt::TokioExecutor::new();
6964/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6965/// # secret,
6966/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6967/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6968/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6969/// # ),
6970/// # ).build().await.unwrap();
6971///
6972/// # let client = hyper_util::client::legacy::Client::builder(
6973/// # hyper_util::rt::TokioExecutor::new()
6974/// # )
6975/// # .build(
6976/// # hyper_rustls::HttpsConnectorBuilder::new()
6977/// # .with_native_roots()
6978/// # .unwrap()
6979/// # .https_or_http()
6980/// # .enable_http2()
6981/// # .build()
6982/// # );
6983/// # let mut hub = Pubsub::new(client, auth);
6984/// // As the method needs a request, you would usually fill it with the desired information
6985/// // into the respective structure. Some of the parts shown here might not be applicable !
6986/// // Values shown here are possibly random and not representative !
6987/// let mut req = SetIamPolicyRequest::default();
6988///
6989/// // You can configure optional parameters by calling the respective setters at will, and
6990/// // execute the final call using `doit()`.
6991/// // Values shown here are possibly random and not representative !
6992/// let result = hub.projects().topics_set_iam_policy(req, "resource")
6993/// .doit().await;
6994/// # }
6995/// ```
6996pub struct ProjectTopicSetIamPolicyCall<'a, C>
6997where
6998 C: 'a,
6999{
7000 hub: &'a Pubsub<C>,
7001 _request: SetIamPolicyRequest,
7002 _resource: String,
7003 _delegate: Option<&'a mut dyn common::Delegate>,
7004 _additional_params: HashMap<String, String>,
7005 _scopes: BTreeSet<String>,
7006}
7007
7008impl<'a, C> common::CallBuilder for ProjectTopicSetIamPolicyCall<'a, C> {}
7009
7010impl<'a, C> ProjectTopicSetIamPolicyCall<'a, C>
7011where
7012 C: common::Connector,
7013{
7014 /// Perform the operation you have build so far.
7015 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7016 use std::borrow::Cow;
7017 use std::io::{Read, Seek};
7018
7019 use common::{url::Params, ToParts};
7020 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7021
7022 let mut dd = common::DefaultDelegate;
7023 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7024 dlg.begin(common::MethodInfo {
7025 id: "pubsub.projects.topics.setIamPolicy",
7026 http_method: hyper::Method::POST,
7027 });
7028
7029 for &field in ["alt", "resource"].iter() {
7030 if self._additional_params.contains_key(field) {
7031 dlg.finished(false);
7032 return Err(common::Error::FieldClash(field));
7033 }
7034 }
7035
7036 let mut params = Params::with_capacity(4 + self._additional_params.len());
7037 params.push("resource", self._resource);
7038
7039 params.extend(self._additional_params.iter());
7040
7041 params.push("alt", "json");
7042 let mut url = self.hub._base_url.clone() + "v1beta2/{+resource}:setIamPolicy";
7043 if self._scopes.is_empty() {
7044 self._scopes
7045 .insert(Scope::CloudPlatform.as_ref().to_string());
7046 }
7047
7048 #[allow(clippy::single_element_loop)]
7049 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7050 url = params.uri_replacement(url, param_name, find_this, true);
7051 }
7052 {
7053 let to_remove = ["resource"];
7054 params.remove_params(&to_remove);
7055 }
7056
7057 let url = params.parse_with_url(&url);
7058
7059 let mut json_mime_type = mime::APPLICATION_JSON;
7060 let mut request_value_reader = {
7061 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7062 common::remove_json_null_values(&mut value);
7063 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7064 serde_json::to_writer(&mut dst, &value).unwrap();
7065 dst
7066 };
7067 let request_size = request_value_reader
7068 .seek(std::io::SeekFrom::End(0))
7069 .unwrap();
7070 request_value_reader
7071 .seek(std::io::SeekFrom::Start(0))
7072 .unwrap();
7073
7074 loop {
7075 let token = match self
7076 .hub
7077 .auth
7078 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7079 .await
7080 {
7081 Ok(token) => token,
7082 Err(e) => match dlg.token(e) {
7083 Ok(token) => token,
7084 Err(e) => {
7085 dlg.finished(false);
7086 return Err(common::Error::MissingToken(e));
7087 }
7088 },
7089 };
7090 request_value_reader
7091 .seek(std::io::SeekFrom::Start(0))
7092 .unwrap();
7093 let mut req_result = {
7094 let client = &self.hub.client;
7095 dlg.pre_request();
7096 let mut req_builder = hyper::Request::builder()
7097 .method(hyper::Method::POST)
7098 .uri(url.as_str())
7099 .header(USER_AGENT, self.hub._user_agent.clone());
7100
7101 if let Some(token) = token.as_ref() {
7102 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7103 }
7104
7105 let request = req_builder
7106 .header(CONTENT_TYPE, json_mime_type.to_string())
7107 .header(CONTENT_LENGTH, request_size as u64)
7108 .body(common::to_body(
7109 request_value_reader.get_ref().clone().into(),
7110 ));
7111
7112 client.request(request.unwrap()).await
7113 };
7114
7115 match req_result {
7116 Err(err) => {
7117 if let common::Retry::After(d) = dlg.http_error(&err) {
7118 sleep(d).await;
7119 continue;
7120 }
7121 dlg.finished(false);
7122 return Err(common::Error::HttpError(err));
7123 }
7124 Ok(res) => {
7125 let (mut parts, body) = res.into_parts();
7126 let mut body = common::Body::new(body);
7127 if !parts.status.is_success() {
7128 let bytes = common::to_bytes(body).await.unwrap_or_default();
7129 let error = serde_json::from_str(&common::to_string(&bytes));
7130 let response = common::to_response(parts, bytes.into());
7131
7132 if let common::Retry::After(d) =
7133 dlg.http_failure(&response, error.as_ref().ok())
7134 {
7135 sleep(d).await;
7136 continue;
7137 }
7138
7139 dlg.finished(false);
7140
7141 return Err(match error {
7142 Ok(value) => common::Error::BadRequest(value),
7143 _ => common::Error::Failure(response),
7144 });
7145 }
7146 let response = {
7147 let bytes = common::to_bytes(body).await.unwrap_or_default();
7148 let encoded = common::to_string(&bytes);
7149 match serde_json::from_str(&encoded) {
7150 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7151 Err(error) => {
7152 dlg.response_json_decode_error(&encoded, &error);
7153 return Err(common::Error::JsonDecodeError(
7154 encoded.to_string(),
7155 error,
7156 ));
7157 }
7158 }
7159 };
7160
7161 dlg.finished(true);
7162 return Ok(response);
7163 }
7164 }
7165 }
7166 }
7167
7168 ///
7169 /// Sets the *request* property to the given value.
7170 ///
7171 /// Even though the property as already been set when instantiating this call,
7172 /// we provide this method for API completeness.
7173 pub fn request(
7174 mut self,
7175 new_value: SetIamPolicyRequest,
7176 ) -> ProjectTopicSetIamPolicyCall<'a, C> {
7177 self._request = new_value;
7178 self
7179 }
7180 /// 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.
7181 ///
7182 /// Sets the *resource* path property to the given value.
7183 ///
7184 /// Even though the property as already been set when instantiating this call,
7185 /// we provide this method for API completeness.
7186 pub fn resource(mut self, new_value: &str) -> ProjectTopicSetIamPolicyCall<'a, C> {
7187 self._resource = new_value.to_string();
7188 self
7189 }
7190 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7191 /// while executing the actual API request.
7192 ///
7193 /// ````text
7194 /// It should be used to handle progress information, and to implement a certain level of resilience.
7195 /// ````
7196 ///
7197 /// Sets the *delegate* property to the given value.
7198 pub fn delegate(
7199 mut self,
7200 new_value: &'a mut dyn common::Delegate,
7201 ) -> ProjectTopicSetIamPolicyCall<'a, C> {
7202 self._delegate = Some(new_value);
7203 self
7204 }
7205
7206 /// Set any additional parameter of the query string used in the request.
7207 /// It should be used to set parameters which are not yet available through their own
7208 /// setters.
7209 ///
7210 /// Please note that this method must not be used to set any of the known parameters
7211 /// which have their own setter method. If done anyway, the request will fail.
7212 ///
7213 /// # Additional Parameters
7214 ///
7215 /// * *$.xgafv* (query-string) - V1 error format.
7216 /// * *access_token* (query-string) - OAuth access token.
7217 /// * *alt* (query-string) - Data format for response.
7218 /// * *callback* (query-string) - JSONP
7219 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7220 /// * *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.
7221 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7222 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7223 /// * *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.
7224 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7225 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7226 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicSetIamPolicyCall<'a, C>
7227 where
7228 T: AsRef<str>,
7229 {
7230 self._additional_params
7231 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7232 self
7233 }
7234
7235 /// Identifies the authorization scope for the method you are building.
7236 ///
7237 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7238 /// [`Scope::CloudPlatform`].
7239 ///
7240 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7241 /// tokens for more than one scope.
7242 ///
7243 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7244 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7245 /// sufficient, a read-write scope will do as well.
7246 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicSetIamPolicyCall<'a, C>
7247 where
7248 St: AsRef<str>,
7249 {
7250 self._scopes.insert(String::from(scope.as_ref()));
7251 self
7252 }
7253 /// Identifies the authorization scope(s) for the method you are building.
7254 ///
7255 /// See [`Self::add_scope()`] for details.
7256 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicSetIamPolicyCall<'a, C>
7257 where
7258 I: IntoIterator<Item = St>,
7259 St: AsRef<str>,
7260 {
7261 self._scopes
7262 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7263 self
7264 }
7265
7266 /// Removes all scopes, and no default scope will be used either.
7267 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7268 /// for details).
7269 pub fn clear_scopes(mut self) -> ProjectTopicSetIamPolicyCall<'a, C> {
7270 self._scopes.clear();
7271 self
7272 }
7273}
7274
7275/// 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.
7276///
7277/// A builder for the *topics.testIamPermissions* method supported by a *project* resource.
7278/// It is not used directly, but through a [`ProjectMethods`] instance.
7279///
7280/// # Example
7281///
7282/// Instantiate a resource method builder
7283///
7284/// ```test_harness,no_run
7285/// # extern crate hyper;
7286/// # extern crate hyper_rustls;
7287/// # extern crate google_pubsub1_beta2 as pubsub1_beta2;
7288/// use pubsub1_beta2::api::TestIamPermissionsRequest;
7289/// # async fn dox() {
7290/// # use pubsub1_beta2::{Pubsub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7291///
7292/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7293/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7294/// # .with_native_roots()
7295/// # .unwrap()
7296/// # .https_only()
7297/// # .enable_http2()
7298/// # .build();
7299///
7300/// # let executor = hyper_util::rt::TokioExecutor::new();
7301/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7302/// # secret,
7303/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7304/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7305/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7306/// # ),
7307/// # ).build().await.unwrap();
7308///
7309/// # let client = hyper_util::client::legacy::Client::builder(
7310/// # hyper_util::rt::TokioExecutor::new()
7311/// # )
7312/// # .build(
7313/// # hyper_rustls::HttpsConnectorBuilder::new()
7314/// # .with_native_roots()
7315/// # .unwrap()
7316/// # .https_or_http()
7317/// # .enable_http2()
7318/// # .build()
7319/// # );
7320/// # let mut hub = Pubsub::new(client, auth);
7321/// // As the method needs a request, you would usually fill it with the desired information
7322/// // into the respective structure. Some of the parts shown here might not be applicable !
7323/// // Values shown here are possibly random and not representative !
7324/// let mut req = TestIamPermissionsRequest::default();
7325///
7326/// // You can configure optional parameters by calling the respective setters at will, and
7327/// // execute the final call using `doit()`.
7328/// // Values shown here are possibly random and not representative !
7329/// let result = hub.projects().topics_test_iam_permissions(req, "resource")
7330/// .doit().await;
7331/// # }
7332/// ```
7333pub struct ProjectTopicTestIamPermissionCall<'a, C>
7334where
7335 C: 'a,
7336{
7337 hub: &'a Pubsub<C>,
7338 _request: TestIamPermissionsRequest,
7339 _resource: String,
7340 _delegate: Option<&'a mut dyn common::Delegate>,
7341 _additional_params: HashMap<String, String>,
7342 _scopes: BTreeSet<String>,
7343}
7344
7345impl<'a, C> common::CallBuilder for ProjectTopicTestIamPermissionCall<'a, C> {}
7346
7347impl<'a, C> ProjectTopicTestIamPermissionCall<'a, C>
7348where
7349 C: common::Connector,
7350{
7351 /// Perform the operation you have build so far.
7352 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
7353 use std::borrow::Cow;
7354 use std::io::{Read, Seek};
7355
7356 use common::{url::Params, ToParts};
7357 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7358
7359 let mut dd = common::DefaultDelegate;
7360 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7361 dlg.begin(common::MethodInfo {
7362 id: "pubsub.projects.topics.testIamPermissions",
7363 http_method: hyper::Method::POST,
7364 });
7365
7366 for &field in ["alt", "resource"].iter() {
7367 if self._additional_params.contains_key(field) {
7368 dlg.finished(false);
7369 return Err(common::Error::FieldClash(field));
7370 }
7371 }
7372
7373 let mut params = Params::with_capacity(4 + self._additional_params.len());
7374 params.push("resource", self._resource);
7375
7376 params.extend(self._additional_params.iter());
7377
7378 params.push("alt", "json");
7379 let mut url = self.hub._base_url.clone() + "v1beta2/{+resource}:testIamPermissions";
7380 if self._scopes.is_empty() {
7381 self._scopes
7382 .insert(Scope::CloudPlatform.as_ref().to_string());
7383 }
7384
7385 #[allow(clippy::single_element_loop)]
7386 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7387 url = params.uri_replacement(url, param_name, find_this, true);
7388 }
7389 {
7390 let to_remove = ["resource"];
7391 params.remove_params(&to_remove);
7392 }
7393
7394 let url = params.parse_with_url(&url);
7395
7396 let mut json_mime_type = mime::APPLICATION_JSON;
7397 let mut request_value_reader = {
7398 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7399 common::remove_json_null_values(&mut value);
7400 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7401 serde_json::to_writer(&mut dst, &value).unwrap();
7402 dst
7403 };
7404 let request_size = request_value_reader
7405 .seek(std::io::SeekFrom::End(0))
7406 .unwrap();
7407 request_value_reader
7408 .seek(std::io::SeekFrom::Start(0))
7409 .unwrap();
7410
7411 loop {
7412 let token = match self
7413 .hub
7414 .auth
7415 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7416 .await
7417 {
7418 Ok(token) => token,
7419 Err(e) => match dlg.token(e) {
7420 Ok(token) => token,
7421 Err(e) => {
7422 dlg.finished(false);
7423 return Err(common::Error::MissingToken(e));
7424 }
7425 },
7426 };
7427 request_value_reader
7428 .seek(std::io::SeekFrom::Start(0))
7429 .unwrap();
7430 let mut req_result = {
7431 let client = &self.hub.client;
7432 dlg.pre_request();
7433 let mut req_builder = hyper::Request::builder()
7434 .method(hyper::Method::POST)
7435 .uri(url.as_str())
7436 .header(USER_AGENT, self.hub._user_agent.clone());
7437
7438 if let Some(token) = token.as_ref() {
7439 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7440 }
7441
7442 let request = req_builder
7443 .header(CONTENT_TYPE, json_mime_type.to_string())
7444 .header(CONTENT_LENGTH, request_size as u64)
7445 .body(common::to_body(
7446 request_value_reader.get_ref().clone().into(),
7447 ));
7448
7449 client.request(request.unwrap()).await
7450 };
7451
7452 match req_result {
7453 Err(err) => {
7454 if let common::Retry::After(d) = dlg.http_error(&err) {
7455 sleep(d).await;
7456 continue;
7457 }
7458 dlg.finished(false);
7459 return Err(common::Error::HttpError(err));
7460 }
7461 Ok(res) => {
7462 let (mut parts, body) = res.into_parts();
7463 let mut body = common::Body::new(body);
7464 if !parts.status.is_success() {
7465 let bytes = common::to_bytes(body).await.unwrap_or_default();
7466 let error = serde_json::from_str(&common::to_string(&bytes));
7467 let response = common::to_response(parts, bytes.into());
7468
7469 if let common::Retry::After(d) =
7470 dlg.http_failure(&response, error.as_ref().ok())
7471 {
7472 sleep(d).await;
7473 continue;
7474 }
7475
7476 dlg.finished(false);
7477
7478 return Err(match error {
7479 Ok(value) => common::Error::BadRequest(value),
7480 _ => common::Error::Failure(response),
7481 });
7482 }
7483 let response = {
7484 let bytes = common::to_bytes(body).await.unwrap_or_default();
7485 let encoded = common::to_string(&bytes);
7486 match serde_json::from_str(&encoded) {
7487 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7488 Err(error) => {
7489 dlg.response_json_decode_error(&encoded, &error);
7490 return Err(common::Error::JsonDecodeError(
7491 encoded.to_string(),
7492 error,
7493 ));
7494 }
7495 }
7496 };
7497
7498 dlg.finished(true);
7499 return Ok(response);
7500 }
7501 }
7502 }
7503 }
7504
7505 ///
7506 /// Sets the *request* property to the given value.
7507 ///
7508 /// Even though the property as already been set when instantiating this call,
7509 /// we provide this method for API completeness.
7510 pub fn request(
7511 mut self,
7512 new_value: TestIamPermissionsRequest,
7513 ) -> ProjectTopicTestIamPermissionCall<'a, C> {
7514 self._request = new_value;
7515 self
7516 }
7517 /// 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.
7518 ///
7519 /// Sets the *resource* path property to the given value.
7520 ///
7521 /// Even though the property as already been set when instantiating this call,
7522 /// we provide this method for API completeness.
7523 pub fn resource(mut self, new_value: &str) -> ProjectTopicTestIamPermissionCall<'a, C> {
7524 self._resource = new_value.to_string();
7525 self
7526 }
7527 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7528 /// while executing the actual API request.
7529 ///
7530 /// ````text
7531 /// It should be used to handle progress information, and to implement a certain level of resilience.
7532 /// ````
7533 ///
7534 /// Sets the *delegate* property to the given value.
7535 pub fn delegate(
7536 mut self,
7537 new_value: &'a mut dyn common::Delegate,
7538 ) -> ProjectTopicTestIamPermissionCall<'a, C> {
7539 self._delegate = Some(new_value);
7540 self
7541 }
7542
7543 /// Set any additional parameter of the query string used in the request.
7544 /// It should be used to set parameters which are not yet available through their own
7545 /// setters.
7546 ///
7547 /// Please note that this method must not be used to set any of the known parameters
7548 /// which have their own setter method. If done anyway, the request will fail.
7549 ///
7550 /// # Additional Parameters
7551 ///
7552 /// * *$.xgafv* (query-string) - V1 error format.
7553 /// * *access_token* (query-string) - OAuth access token.
7554 /// * *alt* (query-string) - Data format for response.
7555 /// * *callback* (query-string) - JSONP
7556 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7557 /// * *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.
7558 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7559 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7560 /// * *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.
7561 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7562 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7563 pub fn param<T>(mut self, name: T, value: T) -> ProjectTopicTestIamPermissionCall<'a, C>
7564 where
7565 T: AsRef<str>,
7566 {
7567 self._additional_params
7568 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7569 self
7570 }
7571
7572 /// Identifies the authorization scope for the method you are building.
7573 ///
7574 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7575 /// [`Scope::CloudPlatform`].
7576 ///
7577 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7578 /// tokens for more than one scope.
7579 ///
7580 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7581 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7582 /// sufficient, a read-write scope will do as well.
7583 pub fn add_scope<St>(mut self, scope: St) -> ProjectTopicTestIamPermissionCall<'a, C>
7584 where
7585 St: AsRef<str>,
7586 {
7587 self._scopes.insert(String::from(scope.as_ref()));
7588 self
7589 }
7590 /// Identifies the authorization scope(s) for the method you are building.
7591 ///
7592 /// See [`Self::add_scope()`] for details.
7593 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTopicTestIamPermissionCall<'a, C>
7594 where
7595 I: IntoIterator<Item = St>,
7596 St: AsRef<str>,
7597 {
7598 self._scopes
7599 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7600 self
7601 }
7602
7603 /// Removes all scopes, and no default scope will be used either.
7604 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7605 /// for details).
7606 pub fn clear_scopes(mut self) -> ProjectTopicTestIamPermissionCall<'a, C> {
7607 self._scopes.clear();
7608 self
7609 }
7610}