google_servicedirectory1_beta1/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
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::CloudPlatform
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all ServiceDirectory related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
49/// use servicedirectory1_beta1::api::GetIamPolicyRequest;
50/// use servicedirectory1_beta1::{Result, Error};
51/// # async fn dox() {
52/// use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = ServiceDirectory::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GetIamPolicyRequest::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_namespaces_services_get_iam_policy(req, "resource")
99/// .doit().await;
100///
101/// match result {
102/// Err(e) => match e {
103/// // The Error enum provides details about what exactly happened.
104/// // You can also just use its `Debug`, `Display` or `Error` traits
105/// Error::HttpError(_)
106/// |Error::Io(_)
107/// |Error::MissingAPIKey
108/// |Error::MissingToken(_)
109/// |Error::Cancelled
110/// |Error::UploadSizeLimitExceeded(_, _)
111/// |Error::Failure(_)
112/// |Error::BadRequest(_)
113/// |Error::FieldClash(_)
114/// |Error::JsonDecodeError(_, _) => println!("{}", e),
115/// },
116/// Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct ServiceDirectory<C> {
122 pub client: common::Client<C>,
123 pub auth: Box<dyn common::GetToken>,
124 _user_agent: String,
125 _base_url: String,
126 _root_url: String,
127}
128
129impl<C> common::Hub for ServiceDirectory<C> {}
130
131impl<'a, C> ServiceDirectory<C> {
132 pub fn new<A: 'static + common::GetToken>(
133 client: common::Client<C>,
134 auth: A,
135 ) -> ServiceDirectory<C> {
136 ServiceDirectory {
137 client,
138 auth: Box::new(auth),
139 _user_agent: "google-api-rust-client/7.0.0".to_string(),
140 _base_url: "https://servicedirectory.googleapis.com/".to_string(),
141 _root_url: "https://servicedirectory.googleapis.com/".to_string(),
142 }
143 }
144
145 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
146 ProjectMethods { hub: self }
147 }
148
149 /// Set the user-agent header field to use in all requests to the server.
150 /// It defaults to `google-api-rust-client/7.0.0`.
151 ///
152 /// Returns the previously set user-agent.
153 pub fn user_agent(&mut self, agent_name: String) -> String {
154 std::mem::replace(&mut self._user_agent, agent_name)
155 }
156
157 /// Set the base url to use in all requests to the server.
158 /// It defaults to `https://servicedirectory.googleapis.com/`.
159 ///
160 /// Returns the previously set base url.
161 pub fn base_url(&mut self, new_base_url: String) -> String {
162 std::mem::replace(&mut self._base_url, new_base_url)
163 }
164
165 /// Set the root url to use in all requests to the server.
166 /// It defaults to `https://servicedirectory.googleapis.com/`.
167 ///
168 /// Returns the previously set root url.
169 pub fn root_url(&mut self, new_root_url: String) -> String {
170 std::mem::replace(&mut self._root_url, new_root_url)
171 }
172}
173
174// ############
175// SCHEMAS ###
176// ##########
177/// Associates `members`, or principals, with a `role`.
178///
179/// This type is not used in any activity, and only used as *part* of another schema.
180///
181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
182#[serde_with::serde_as]
183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
184pub struct Binding {
185 /// 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).
186 pub condition: Option<Expr>,
187 /// 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`.
188 pub members: Option<Vec<String>>,
189 /// 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).
190 pub role: Option<String>,
191}
192
193impl common::Part for Binding {}
194
195/// 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); }
196///
197/// # Activities
198///
199/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
200/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
201///
202/// * [locations namespaces services endpoints delete projects](ProjectLocationNamespaceServiceEndpointDeleteCall) (response)
203/// * [locations namespaces services delete projects](ProjectLocationNamespaceServiceDeleteCall) (response)
204/// * [locations namespaces delete projects](ProjectLocationNamespaceDeleteCall) (response)
205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
206#[serde_with::serde_as]
207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
208pub struct Empty {
209 _never_set: Option<bool>,
210}
211
212impl common::ResponseResult for Empty {}
213
214/// An individual endpoint that provides a service. The service must already exist to create an endpoint.
215///
216/// # Activities
217///
218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
220///
221/// * [locations namespaces services endpoints create projects](ProjectLocationNamespaceServiceEndpointCreateCall) (request|response)
222/// * [locations namespaces services endpoints get projects](ProjectLocationNamespaceServiceEndpointGetCall) (response)
223/// * [locations namespaces services endpoints patch projects](ProjectLocationNamespaceServiceEndpointPatchCall) (request|response)
224#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
225#[serde_with::serde_as]
226#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
227pub struct Endpoint {
228 /// Optional. An IPv4 or IPv6 address. Service Directory rejects bad addresses like: * `8.8.8` * `8.8.8.8:53` * `test:bad:address` * `[::1]` * `[::1]:8080` Limited to 45 characters.
229 pub address: Option<String>,
230 /// Output only. The timestamp when the endpoint was created.
231 #[serde(rename = "createTime")]
232 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
233 /// Optional. Metadata for the endpoint. This data can be consumed by service clients. Restrictions: * The entire metadata dictionary may contain up to 512 characters, spread accoss all key-value pairs. Metadata that goes beyond this limit are rejected * Valid metadata keys have two segments: an optional prefix and name, separated by a slash (/). The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between. The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS labels separated by dots (.), not longer than 253 characters in total, followed by a slash (/). Metadata that fails to meet these requirements are rejected Note: This field is equivalent to the `annotations` field in the v1 API. They have the same syntax and read/write to the same location in Service Directory.
234 pub metadata: Option<HashMap<String, String>>,
235 /// Immutable. The resource name for the endpoint in the format `projects/*/locations/*/namespaces/*/services/*/endpoints/*`.
236 pub name: Option<String>,
237 /// Immutable. The Google Compute Engine network (VPC) of the endpoint in the format `projects//locations/global/networks/*`. The project must be specified by project number (project id is rejected). Incorrectly formatted networks are rejected, but no other validation is performed on this field (ex. network or project existence, reachability, or permissions).
238 pub network: Option<String>,
239 /// Optional. Service Directory rejects values outside of `[0, 65535]`.
240 pub port: Option<i32>,
241 /// Output only. A globally unique identifier (in UUID4 format) for this endpoint.
242 pub uid: Option<String>,
243 /// Output only. The timestamp when the endpoint was last updated.
244 #[serde(rename = "updateTime")]
245 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
246}
247
248impl common::RequestValue for Endpoint {}
249impl common::ResponseResult for Endpoint {}
250
251/// 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.
252///
253/// This type is not used in any activity, and only used as *part* of another schema.
254///
255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
256#[serde_with::serde_as]
257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
258pub struct Expr {
259 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
260 pub description: Option<String>,
261 /// Textual representation of an expression in Common Expression Language syntax.
262 pub expression: Option<String>,
263 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
264 pub location: Option<String>,
265 /// 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.
266 pub title: Option<String>,
267}
268
269impl common::Part for Expr {}
270
271/// Request message for `GetIamPolicy` method.
272///
273/// # Activities
274///
275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
277///
278/// * [locations namespaces services get iam policy projects](ProjectLocationNamespaceServiceGetIamPolicyCall) (request)
279/// * [locations namespaces workloads get iam policy projects](ProjectLocationNamespaceWorkloadGetIamPolicyCall) (request)
280/// * [locations namespaces get iam policy projects](ProjectLocationNamespaceGetIamPolicyCall) (request)
281#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
282#[serde_with::serde_as]
283#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
284pub struct GetIamPolicyRequest {
285 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
286 pub options: Option<GetPolicyOptions>,
287}
288
289impl common::RequestValue for GetIamPolicyRequest {}
290
291/// Encapsulates settings provided to GetIamPolicy.
292///
293/// This type is not used in any activity, and only used as *part* of another schema.
294///
295#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
296#[serde_with::serde_as]
297#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
298pub struct GetPolicyOptions {
299 /// 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).
300 #[serde(rename = "requestedPolicyVersion")]
301 pub requested_policy_version: Option<i32>,
302}
303
304impl common::Part for GetPolicyOptions {}
305
306/// The response message for RegistrationService.ListEndpoints.
307///
308/// # Activities
309///
310/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
311/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
312///
313/// * [locations namespaces services endpoints list projects](ProjectLocationNamespaceServiceEndpointListCall) (response)
314#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
315#[serde_with::serde_as]
316#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
317pub struct ListEndpointsResponse {
318 /// The list of endpoints.
319 pub endpoints: Option<Vec<Endpoint>>,
320 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
321 #[serde(rename = "nextPageToken")]
322 pub next_page_token: Option<String>,
323}
324
325impl common::ResponseResult for ListEndpointsResponse {}
326
327/// The response message for Locations.ListLocations.
328///
329/// # Activities
330///
331/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
332/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
333///
334/// * [locations list projects](ProjectLocationListCall) (response)
335#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
336#[serde_with::serde_as]
337#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
338pub struct ListLocationsResponse {
339 /// A list of locations that matches the specified filter in the request.
340 pub locations: Option<Vec<Location>>,
341 /// The standard List next-page token.
342 #[serde(rename = "nextPageToken")]
343 pub next_page_token: Option<String>,
344}
345
346impl common::ResponseResult for ListLocationsResponse {}
347
348/// The response message for RegistrationService.ListNamespaces.
349///
350/// # Activities
351///
352/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
353/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
354///
355/// * [locations namespaces list projects](ProjectLocationNamespaceListCall) (response)
356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
357#[serde_with::serde_as]
358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
359pub struct ListNamespacesResponse {
360 /// The list of namespaces.
361 pub namespaces: Option<Vec<Namespace>>,
362 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
363 #[serde(rename = "nextPageToken")]
364 pub next_page_token: Option<String>,
365}
366
367impl common::ResponseResult for ListNamespacesResponse {}
368
369/// The response message for RegistrationService.ListServices.
370///
371/// # Activities
372///
373/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
374/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
375///
376/// * [locations namespaces services list projects](ProjectLocationNamespaceServiceListCall) (response)
377#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
378#[serde_with::serde_as]
379#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
380pub struct ListServicesResponse {
381 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
382 #[serde(rename = "nextPageToken")]
383 pub next_page_token: Option<String>,
384 /// The list of services.
385 pub services: Option<Vec<Service>>,
386}
387
388impl common::ResponseResult for ListServicesResponse {}
389
390/// A resource that represents a Google Cloud location.
391///
392/// # Activities
393///
394/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
395/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
396///
397/// * [locations get projects](ProjectLocationGetCall) (response)
398#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
399#[serde_with::serde_as]
400#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
401pub struct Location {
402 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
403 #[serde(rename = "displayName")]
404 pub display_name: Option<String>,
405 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
406 pub labels: Option<HashMap<String, String>>,
407 /// The canonical id for this location. For example: `"us-east1"`.
408 #[serde(rename = "locationId")]
409 pub location_id: Option<String>,
410 /// Service-specific metadata. For example the available capacity at the given location.
411 pub metadata: Option<HashMap<String, serde_json::Value>>,
412 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
413 pub name: Option<String>,
414}
415
416impl common::ResponseResult for Location {}
417
418/// A container for services. Namespaces allow administrators to group services together and define permissions for a collection of services.
419///
420/// # Activities
421///
422/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
423/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
424///
425/// * [locations namespaces create projects](ProjectLocationNamespaceCreateCall) (request|response)
426/// * [locations namespaces get projects](ProjectLocationNamespaceGetCall) (response)
427/// * [locations namespaces patch projects](ProjectLocationNamespacePatchCall) (request|response)
428#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
429#[serde_with::serde_as]
430#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
431pub struct Namespace {
432 /// Output only. The timestamp when the namespace was created.
433 #[serde(rename = "createTime")]
434 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
435 /// Optional. Resource labels associated with this namespace. No more than 64 user labels can be associated with a given resource. Label keys and values can be no longer than 63 characters.
436 pub labels: Option<HashMap<String, String>>,
437 /// Immutable. The resource name for the namespace in the format `projects/*/locations/*/namespaces/*`.
438 pub name: Option<String>,
439 /// Output only. A globally unique identifier (in UUID4 format) for this namespace.
440 pub uid: Option<String>,
441 /// Output only. The timestamp when the namespace was last updated.
442 #[serde(rename = "updateTime")]
443 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
444}
445
446impl common::RequestValue for Namespace {}
447impl common::ResponseResult for Namespace {}
448
449/// 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/).
450///
451/// # Activities
452///
453/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
454/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
455///
456/// * [locations namespaces services get iam policy projects](ProjectLocationNamespaceServiceGetIamPolicyCall) (response)
457/// * [locations namespaces services set iam policy projects](ProjectLocationNamespaceServiceSetIamPolicyCall) (response)
458/// * [locations namespaces workloads get iam policy projects](ProjectLocationNamespaceWorkloadGetIamPolicyCall) (response)
459/// * [locations namespaces workloads set iam policy projects](ProjectLocationNamespaceWorkloadSetIamPolicyCall) (response)
460/// * [locations namespaces get iam policy projects](ProjectLocationNamespaceGetIamPolicyCall) (response)
461/// * [locations namespaces set iam policy projects](ProjectLocationNamespaceSetIamPolicyCall) (response)
462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
463#[serde_with::serde_as]
464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
465pub struct Policy {
466 /// 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`.
467 pub bindings: Option<Vec<Binding>>,
468 /// `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.
469 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
470 pub etag: Option<Vec<u8>>,
471 /// 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).
472 pub version: Option<i32>,
473}
474
475impl common::ResponseResult for Policy {}
476
477/// The request message for LookupService.ResolveService. Looks up a service by its name, returns the service and its endpoints.
478///
479/// # Activities
480///
481/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
482/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
483///
484/// * [locations namespaces services resolve projects](ProjectLocationNamespaceServiceResolveCall) (request)
485#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
486#[serde_with::serde_as]
487#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
488pub struct ResolveServiceRequest {
489 /// Optional. The filter applied to the endpoints of the resolved service. General `filter` string syntax: ` ()` * `` can be `name`, `address`, `port`, or `metadata.` for map field * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` means `HAS`, and is roughly the same as `=` * `` must be the same data type as field * `` can be `AND`, `OR`, `NOT` Examples of valid filters: * `metadata.owner` returns endpoints that have a annotation with the key `owner`, this is the same as `metadata:owner` * `metadata.protocol=gRPC` returns endpoints that have key/value `protocol=gRPC` * `address=192.108.1.105` returns endpoints that have this address * `port>8080` returns endpoints that have port number larger than 8080 * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` returns endpoints that have name that is alphabetically later than the string, so "endpoint-e" is returned but "endpoint-a" is not * `name=projects/my-project/locations/us-central1/namespaces/my-namespace/services/my-service/endpoints/ep-1` returns the endpoint that has an endpoint_id equal to `ep-1` * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have `owner` in annotation key but value is not `sd` AND have key/value `foo=bar` * `doesnotexist.foo=bar` returns an empty list. Note that endpoint doesn't have a field called "doesnotexist". Since the filter does not match any endpoint, it returns no results For more information about filtering, see [API Filtering](https://aip.dev/160).
490 #[serde(rename = "endpointFilter")]
491 pub endpoint_filter: Option<String>,
492 /// Optional. The maximum number of endpoints to return. Defaults to 25. Maximum is 100. If a value less than one is specified, the Default is used. If a value greater than the Maximum is specified, the Maximum is used.
493 #[serde(rename = "maxEndpoints")]
494 pub max_endpoints: Option<i32>,
495}
496
497impl common::RequestValue for ResolveServiceRequest {}
498
499/// The response message for LookupService.ResolveService.
500///
501/// # Activities
502///
503/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
504/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
505///
506/// * [locations namespaces services resolve projects](ProjectLocationNamespaceServiceResolveCall) (response)
507#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
508#[serde_with::serde_as]
509#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
510pub struct ResolveServiceResponse {
511 /// no description provided
512 pub service: Option<Service>,
513}
514
515impl common::ResponseResult for ResolveServiceResponse {}
516
517/// An individual service. A service contains a name and optional metadata. A service must exist before endpoints can be added to it.
518///
519/// # Activities
520///
521/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
522/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
523///
524/// * [locations namespaces services create projects](ProjectLocationNamespaceServiceCreateCall) (request|response)
525/// * [locations namespaces services get projects](ProjectLocationNamespaceServiceGetCall) (response)
526/// * [locations namespaces services patch projects](ProjectLocationNamespaceServicePatchCall) (request|response)
527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
528#[serde_with::serde_as]
529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
530pub struct Service {
531 /// Output only. The timestamp when the service was created.
532 #[serde(rename = "createTime")]
533 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
534 /// Output only. Endpoints associated with this service. Returned on LookupService.ResolveService. Control plane clients should use RegistrationService.ListEndpoints.
535 pub endpoints: Option<Vec<Endpoint>>,
536 /// Optional. Metadata for the service. This data can be consumed by service clients. Restrictions: * The entire metadata dictionary may contain up to 2000 characters, spread accoss all key-value pairs. Metadata that goes beyond this limit are rejected * Valid metadata keys have two segments: an optional prefix and name, separated by a slash (/). The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between. The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS labels separated by dots (.), not longer than 253 characters in total, followed by a slash (/). Metadata that fails to meet these requirements are rejected Note: This field is equivalent to the `annotations` field in the v1 API. They have the same syntax and read/write to the same location in Service Directory.
537 pub metadata: Option<HashMap<String, String>>,
538 /// Immutable. The resource name for the service in the format `projects/*/locations/*/namespaces/*/services/*`.
539 pub name: Option<String>,
540 /// Output only. A globally unique identifier (in UUID4 format) for this service.
541 pub uid: Option<String>,
542 /// Output only. The timestamp when the service was last updated. Note: endpoints being created/deleted/updated within the service are not considered service updates for the purpose of this timestamp.
543 #[serde(rename = "updateTime")]
544 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
545}
546
547impl common::RequestValue for Service {}
548impl common::ResponseResult for Service {}
549
550/// Request message for `SetIamPolicy` method.
551///
552/// # Activities
553///
554/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
555/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
556///
557/// * [locations namespaces services set iam policy projects](ProjectLocationNamespaceServiceSetIamPolicyCall) (request)
558/// * [locations namespaces workloads set iam policy projects](ProjectLocationNamespaceWorkloadSetIamPolicyCall) (request)
559/// * [locations namespaces set iam policy projects](ProjectLocationNamespaceSetIamPolicyCall) (request)
560#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
561#[serde_with::serde_as]
562#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
563pub struct SetIamPolicyRequest {
564 /// 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.
565 pub policy: Option<Policy>,
566}
567
568impl common::RequestValue for SetIamPolicyRequest {}
569
570/// Request message for `TestIamPermissions` method.
571///
572/// # Activities
573///
574/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
575/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
576///
577/// * [locations namespaces services test iam permissions projects](ProjectLocationNamespaceServiceTestIamPermissionCall) (request)
578/// * [locations namespaces workloads test iam permissions projects](ProjectLocationNamespaceWorkloadTestIamPermissionCall) (request)
579/// * [locations namespaces test iam permissions projects](ProjectLocationNamespaceTestIamPermissionCall) (request)
580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
581#[serde_with::serde_as]
582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
583pub struct TestIamPermissionsRequest {
584 /// 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).
585 pub permissions: Option<Vec<String>>,
586}
587
588impl common::RequestValue for TestIamPermissionsRequest {}
589
590/// Response message for `TestIamPermissions` method.
591///
592/// # Activities
593///
594/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
595/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
596///
597/// * [locations namespaces services test iam permissions projects](ProjectLocationNamespaceServiceTestIamPermissionCall) (response)
598/// * [locations namespaces workloads test iam permissions projects](ProjectLocationNamespaceWorkloadTestIamPermissionCall) (response)
599/// * [locations namespaces test iam permissions projects](ProjectLocationNamespaceTestIamPermissionCall) (response)
600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
601#[serde_with::serde_as]
602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
603pub struct TestIamPermissionsResponse {
604 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
605 pub permissions: Option<Vec<String>>,
606}
607
608impl common::ResponseResult for TestIamPermissionsResponse {}
609
610// ###################
611// MethodBuilders ###
612// #################
613
614/// A builder providing access to all methods supported on *project* resources.
615/// It is not used directly, but through the [`ServiceDirectory`] hub.
616///
617/// # Example
618///
619/// Instantiate a resource builder
620///
621/// ```test_harness,no_run
622/// extern crate hyper;
623/// extern crate hyper_rustls;
624/// extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
625///
626/// # async fn dox() {
627/// use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
628///
629/// let secret: yup_oauth2::ApplicationSecret = Default::default();
630/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
631/// .with_native_roots()
632/// .unwrap()
633/// .https_only()
634/// .enable_http2()
635/// .build();
636///
637/// let executor = hyper_util::rt::TokioExecutor::new();
638/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
639/// secret,
640/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
641/// yup_oauth2::client::CustomHyperClientBuilder::from(
642/// hyper_util::client::legacy::Client::builder(executor).build(connector),
643/// ),
644/// ).build().await.unwrap();
645///
646/// let client = hyper_util::client::legacy::Client::builder(
647/// hyper_util::rt::TokioExecutor::new()
648/// )
649/// .build(
650/// hyper_rustls::HttpsConnectorBuilder::new()
651/// .with_native_roots()
652/// .unwrap()
653/// .https_or_http()
654/// .enable_http2()
655/// .build()
656/// );
657/// let mut hub = ServiceDirectory::new(client, auth);
658/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
659/// // like `locations_get(...)`, `locations_list(...)`, `locations_namespaces_create(...)`, `locations_namespaces_delete(...)`, `locations_namespaces_get(...)`, `locations_namespaces_get_iam_policy(...)`, `locations_namespaces_list(...)`, `locations_namespaces_patch(...)`, `locations_namespaces_services_create(...)`, `locations_namespaces_services_delete(...)`, `locations_namespaces_services_endpoints_create(...)`, `locations_namespaces_services_endpoints_delete(...)`, `locations_namespaces_services_endpoints_get(...)`, `locations_namespaces_services_endpoints_list(...)`, `locations_namespaces_services_endpoints_patch(...)`, `locations_namespaces_services_get(...)`, `locations_namespaces_services_get_iam_policy(...)`, `locations_namespaces_services_list(...)`, `locations_namespaces_services_patch(...)`, `locations_namespaces_services_resolve(...)`, `locations_namespaces_services_set_iam_policy(...)`, `locations_namespaces_services_test_iam_permissions(...)`, `locations_namespaces_set_iam_policy(...)`, `locations_namespaces_test_iam_permissions(...)`, `locations_namespaces_workloads_get_iam_policy(...)`, `locations_namespaces_workloads_set_iam_policy(...)` and `locations_namespaces_workloads_test_iam_permissions(...)`
660/// // to build up your call.
661/// let rb = hub.projects();
662/// # }
663/// ```
664pub struct ProjectMethods<'a, C>
665where
666 C: 'a,
667{
668 hub: &'a ServiceDirectory<C>,
669}
670
671impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
672
673impl<'a, C> ProjectMethods<'a, C> {
674 /// Create a builder to help you perform the following task:
675 ///
676 /// Creates an endpoint, and returns the new endpoint.
677 ///
678 /// # Arguments
679 ///
680 /// * `request` - No description provided.
681 /// * `parent` - Required. The resource name of the service that this endpoint provides.
682 pub fn locations_namespaces_services_endpoints_create(
683 &self,
684 request: Endpoint,
685 parent: &str,
686 ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> {
687 ProjectLocationNamespaceServiceEndpointCreateCall {
688 hub: self.hub,
689 _request: request,
690 _parent: parent.to_string(),
691 _endpoint_id: Default::default(),
692 _delegate: Default::default(),
693 _additional_params: Default::default(),
694 _scopes: Default::default(),
695 }
696 }
697
698 /// Create a builder to help you perform the following task:
699 ///
700 /// Deletes an endpoint.
701 ///
702 /// # Arguments
703 ///
704 /// * `name` - Required. The name of the endpoint to delete.
705 pub fn locations_namespaces_services_endpoints_delete(
706 &self,
707 name: &str,
708 ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> {
709 ProjectLocationNamespaceServiceEndpointDeleteCall {
710 hub: self.hub,
711 _name: name.to_string(),
712 _delegate: Default::default(),
713 _additional_params: Default::default(),
714 _scopes: Default::default(),
715 }
716 }
717
718 /// Create a builder to help you perform the following task:
719 ///
720 /// Gets an endpoint.
721 ///
722 /// # Arguments
723 ///
724 /// * `name` - Required. The name of the endpoint to get.
725 pub fn locations_namespaces_services_endpoints_get(
726 &self,
727 name: &str,
728 ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> {
729 ProjectLocationNamespaceServiceEndpointGetCall {
730 hub: self.hub,
731 _name: name.to_string(),
732 _delegate: Default::default(),
733 _additional_params: Default::default(),
734 _scopes: Default::default(),
735 }
736 }
737
738 /// Create a builder to help you perform the following task:
739 ///
740 /// Lists all endpoints.
741 ///
742 /// # Arguments
743 ///
744 /// * `parent` - Required. The resource name of the service whose endpoints you'd like to list.
745 pub fn locations_namespaces_services_endpoints_list(
746 &self,
747 parent: &str,
748 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> {
749 ProjectLocationNamespaceServiceEndpointListCall {
750 hub: self.hub,
751 _parent: parent.to_string(),
752 _page_token: Default::default(),
753 _page_size: Default::default(),
754 _order_by: Default::default(),
755 _filter: Default::default(),
756 _delegate: Default::default(),
757 _additional_params: Default::default(),
758 _scopes: Default::default(),
759 }
760 }
761
762 /// Create a builder to help you perform the following task:
763 ///
764 /// Updates an endpoint.
765 ///
766 /// # Arguments
767 ///
768 /// * `request` - No description provided.
769 /// * `name` - Immutable. The resource name for the endpoint in the format `projects/*/locations/*/namespaces/*/services/*/endpoints/*`.
770 pub fn locations_namespaces_services_endpoints_patch(
771 &self,
772 request: Endpoint,
773 name: &str,
774 ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> {
775 ProjectLocationNamespaceServiceEndpointPatchCall {
776 hub: self.hub,
777 _request: request,
778 _name: name.to_string(),
779 _update_mask: Default::default(),
780 _delegate: Default::default(),
781 _additional_params: Default::default(),
782 _scopes: Default::default(),
783 }
784 }
785
786 /// Create a builder to help you perform the following task:
787 ///
788 /// Creates a service, and returns the new service.
789 ///
790 /// # Arguments
791 ///
792 /// * `request` - No description provided.
793 /// * `parent` - Required. The resource name of the namespace this service will belong to.
794 pub fn locations_namespaces_services_create(
795 &self,
796 request: Service,
797 parent: &str,
798 ) -> ProjectLocationNamespaceServiceCreateCall<'a, C> {
799 ProjectLocationNamespaceServiceCreateCall {
800 hub: self.hub,
801 _request: request,
802 _parent: parent.to_string(),
803 _service_id: Default::default(),
804 _delegate: Default::default(),
805 _additional_params: Default::default(),
806 _scopes: Default::default(),
807 }
808 }
809
810 /// Create a builder to help you perform the following task:
811 ///
812 /// Deletes a service. This also deletes all endpoints associated with the service.
813 ///
814 /// # Arguments
815 ///
816 /// * `name` - Required. The name of the service to delete.
817 pub fn locations_namespaces_services_delete(
818 &self,
819 name: &str,
820 ) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> {
821 ProjectLocationNamespaceServiceDeleteCall {
822 hub: self.hub,
823 _name: name.to_string(),
824 _delegate: Default::default(),
825 _additional_params: Default::default(),
826 _scopes: Default::default(),
827 }
828 }
829
830 /// Create a builder to help you perform the following task:
831 ///
832 /// Gets a service.
833 ///
834 /// # Arguments
835 ///
836 /// * `name` - Required. The name of the service to get.
837 pub fn locations_namespaces_services_get(
838 &self,
839 name: &str,
840 ) -> ProjectLocationNamespaceServiceGetCall<'a, C> {
841 ProjectLocationNamespaceServiceGetCall {
842 hub: self.hub,
843 _name: name.to_string(),
844 _delegate: Default::default(),
845 _additional_params: Default::default(),
846 _scopes: Default::default(),
847 }
848 }
849
850 /// Create a builder to help you perform the following task:
851 ///
852 /// Gets the IAM Policy for a resource
853 ///
854 /// # Arguments
855 ///
856 /// * `request` - No description provided.
857 /// * `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.
858 pub fn locations_namespaces_services_get_iam_policy(
859 &self,
860 request: GetIamPolicyRequest,
861 resource: &str,
862 ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> {
863 ProjectLocationNamespaceServiceGetIamPolicyCall {
864 hub: self.hub,
865 _request: request,
866 _resource: resource.to_string(),
867 _delegate: Default::default(),
868 _additional_params: Default::default(),
869 _scopes: Default::default(),
870 }
871 }
872
873 /// Create a builder to help you perform the following task:
874 ///
875 /// Lists all services belonging to a namespace.
876 ///
877 /// # Arguments
878 ///
879 /// * `parent` - Required. The resource name of the namespace whose services you'd like to list.
880 pub fn locations_namespaces_services_list(
881 &self,
882 parent: &str,
883 ) -> ProjectLocationNamespaceServiceListCall<'a, C> {
884 ProjectLocationNamespaceServiceListCall {
885 hub: self.hub,
886 _parent: parent.to_string(),
887 _page_token: Default::default(),
888 _page_size: Default::default(),
889 _order_by: Default::default(),
890 _filter: Default::default(),
891 _delegate: Default::default(),
892 _additional_params: Default::default(),
893 _scopes: Default::default(),
894 }
895 }
896
897 /// Create a builder to help you perform the following task:
898 ///
899 /// Updates a service.
900 ///
901 /// # Arguments
902 ///
903 /// * `request` - No description provided.
904 /// * `name` - Immutable. The resource name for the service in the format `projects/*/locations/*/namespaces/*/services/*`.
905 pub fn locations_namespaces_services_patch(
906 &self,
907 request: Service,
908 name: &str,
909 ) -> ProjectLocationNamespaceServicePatchCall<'a, C> {
910 ProjectLocationNamespaceServicePatchCall {
911 hub: self.hub,
912 _request: request,
913 _name: name.to_string(),
914 _update_mask: Default::default(),
915 _delegate: Default::default(),
916 _additional_params: Default::default(),
917 _scopes: Default::default(),
918 }
919 }
920
921 /// Create a builder to help you perform the following task:
922 ///
923 /// Returns a service and its associated endpoints. Resolving a service is not considered an active developer method.
924 ///
925 /// # Arguments
926 ///
927 /// * `request` - No description provided.
928 /// * `name` - Required. The name of the service to resolve.
929 pub fn locations_namespaces_services_resolve(
930 &self,
931 request: ResolveServiceRequest,
932 name: &str,
933 ) -> ProjectLocationNamespaceServiceResolveCall<'a, C> {
934 ProjectLocationNamespaceServiceResolveCall {
935 hub: self.hub,
936 _request: request,
937 _name: name.to_string(),
938 _delegate: Default::default(),
939 _additional_params: Default::default(),
940 _scopes: Default::default(),
941 }
942 }
943
944 /// Create a builder to help you perform the following task:
945 ///
946 /// Sets the IAM Policy for a resource
947 ///
948 /// # Arguments
949 ///
950 /// * `request` - No description provided.
951 /// * `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.
952 pub fn locations_namespaces_services_set_iam_policy(
953 &self,
954 request: SetIamPolicyRequest,
955 resource: &str,
956 ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> {
957 ProjectLocationNamespaceServiceSetIamPolicyCall {
958 hub: self.hub,
959 _request: request,
960 _resource: resource.to_string(),
961 _delegate: Default::default(),
962 _additional_params: Default::default(),
963 _scopes: Default::default(),
964 }
965 }
966
967 /// Create a builder to help you perform the following task:
968 ///
969 /// Tests IAM permissions for a resource (namespace, service or service workload only).
970 ///
971 /// # Arguments
972 ///
973 /// * `request` - No description provided.
974 /// * `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.
975 pub fn locations_namespaces_services_test_iam_permissions(
976 &self,
977 request: TestIamPermissionsRequest,
978 resource: &str,
979 ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> {
980 ProjectLocationNamespaceServiceTestIamPermissionCall {
981 hub: self.hub,
982 _request: request,
983 _resource: resource.to_string(),
984 _delegate: Default::default(),
985 _additional_params: Default::default(),
986 _scopes: Default::default(),
987 }
988 }
989
990 /// Create a builder to help you perform the following task:
991 ///
992 /// Gets the IAM Policy for a resource
993 ///
994 /// # Arguments
995 ///
996 /// * `request` - No description provided.
997 /// * `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.
998 pub fn locations_namespaces_workloads_get_iam_policy(
999 &self,
1000 request: GetIamPolicyRequest,
1001 resource: &str,
1002 ) -> ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C> {
1003 ProjectLocationNamespaceWorkloadGetIamPolicyCall {
1004 hub: self.hub,
1005 _request: request,
1006 _resource: resource.to_string(),
1007 _delegate: Default::default(),
1008 _additional_params: Default::default(),
1009 _scopes: Default::default(),
1010 }
1011 }
1012
1013 /// Create a builder to help you perform the following task:
1014 ///
1015 /// Sets the IAM Policy for a resource
1016 ///
1017 /// # Arguments
1018 ///
1019 /// * `request` - No description provided.
1020 /// * `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.
1021 pub fn locations_namespaces_workloads_set_iam_policy(
1022 &self,
1023 request: SetIamPolicyRequest,
1024 resource: &str,
1025 ) -> ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C> {
1026 ProjectLocationNamespaceWorkloadSetIamPolicyCall {
1027 hub: self.hub,
1028 _request: request,
1029 _resource: resource.to_string(),
1030 _delegate: Default::default(),
1031 _additional_params: Default::default(),
1032 _scopes: Default::default(),
1033 }
1034 }
1035
1036 /// Create a builder to help you perform the following task:
1037 ///
1038 /// Tests IAM permissions for a resource (namespace, service or service workload only).
1039 ///
1040 /// # Arguments
1041 ///
1042 /// * `request` - No description provided.
1043 /// * `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.
1044 pub fn locations_namespaces_workloads_test_iam_permissions(
1045 &self,
1046 request: TestIamPermissionsRequest,
1047 resource: &str,
1048 ) -> ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C> {
1049 ProjectLocationNamespaceWorkloadTestIamPermissionCall {
1050 hub: self.hub,
1051 _request: request,
1052 _resource: resource.to_string(),
1053 _delegate: Default::default(),
1054 _additional_params: Default::default(),
1055 _scopes: Default::default(),
1056 }
1057 }
1058
1059 /// Create a builder to help you perform the following task:
1060 ///
1061 /// Creates a namespace, and returns the new namespace.
1062 ///
1063 /// # Arguments
1064 ///
1065 /// * `request` - No description provided.
1066 /// * `parent` - Required. The resource name of the project and location the namespace will be created in.
1067 pub fn locations_namespaces_create(
1068 &self,
1069 request: Namespace,
1070 parent: &str,
1071 ) -> ProjectLocationNamespaceCreateCall<'a, C> {
1072 ProjectLocationNamespaceCreateCall {
1073 hub: self.hub,
1074 _request: request,
1075 _parent: parent.to_string(),
1076 _namespace_id: Default::default(),
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 /// Deletes a namespace. This also deletes all services and endpoints in the namespace.
1086 ///
1087 /// # Arguments
1088 ///
1089 /// * `name` - Required. The name of the namespace to delete.
1090 pub fn locations_namespaces_delete(
1091 &self,
1092 name: &str,
1093 ) -> ProjectLocationNamespaceDeleteCall<'a, C> {
1094 ProjectLocationNamespaceDeleteCall {
1095 hub: self.hub,
1096 _name: name.to_string(),
1097 _delegate: Default::default(),
1098 _additional_params: Default::default(),
1099 _scopes: Default::default(),
1100 }
1101 }
1102
1103 /// Create a builder to help you perform the following task:
1104 ///
1105 /// Gets a namespace.
1106 ///
1107 /// # Arguments
1108 ///
1109 /// * `name` - Required. The name of the namespace to retrieve.
1110 pub fn locations_namespaces_get(&self, name: &str) -> ProjectLocationNamespaceGetCall<'a, C> {
1111 ProjectLocationNamespaceGetCall {
1112 hub: self.hub,
1113 _name: name.to_string(),
1114 _delegate: Default::default(),
1115 _additional_params: Default::default(),
1116 _scopes: Default::default(),
1117 }
1118 }
1119
1120 /// Create a builder to help you perform the following task:
1121 ///
1122 /// Gets the IAM Policy for a resource
1123 ///
1124 /// # Arguments
1125 ///
1126 /// * `request` - No description provided.
1127 /// * `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.
1128 pub fn locations_namespaces_get_iam_policy(
1129 &self,
1130 request: GetIamPolicyRequest,
1131 resource: &str,
1132 ) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> {
1133 ProjectLocationNamespaceGetIamPolicyCall {
1134 hub: self.hub,
1135 _request: request,
1136 _resource: resource.to_string(),
1137 _delegate: Default::default(),
1138 _additional_params: Default::default(),
1139 _scopes: Default::default(),
1140 }
1141 }
1142
1143 /// Create a builder to help you perform the following task:
1144 ///
1145 /// Lists all namespaces.
1146 ///
1147 /// # Arguments
1148 ///
1149 /// * `parent` - Required. The resource name of the project and location whose namespaces you'd like to list.
1150 pub fn locations_namespaces_list(
1151 &self,
1152 parent: &str,
1153 ) -> ProjectLocationNamespaceListCall<'a, C> {
1154 ProjectLocationNamespaceListCall {
1155 hub: self.hub,
1156 _parent: parent.to_string(),
1157 _page_token: Default::default(),
1158 _page_size: Default::default(),
1159 _order_by: Default::default(),
1160 _filter: Default::default(),
1161 _delegate: Default::default(),
1162 _additional_params: Default::default(),
1163 _scopes: Default::default(),
1164 }
1165 }
1166
1167 /// Create a builder to help you perform the following task:
1168 ///
1169 /// Updates a namespace.
1170 ///
1171 /// # Arguments
1172 ///
1173 /// * `request` - No description provided.
1174 /// * `name` - Immutable. The resource name for the namespace in the format `projects/*/locations/*/namespaces/*`.
1175 pub fn locations_namespaces_patch(
1176 &self,
1177 request: Namespace,
1178 name: &str,
1179 ) -> ProjectLocationNamespacePatchCall<'a, C> {
1180 ProjectLocationNamespacePatchCall {
1181 hub: self.hub,
1182 _request: request,
1183 _name: name.to_string(),
1184 _update_mask: Default::default(),
1185 _delegate: Default::default(),
1186 _additional_params: Default::default(),
1187 _scopes: Default::default(),
1188 }
1189 }
1190
1191 /// Create a builder to help you perform the following task:
1192 ///
1193 /// Sets the IAM Policy for a resource
1194 ///
1195 /// # Arguments
1196 ///
1197 /// * `request` - No description provided.
1198 /// * `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.
1199 pub fn locations_namespaces_set_iam_policy(
1200 &self,
1201 request: SetIamPolicyRequest,
1202 resource: &str,
1203 ) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> {
1204 ProjectLocationNamespaceSetIamPolicyCall {
1205 hub: self.hub,
1206 _request: request,
1207 _resource: resource.to_string(),
1208 _delegate: Default::default(),
1209 _additional_params: Default::default(),
1210 _scopes: Default::default(),
1211 }
1212 }
1213
1214 /// Create a builder to help you perform the following task:
1215 ///
1216 /// Tests IAM permissions for a resource (namespace, service or service workload only).
1217 ///
1218 /// # Arguments
1219 ///
1220 /// * `request` - No description provided.
1221 /// * `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.
1222 pub fn locations_namespaces_test_iam_permissions(
1223 &self,
1224 request: TestIamPermissionsRequest,
1225 resource: &str,
1226 ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> {
1227 ProjectLocationNamespaceTestIamPermissionCall {
1228 hub: self.hub,
1229 _request: request,
1230 _resource: resource.to_string(),
1231 _delegate: Default::default(),
1232 _additional_params: Default::default(),
1233 _scopes: Default::default(),
1234 }
1235 }
1236
1237 /// Create a builder to help you perform the following task:
1238 ///
1239 /// Gets information about a location.
1240 ///
1241 /// # Arguments
1242 ///
1243 /// * `name` - Resource name for the location.
1244 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1245 ProjectLocationGetCall {
1246 hub: self.hub,
1247 _name: name.to_string(),
1248 _delegate: Default::default(),
1249 _additional_params: Default::default(),
1250 _scopes: Default::default(),
1251 }
1252 }
1253
1254 /// Create a builder to help you perform the following task:
1255 ///
1256 /// Lists information about the supported locations for this service.
1257 ///
1258 /// # Arguments
1259 ///
1260 /// * `name` - The resource that owns the locations collection, if applicable.
1261 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1262 ProjectLocationListCall {
1263 hub: self.hub,
1264 _name: name.to_string(),
1265 _page_token: Default::default(),
1266 _page_size: Default::default(),
1267 _filter: Default::default(),
1268 _extra_location_types: Default::default(),
1269 _delegate: Default::default(),
1270 _additional_params: Default::default(),
1271 _scopes: Default::default(),
1272 }
1273 }
1274}
1275
1276// ###################
1277// CallBuilders ###
1278// #################
1279
1280/// Creates an endpoint, and returns the new endpoint.
1281///
1282/// A builder for the *locations.namespaces.services.endpoints.create* method supported by a *project* resource.
1283/// It is not used directly, but through a [`ProjectMethods`] instance.
1284///
1285/// # Example
1286///
1287/// Instantiate a resource method builder
1288///
1289/// ```test_harness,no_run
1290/// # extern crate hyper;
1291/// # extern crate hyper_rustls;
1292/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
1293/// use servicedirectory1_beta1::api::Endpoint;
1294/// # async fn dox() {
1295/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1296///
1297/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1298/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1299/// # .with_native_roots()
1300/// # .unwrap()
1301/// # .https_only()
1302/// # .enable_http2()
1303/// # .build();
1304///
1305/// # let executor = hyper_util::rt::TokioExecutor::new();
1306/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1307/// # secret,
1308/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1309/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1310/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1311/// # ),
1312/// # ).build().await.unwrap();
1313///
1314/// # let client = hyper_util::client::legacy::Client::builder(
1315/// # hyper_util::rt::TokioExecutor::new()
1316/// # )
1317/// # .build(
1318/// # hyper_rustls::HttpsConnectorBuilder::new()
1319/// # .with_native_roots()
1320/// # .unwrap()
1321/// # .https_or_http()
1322/// # .enable_http2()
1323/// # .build()
1324/// # );
1325/// # let mut hub = ServiceDirectory::new(client, auth);
1326/// // As the method needs a request, you would usually fill it with the desired information
1327/// // into the respective structure. Some of the parts shown here might not be applicable !
1328/// // Values shown here are possibly random and not representative !
1329/// let mut req = Endpoint::default();
1330///
1331/// // You can configure optional parameters by calling the respective setters at will, and
1332/// // execute the final call using `doit()`.
1333/// // Values shown here are possibly random and not representative !
1334/// let result = hub.projects().locations_namespaces_services_endpoints_create(req, "parent")
1335/// .endpoint_id("voluptua.")
1336/// .doit().await;
1337/// # }
1338/// ```
1339pub struct ProjectLocationNamespaceServiceEndpointCreateCall<'a, C>
1340where
1341 C: 'a,
1342{
1343 hub: &'a ServiceDirectory<C>,
1344 _request: Endpoint,
1345 _parent: String,
1346 _endpoint_id: Option<String>,
1347 _delegate: Option<&'a mut dyn common::Delegate>,
1348 _additional_params: HashMap<String, String>,
1349 _scopes: BTreeSet<String>,
1350}
1351
1352impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> {}
1353
1354impl<'a, C> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C>
1355where
1356 C: common::Connector,
1357{
1358 /// Perform the operation you have build so far.
1359 pub async fn doit(mut self) -> common::Result<(common::Response, Endpoint)> {
1360 use std::borrow::Cow;
1361 use std::io::{Read, Seek};
1362
1363 use common::{url::Params, ToParts};
1364 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1365
1366 let mut dd = common::DefaultDelegate;
1367 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1368 dlg.begin(common::MethodInfo {
1369 id: "servicedirectory.projects.locations.namespaces.services.endpoints.create",
1370 http_method: hyper::Method::POST,
1371 });
1372
1373 for &field in ["alt", "parent", "endpointId"].iter() {
1374 if self._additional_params.contains_key(field) {
1375 dlg.finished(false);
1376 return Err(common::Error::FieldClash(field));
1377 }
1378 }
1379
1380 let mut params = Params::with_capacity(5 + self._additional_params.len());
1381 params.push("parent", self._parent);
1382 if let Some(value) = self._endpoint_id.as_ref() {
1383 params.push("endpointId", value);
1384 }
1385
1386 params.extend(self._additional_params.iter());
1387
1388 params.push("alt", "json");
1389 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/endpoints";
1390 if self._scopes.is_empty() {
1391 self._scopes
1392 .insert(Scope::CloudPlatform.as_ref().to_string());
1393 }
1394
1395 #[allow(clippy::single_element_loop)]
1396 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1397 url = params.uri_replacement(url, param_name, find_this, true);
1398 }
1399 {
1400 let to_remove = ["parent"];
1401 params.remove_params(&to_remove);
1402 }
1403
1404 let url = params.parse_with_url(&url);
1405
1406 let mut json_mime_type = mime::APPLICATION_JSON;
1407 let mut request_value_reader = {
1408 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1409 common::remove_json_null_values(&mut value);
1410 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1411 serde_json::to_writer(&mut dst, &value).unwrap();
1412 dst
1413 };
1414 let request_size = request_value_reader
1415 .seek(std::io::SeekFrom::End(0))
1416 .unwrap();
1417 request_value_reader
1418 .seek(std::io::SeekFrom::Start(0))
1419 .unwrap();
1420
1421 loop {
1422 let token = match self
1423 .hub
1424 .auth
1425 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1426 .await
1427 {
1428 Ok(token) => token,
1429 Err(e) => match dlg.token(e) {
1430 Ok(token) => token,
1431 Err(e) => {
1432 dlg.finished(false);
1433 return Err(common::Error::MissingToken(e));
1434 }
1435 },
1436 };
1437 request_value_reader
1438 .seek(std::io::SeekFrom::Start(0))
1439 .unwrap();
1440 let mut req_result = {
1441 let client = &self.hub.client;
1442 dlg.pre_request();
1443 let mut req_builder = hyper::Request::builder()
1444 .method(hyper::Method::POST)
1445 .uri(url.as_str())
1446 .header(USER_AGENT, self.hub._user_agent.clone());
1447
1448 if let Some(token) = token.as_ref() {
1449 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1450 }
1451
1452 let request = req_builder
1453 .header(CONTENT_TYPE, json_mime_type.to_string())
1454 .header(CONTENT_LENGTH, request_size as u64)
1455 .body(common::to_body(
1456 request_value_reader.get_ref().clone().into(),
1457 ));
1458
1459 client.request(request.unwrap()).await
1460 };
1461
1462 match req_result {
1463 Err(err) => {
1464 if let common::Retry::After(d) = dlg.http_error(&err) {
1465 sleep(d).await;
1466 continue;
1467 }
1468 dlg.finished(false);
1469 return Err(common::Error::HttpError(err));
1470 }
1471 Ok(res) => {
1472 let (mut parts, body) = res.into_parts();
1473 let mut body = common::Body::new(body);
1474 if !parts.status.is_success() {
1475 let bytes = common::to_bytes(body).await.unwrap_or_default();
1476 let error = serde_json::from_str(&common::to_string(&bytes));
1477 let response = common::to_response(parts, bytes.into());
1478
1479 if let common::Retry::After(d) =
1480 dlg.http_failure(&response, error.as_ref().ok())
1481 {
1482 sleep(d).await;
1483 continue;
1484 }
1485
1486 dlg.finished(false);
1487
1488 return Err(match error {
1489 Ok(value) => common::Error::BadRequest(value),
1490 _ => common::Error::Failure(response),
1491 });
1492 }
1493 let response = {
1494 let bytes = common::to_bytes(body).await.unwrap_or_default();
1495 let encoded = common::to_string(&bytes);
1496 match serde_json::from_str(&encoded) {
1497 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1498 Err(error) => {
1499 dlg.response_json_decode_error(&encoded, &error);
1500 return Err(common::Error::JsonDecodeError(
1501 encoded.to_string(),
1502 error,
1503 ));
1504 }
1505 }
1506 };
1507
1508 dlg.finished(true);
1509 return Ok(response);
1510 }
1511 }
1512 }
1513 }
1514
1515 ///
1516 /// Sets the *request* property to the given value.
1517 ///
1518 /// Even though the property as already been set when instantiating this call,
1519 /// we provide this method for API completeness.
1520 pub fn request(
1521 mut self,
1522 new_value: Endpoint,
1523 ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> {
1524 self._request = new_value;
1525 self
1526 }
1527 /// Required. The resource name of the service that this endpoint provides.
1528 ///
1529 /// Sets the *parent* path property to the given value.
1530 ///
1531 /// Even though the property as already been set when instantiating this call,
1532 /// we provide this method for API completeness.
1533 pub fn parent(
1534 mut self,
1535 new_value: &str,
1536 ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> {
1537 self._parent = new_value.to_string();
1538 self
1539 }
1540 /// Required. The Resource ID must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
1541 ///
1542 /// Sets the *endpoint id* query property to the given value.
1543 pub fn endpoint_id(
1544 mut self,
1545 new_value: &str,
1546 ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> {
1547 self._endpoint_id = Some(new_value.to_string());
1548 self
1549 }
1550 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1551 /// while executing the actual API request.
1552 ///
1553 /// ````text
1554 /// It should be used to handle progress information, and to implement a certain level of resilience.
1555 /// ````
1556 ///
1557 /// Sets the *delegate* property to the given value.
1558 pub fn delegate(
1559 mut self,
1560 new_value: &'a mut dyn common::Delegate,
1561 ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> {
1562 self._delegate = Some(new_value);
1563 self
1564 }
1565
1566 /// Set any additional parameter of the query string used in the request.
1567 /// It should be used to set parameters which are not yet available through their own
1568 /// setters.
1569 ///
1570 /// Please note that this method must not be used to set any of the known parameters
1571 /// which have their own setter method. If done anyway, the request will fail.
1572 ///
1573 /// # Additional Parameters
1574 ///
1575 /// * *$.xgafv* (query-string) - V1 error format.
1576 /// * *access_token* (query-string) - OAuth access token.
1577 /// * *alt* (query-string) - Data format for response.
1578 /// * *callback* (query-string) - JSONP
1579 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1580 /// * *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.
1581 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1582 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1583 /// * *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.
1584 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1585 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1586 pub fn param<T>(
1587 mut self,
1588 name: T,
1589 value: T,
1590 ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C>
1591 where
1592 T: AsRef<str>,
1593 {
1594 self._additional_params
1595 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1596 self
1597 }
1598
1599 /// Identifies the authorization scope for the method you are building.
1600 ///
1601 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1602 /// [`Scope::CloudPlatform`].
1603 ///
1604 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1605 /// tokens for more than one scope.
1606 ///
1607 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1608 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1609 /// sufficient, a read-write scope will do as well.
1610 pub fn add_scope<St>(
1611 mut self,
1612 scope: St,
1613 ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C>
1614 where
1615 St: AsRef<str>,
1616 {
1617 self._scopes.insert(String::from(scope.as_ref()));
1618 self
1619 }
1620 /// Identifies the authorization scope(s) for the method you are building.
1621 ///
1622 /// See [`Self::add_scope()`] for details.
1623 pub fn add_scopes<I, St>(
1624 mut self,
1625 scopes: I,
1626 ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C>
1627 where
1628 I: IntoIterator<Item = St>,
1629 St: AsRef<str>,
1630 {
1631 self._scopes
1632 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1633 self
1634 }
1635
1636 /// Removes all scopes, and no default scope will be used either.
1637 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1638 /// for details).
1639 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> {
1640 self._scopes.clear();
1641 self
1642 }
1643}
1644
1645/// Deletes an endpoint.
1646///
1647/// A builder for the *locations.namespaces.services.endpoints.delete* method supported by a *project* resource.
1648/// It is not used directly, but through a [`ProjectMethods`] instance.
1649///
1650/// # Example
1651///
1652/// Instantiate a resource method builder
1653///
1654/// ```test_harness,no_run
1655/// # extern crate hyper;
1656/// # extern crate hyper_rustls;
1657/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
1658/// # async fn dox() {
1659/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1660///
1661/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1662/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1663/// # .with_native_roots()
1664/// # .unwrap()
1665/// # .https_only()
1666/// # .enable_http2()
1667/// # .build();
1668///
1669/// # let executor = hyper_util::rt::TokioExecutor::new();
1670/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1671/// # secret,
1672/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1673/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1674/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1675/// # ),
1676/// # ).build().await.unwrap();
1677///
1678/// # let client = hyper_util::client::legacy::Client::builder(
1679/// # hyper_util::rt::TokioExecutor::new()
1680/// # )
1681/// # .build(
1682/// # hyper_rustls::HttpsConnectorBuilder::new()
1683/// # .with_native_roots()
1684/// # .unwrap()
1685/// # .https_or_http()
1686/// # .enable_http2()
1687/// # .build()
1688/// # );
1689/// # let mut hub = ServiceDirectory::new(client, auth);
1690/// // You can configure optional parameters by calling the respective setters at will, and
1691/// // execute the final call using `doit()`.
1692/// // Values shown here are possibly random and not representative !
1693/// let result = hub.projects().locations_namespaces_services_endpoints_delete("name")
1694/// .doit().await;
1695/// # }
1696/// ```
1697pub struct ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C>
1698where
1699 C: 'a,
1700{
1701 hub: &'a ServiceDirectory<C>,
1702 _name: String,
1703 _delegate: Option<&'a mut dyn common::Delegate>,
1704 _additional_params: HashMap<String, String>,
1705 _scopes: BTreeSet<String>,
1706}
1707
1708impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> {}
1709
1710impl<'a, C> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C>
1711where
1712 C: common::Connector,
1713{
1714 /// Perform the operation you have build so far.
1715 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1716 use std::borrow::Cow;
1717 use std::io::{Read, Seek};
1718
1719 use common::{url::Params, ToParts};
1720 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1721
1722 let mut dd = common::DefaultDelegate;
1723 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1724 dlg.begin(common::MethodInfo {
1725 id: "servicedirectory.projects.locations.namespaces.services.endpoints.delete",
1726 http_method: hyper::Method::DELETE,
1727 });
1728
1729 for &field in ["alt", "name"].iter() {
1730 if self._additional_params.contains_key(field) {
1731 dlg.finished(false);
1732 return Err(common::Error::FieldClash(field));
1733 }
1734 }
1735
1736 let mut params = Params::with_capacity(3 + self._additional_params.len());
1737 params.push("name", self._name);
1738
1739 params.extend(self._additional_params.iter());
1740
1741 params.push("alt", "json");
1742 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
1743 if self._scopes.is_empty() {
1744 self._scopes
1745 .insert(Scope::CloudPlatform.as_ref().to_string());
1746 }
1747
1748 #[allow(clippy::single_element_loop)]
1749 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1750 url = params.uri_replacement(url, param_name, find_this, true);
1751 }
1752 {
1753 let to_remove = ["name"];
1754 params.remove_params(&to_remove);
1755 }
1756
1757 let url = params.parse_with_url(&url);
1758
1759 loop {
1760 let token = match self
1761 .hub
1762 .auth
1763 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1764 .await
1765 {
1766 Ok(token) => token,
1767 Err(e) => match dlg.token(e) {
1768 Ok(token) => token,
1769 Err(e) => {
1770 dlg.finished(false);
1771 return Err(common::Error::MissingToken(e));
1772 }
1773 },
1774 };
1775 let mut req_result = {
1776 let client = &self.hub.client;
1777 dlg.pre_request();
1778 let mut req_builder = hyper::Request::builder()
1779 .method(hyper::Method::DELETE)
1780 .uri(url.as_str())
1781 .header(USER_AGENT, self.hub._user_agent.clone());
1782
1783 if let Some(token) = token.as_ref() {
1784 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1785 }
1786
1787 let request = req_builder
1788 .header(CONTENT_LENGTH, 0_u64)
1789 .body(common::to_body::<String>(None));
1790
1791 client.request(request.unwrap()).await
1792 };
1793
1794 match req_result {
1795 Err(err) => {
1796 if let common::Retry::After(d) = dlg.http_error(&err) {
1797 sleep(d).await;
1798 continue;
1799 }
1800 dlg.finished(false);
1801 return Err(common::Error::HttpError(err));
1802 }
1803 Ok(res) => {
1804 let (mut parts, body) = res.into_parts();
1805 let mut body = common::Body::new(body);
1806 if !parts.status.is_success() {
1807 let bytes = common::to_bytes(body).await.unwrap_or_default();
1808 let error = serde_json::from_str(&common::to_string(&bytes));
1809 let response = common::to_response(parts, bytes.into());
1810
1811 if let common::Retry::After(d) =
1812 dlg.http_failure(&response, error.as_ref().ok())
1813 {
1814 sleep(d).await;
1815 continue;
1816 }
1817
1818 dlg.finished(false);
1819
1820 return Err(match error {
1821 Ok(value) => common::Error::BadRequest(value),
1822 _ => common::Error::Failure(response),
1823 });
1824 }
1825 let response = {
1826 let bytes = common::to_bytes(body).await.unwrap_or_default();
1827 let encoded = common::to_string(&bytes);
1828 match serde_json::from_str(&encoded) {
1829 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1830 Err(error) => {
1831 dlg.response_json_decode_error(&encoded, &error);
1832 return Err(common::Error::JsonDecodeError(
1833 encoded.to_string(),
1834 error,
1835 ));
1836 }
1837 }
1838 };
1839
1840 dlg.finished(true);
1841 return Ok(response);
1842 }
1843 }
1844 }
1845 }
1846
1847 /// Required. The name of the endpoint to delete.
1848 ///
1849 /// Sets the *name* path property to the given value.
1850 ///
1851 /// Even though the property as already been set when instantiating this call,
1852 /// we provide this method for API completeness.
1853 pub fn name(
1854 mut self,
1855 new_value: &str,
1856 ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> {
1857 self._name = new_value.to_string();
1858 self
1859 }
1860 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1861 /// while executing the actual API request.
1862 ///
1863 /// ````text
1864 /// It should be used to handle progress information, and to implement a certain level of resilience.
1865 /// ````
1866 ///
1867 /// Sets the *delegate* property to the given value.
1868 pub fn delegate(
1869 mut self,
1870 new_value: &'a mut dyn common::Delegate,
1871 ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> {
1872 self._delegate = Some(new_value);
1873 self
1874 }
1875
1876 /// Set any additional parameter of the query string used in the request.
1877 /// It should be used to set parameters which are not yet available through their own
1878 /// setters.
1879 ///
1880 /// Please note that this method must not be used to set any of the known parameters
1881 /// which have their own setter method. If done anyway, the request will fail.
1882 ///
1883 /// # Additional Parameters
1884 ///
1885 /// * *$.xgafv* (query-string) - V1 error format.
1886 /// * *access_token* (query-string) - OAuth access token.
1887 /// * *alt* (query-string) - Data format for response.
1888 /// * *callback* (query-string) - JSONP
1889 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1890 /// * *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.
1891 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1892 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1893 /// * *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.
1894 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1895 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1896 pub fn param<T>(
1897 mut self,
1898 name: T,
1899 value: T,
1900 ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C>
1901 where
1902 T: AsRef<str>,
1903 {
1904 self._additional_params
1905 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1906 self
1907 }
1908
1909 /// Identifies the authorization scope for the method you are building.
1910 ///
1911 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1912 /// [`Scope::CloudPlatform`].
1913 ///
1914 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1915 /// tokens for more than one scope.
1916 ///
1917 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1918 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1919 /// sufficient, a read-write scope will do as well.
1920 pub fn add_scope<St>(
1921 mut self,
1922 scope: St,
1923 ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C>
1924 where
1925 St: AsRef<str>,
1926 {
1927 self._scopes.insert(String::from(scope.as_ref()));
1928 self
1929 }
1930 /// Identifies the authorization scope(s) for the method you are building.
1931 ///
1932 /// See [`Self::add_scope()`] for details.
1933 pub fn add_scopes<I, St>(
1934 mut self,
1935 scopes: I,
1936 ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C>
1937 where
1938 I: IntoIterator<Item = St>,
1939 St: AsRef<str>,
1940 {
1941 self._scopes
1942 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1943 self
1944 }
1945
1946 /// Removes all scopes, and no default scope will be used either.
1947 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1948 /// for details).
1949 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> {
1950 self._scopes.clear();
1951 self
1952 }
1953}
1954
1955/// Gets an endpoint.
1956///
1957/// A builder for the *locations.namespaces.services.endpoints.get* method supported by a *project* resource.
1958/// It is not used directly, but through a [`ProjectMethods`] instance.
1959///
1960/// # Example
1961///
1962/// Instantiate a resource method builder
1963///
1964/// ```test_harness,no_run
1965/// # extern crate hyper;
1966/// # extern crate hyper_rustls;
1967/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
1968/// # async fn dox() {
1969/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1970///
1971/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1972/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1973/// # .with_native_roots()
1974/// # .unwrap()
1975/// # .https_only()
1976/// # .enable_http2()
1977/// # .build();
1978///
1979/// # let executor = hyper_util::rt::TokioExecutor::new();
1980/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1981/// # secret,
1982/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1983/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1984/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1985/// # ),
1986/// # ).build().await.unwrap();
1987///
1988/// # let client = hyper_util::client::legacy::Client::builder(
1989/// # hyper_util::rt::TokioExecutor::new()
1990/// # )
1991/// # .build(
1992/// # hyper_rustls::HttpsConnectorBuilder::new()
1993/// # .with_native_roots()
1994/// # .unwrap()
1995/// # .https_or_http()
1996/// # .enable_http2()
1997/// # .build()
1998/// # );
1999/// # let mut hub = ServiceDirectory::new(client, auth);
2000/// // You can configure optional parameters by calling the respective setters at will, and
2001/// // execute the final call using `doit()`.
2002/// // Values shown here are possibly random and not representative !
2003/// let result = hub.projects().locations_namespaces_services_endpoints_get("name")
2004/// .doit().await;
2005/// # }
2006/// ```
2007pub struct ProjectLocationNamespaceServiceEndpointGetCall<'a, C>
2008where
2009 C: 'a,
2010{
2011 hub: &'a ServiceDirectory<C>,
2012 _name: String,
2013 _delegate: Option<&'a mut dyn common::Delegate>,
2014 _additional_params: HashMap<String, String>,
2015 _scopes: BTreeSet<String>,
2016}
2017
2018impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointGetCall<'a, C> {}
2019
2020impl<'a, C> ProjectLocationNamespaceServiceEndpointGetCall<'a, C>
2021where
2022 C: common::Connector,
2023{
2024 /// Perform the operation you have build so far.
2025 pub async fn doit(mut self) -> common::Result<(common::Response, Endpoint)> {
2026 use std::borrow::Cow;
2027 use std::io::{Read, Seek};
2028
2029 use common::{url::Params, ToParts};
2030 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2031
2032 let mut dd = common::DefaultDelegate;
2033 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2034 dlg.begin(common::MethodInfo {
2035 id: "servicedirectory.projects.locations.namespaces.services.endpoints.get",
2036 http_method: hyper::Method::GET,
2037 });
2038
2039 for &field in ["alt", "name"].iter() {
2040 if self._additional_params.contains_key(field) {
2041 dlg.finished(false);
2042 return Err(common::Error::FieldClash(field));
2043 }
2044 }
2045
2046 let mut params = Params::with_capacity(3 + self._additional_params.len());
2047 params.push("name", self._name);
2048
2049 params.extend(self._additional_params.iter());
2050
2051 params.push("alt", "json");
2052 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2053 if self._scopes.is_empty() {
2054 self._scopes
2055 .insert(Scope::CloudPlatform.as_ref().to_string());
2056 }
2057
2058 #[allow(clippy::single_element_loop)]
2059 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2060 url = params.uri_replacement(url, param_name, find_this, true);
2061 }
2062 {
2063 let to_remove = ["name"];
2064 params.remove_params(&to_remove);
2065 }
2066
2067 let url = params.parse_with_url(&url);
2068
2069 loop {
2070 let token = match self
2071 .hub
2072 .auth
2073 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2074 .await
2075 {
2076 Ok(token) => token,
2077 Err(e) => match dlg.token(e) {
2078 Ok(token) => token,
2079 Err(e) => {
2080 dlg.finished(false);
2081 return Err(common::Error::MissingToken(e));
2082 }
2083 },
2084 };
2085 let mut req_result = {
2086 let client = &self.hub.client;
2087 dlg.pre_request();
2088 let mut req_builder = hyper::Request::builder()
2089 .method(hyper::Method::GET)
2090 .uri(url.as_str())
2091 .header(USER_AGENT, self.hub._user_agent.clone());
2092
2093 if let Some(token) = token.as_ref() {
2094 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2095 }
2096
2097 let request = req_builder
2098 .header(CONTENT_LENGTH, 0_u64)
2099 .body(common::to_body::<String>(None));
2100
2101 client.request(request.unwrap()).await
2102 };
2103
2104 match req_result {
2105 Err(err) => {
2106 if let common::Retry::After(d) = dlg.http_error(&err) {
2107 sleep(d).await;
2108 continue;
2109 }
2110 dlg.finished(false);
2111 return Err(common::Error::HttpError(err));
2112 }
2113 Ok(res) => {
2114 let (mut parts, body) = res.into_parts();
2115 let mut body = common::Body::new(body);
2116 if !parts.status.is_success() {
2117 let bytes = common::to_bytes(body).await.unwrap_or_default();
2118 let error = serde_json::from_str(&common::to_string(&bytes));
2119 let response = common::to_response(parts, bytes.into());
2120
2121 if let common::Retry::After(d) =
2122 dlg.http_failure(&response, error.as_ref().ok())
2123 {
2124 sleep(d).await;
2125 continue;
2126 }
2127
2128 dlg.finished(false);
2129
2130 return Err(match error {
2131 Ok(value) => common::Error::BadRequest(value),
2132 _ => common::Error::Failure(response),
2133 });
2134 }
2135 let response = {
2136 let bytes = common::to_bytes(body).await.unwrap_or_default();
2137 let encoded = common::to_string(&bytes);
2138 match serde_json::from_str(&encoded) {
2139 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2140 Err(error) => {
2141 dlg.response_json_decode_error(&encoded, &error);
2142 return Err(common::Error::JsonDecodeError(
2143 encoded.to_string(),
2144 error,
2145 ));
2146 }
2147 }
2148 };
2149
2150 dlg.finished(true);
2151 return Ok(response);
2152 }
2153 }
2154 }
2155 }
2156
2157 /// Required. The name of the endpoint to get.
2158 ///
2159 /// Sets the *name* path property to the given value.
2160 ///
2161 /// Even though the property as already been set when instantiating this call,
2162 /// we provide this method for API completeness.
2163 pub fn name(
2164 mut self,
2165 new_value: &str,
2166 ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> {
2167 self._name = new_value.to_string();
2168 self
2169 }
2170 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2171 /// while executing the actual API request.
2172 ///
2173 /// ````text
2174 /// It should be used to handle progress information, and to implement a certain level of resilience.
2175 /// ````
2176 ///
2177 /// Sets the *delegate* property to the given value.
2178 pub fn delegate(
2179 mut self,
2180 new_value: &'a mut dyn common::Delegate,
2181 ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> {
2182 self._delegate = Some(new_value);
2183 self
2184 }
2185
2186 /// Set any additional parameter of the query string used in the request.
2187 /// It should be used to set parameters which are not yet available through their own
2188 /// setters.
2189 ///
2190 /// Please note that this method must not be used to set any of the known parameters
2191 /// which have their own setter method. If done anyway, the request will fail.
2192 ///
2193 /// # Additional Parameters
2194 ///
2195 /// * *$.xgafv* (query-string) - V1 error format.
2196 /// * *access_token* (query-string) - OAuth access token.
2197 /// * *alt* (query-string) - Data format for response.
2198 /// * *callback* (query-string) - JSONP
2199 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2200 /// * *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.
2201 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2202 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2203 /// * *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.
2204 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2205 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2206 pub fn param<T>(
2207 mut self,
2208 name: T,
2209 value: T,
2210 ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C>
2211 where
2212 T: AsRef<str>,
2213 {
2214 self._additional_params
2215 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2216 self
2217 }
2218
2219 /// Identifies the authorization scope for the method you are building.
2220 ///
2221 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2222 /// [`Scope::CloudPlatform`].
2223 ///
2224 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2225 /// tokens for more than one scope.
2226 ///
2227 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2228 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2229 /// sufficient, a read-write scope will do as well.
2230 pub fn add_scope<St>(
2231 mut self,
2232 scope: St,
2233 ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C>
2234 where
2235 St: AsRef<str>,
2236 {
2237 self._scopes.insert(String::from(scope.as_ref()));
2238 self
2239 }
2240 /// Identifies the authorization scope(s) for the method you are building.
2241 ///
2242 /// See [`Self::add_scope()`] for details.
2243 pub fn add_scopes<I, St>(
2244 mut self,
2245 scopes: I,
2246 ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C>
2247 where
2248 I: IntoIterator<Item = St>,
2249 St: AsRef<str>,
2250 {
2251 self._scopes
2252 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2253 self
2254 }
2255
2256 /// Removes all scopes, and no default scope will be used either.
2257 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2258 /// for details).
2259 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> {
2260 self._scopes.clear();
2261 self
2262 }
2263}
2264
2265/// Lists all endpoints.
2266///
2267/// A builder for the *locations.namespaces.services.endpoints.list* method supported by a *project* resource.
2268/// It is not used directly, but through a [`ProjectMethods`] instance.
2269///
2270/// # Example
2271///
2272/// Instantiate a resource method builder
2273///
2274/// ```test_harness,no_run
2275/// # extern crate hyper;
2276/// # extern crate hyper_rustls;
2277/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
2278/// # async fn dox() {
2279/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2280///
2281/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2282/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2283/// # .with_native_roots()
2284/// # .unwrap()
2285/// # .https_only()
2286/// # .enable_http2()
2287/// # .build();
2288///
2289/// # let executor = hyper_util::rt::TokioExecutor::new();
2290/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2291/// # secret,
2292/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2293/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2294/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2295/// # ),
2296/// # ).build().await.unwrap();
2297///
2298/// # let client = hyper_util::client::legacy::Client::builder(
2299/// # hyper_util::rt::TokioExecutor::new()
2300/// # )
2301/// # .build(
2302/// # hyper_rustls::HttpsConnectorBuilder::new()
2303/// # .with_native_roots()
2304/// # .unwrap()
2305/// # .https_or_http()
2306/// # .enable_http2()
2307/// # .build()
2308/// # );
2309/// # let mut hub = ServiceDirectory::new(client, auth);
2310/// // You can configure optional parameters by calling the respective setters at will, and
2311/// // execute the final call using `doit()`.
2312/// // Values shown here are possibly random and not representative !
2313/// let result = hub.projects().locations_namespaces_services_endpoints_list("parent")
2314/// .page_token("amet.")
2315/// .page_size(-59)
2316/// .order_by("amet.")
2317/// .filter("duo")
2318/// .doit().await;
2319/// # }
2320/// ```
2321pub struct ProjectLocationNamespaceServiceEndpointListCall<'a, C>
2322where
2323 C: 'a,
2324{
2325 hub: &'a ServiceDirectory<C>,
2326 _parent: String,
2327 _page_token: Option<String>,
2328 _page_size: Option<i32>,
2329 _order_by: Option<String>,
2330 _filter: Option<String>,
2331 _delegate: Option<&'a mut dyn common::Delegate>,
2332 _additional_params: HashMap<String, String>,
2333 _scopes: BTreeSet<String>,
2334}
2335
2336impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointListCall<'a, C> {}
2337
2338impl<'a, C> ProjectLocationNamespaceServiceEndpointListCall<'a, C>
2339where
2340 C: common::Connector,
2341{
2342 /// Perform the operation you have build so far.
2343 pub async fn doit(mut self) -> common::Result<(common::Response, ListEndpointsResponse)> {
2344 use std::borrow::Cow;
2345 use std::io::{Read, Seek};
2346
2347 use common::{url::Params, ToParts};
2348 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2349
2350 let mut dd = common::DefaultDelegate;
2351 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2352 dlg.begin(common::MethodInfo {
2353 id: "servicedirectory.projects.locations.namespaces.services.endpoints.list",
2354 http_method: hyper::Method::GET,
2355 });
2356
2357 for &field in [
2358 "alt",
2359 "parent",
2360 "pageToken",
2361 "pageSize",
2362 "orderBy",
2363 "filter",
2364 ]
2365 .iter()
2366 {
2367 if self._additional_params.contains_key(field) {
2368 dlg.finished(false);
2369 return Err(common::Error::FieldClash(field));
2370 }
2371 }
2372
2373 let mut params = Params::with_capacity(7 + self._additional_params.len());
2374 params.push("parent", self._parent);
2375 if let Some(value) = self._page_token.as_ref() {
2376 params.push("pageToken", value);
2377 }
2378 if let Some(value) = self._page_size.as_ref() {
2379 params.push("pageSize", value.to_string());
2380 }
2381 if let Some(value) = self._order_by.as_ref() {
2382 params.push("orderBy", value);
2383 }
2384 if let Some(value) = self._filter.as_ref() {
2385 params.push("filter", value);
2386 }
2387
2388 params.extend(self._additional_params.iter());
2389
2390 params.push("alt", "json");
2391 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/endpoints";
2392 if self._scopes.is_empty() {
2393 self._scopes
2394 .insert(Scope::CloudPlatform.as_ref().to_string());
2395 }
2396
2397 #[allow(clippy::single_element_loop)]
2398 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2399 url = params.uri_replacement(url, param_name, find_this, true);
2400 }
2401 {
2402 let to_remove = ["parent"];
2403 params.remove_params(&to_remove);
2404 }
2405
2406 let url = params.parse_with_url(&url);
2407
2408 loop {
2409 let token = match self
2410 .hub
2411 .auth
2412 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2413 .await
2414 {
2415 Ok(token) => token,
2416 Err(e) => match dlg.token(e) {
2417 Ok(token) => token,
2418 Err(e) => {
2419 dlg.finished(false);
2420 return Err(common::Error::MissingToken(e));
2421 }
2422 },
2423 };
2424 let mut req_result = {
2425 let client = &self.hub.client;
2426 dlg.pre_request();
2427 let mut req_builder = hyper::Request::builder()
2428 .method(hyper::Method::GET)
2429 .uri(url.as_str())
2430 .header(USER_AGENT, self.hub._user_agent.clone());
2431
2432 if let Some(token) = token.as_ref() {
2433 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2434 }
2435
2436 let request = req_builder
2437 .header(CONTENT_LENGTH, 0_u64)
2438 .body(common::to_body::<String>(None));
2439
2440 client.request(request.unwrap()).await
2441 };
2442
2443 match req_result {
2444 Err(err) => {
2445 if let common::Retry::After(d) = dlg.http_error(&err) {
2446 sleep(d).await;
2447 continue;
2448 }
2449 dlg.finished(false);
2450 return Err(common::Error::HttpError(err));
2451 }
2452 Ok(res) => {
2453 let (mut parts, body) = res.into_parts();
2454 let mut body = common::Body::new(body);
2455 if !parts.status.is_success() {
2456 let bytes = common::to_bytes(body).await.unwrap_or_default();
2457 let error = serde_json::from_str(&common::to_string(&bytes));
2458 let response = common::to_response(parts, bytes.into());
2459
2460 if let common::Retry::After(d) =
2461 dlg.http_failure(&response, error.as_ref().ok())
2462 {
2463 sleep(d).await;
2464 continue;
2465 }
2466
2467 dlg.finished(false);
2468
2469 return Err(match error {
2470 Ok(value) => common::Error::BadRequest(value),
2471 _ => common::Error::Failure(response),
2472 });
2473 }
2474 let response = {
2475 let bytes = common::to_bytes(body).await.unwrap_or_default();
2476 let encoded = common::to_string(&bytes);
2477 match serde_json::from_str(&encoded) {
2478 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2479 Err(error) => {
2480 dlg.response_json_decode_error(&encoded, &error);
2481 return Err(common::Error::JsonDecodeError(
2482 encoded.to_string(),
2483 error,
2484 ));
2485 }
2486 }
2487 };
2488
2489 dlg.finished(true);
2490 return Ok(response);
2491 }
2492 }
2493 }
2494 }
2495
2496 /// Required. The resource name of the service whose endpoints you'd like to list.
2497 ///
2498 /// Sets the *parent* path property to the given value.
2499 ///
2500 /// Even though the property as already been set when instantiating this call,
2501 /// we provide this method for API completeness.
2502 pub fn parent(
2503 mut self,
2504 new_value: &str,
2505 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> {
2506 self._parent = new_value.to_string();
2507 self
2508 }
2509 /// Optional. The next_page_token value returned from a previous List request, if any.
2510 ///
2511 /// Sets the *page token* query property to the given value.
2512 pub fn page_token(
2513 mut self,
2514 new_value: &str,
2515 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> {
2516 self._page_token = Some(new_value.to_string());
2517 self
2518 }
2519 /// Optional. The maximum number of items to return. The default value is 100.
2520 ///
2521 /// Sets the *page size* query property to the given value.
2522 pub fn page_size(
2523 mut self,
2524 new_value: i32,
2525 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> {
2526 self._page_size = Some(new_value);
2527 self
2528 }
2529 /// Optional. The order to list results by. General `order_by` string syntax: ` () (,)` * `` allows values: `name`, `address`, `port` * `` ascending or descending order by ``. If this is left blank, `asc` is used Note that an empty `order_by` string results in default order, which is order by `name` in ascending order.
2530 ///
2531 /// Sets the *order by* query property to the given value.
2532 pub fn order_by(
2533 mut self,
2534 new_value: &str,
2535 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> {
2536 self._order_by = Some(new_value.to_string());
2537 self
2538 }
2539 /// Optional. The filter to list results by. General `filter` string syntax: ` ()` * `` can be `name`, `address`, `port`, `metadata.` for map field, or `attributes.` for attributes field * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` means `HAS`, and is roughly the same as `=` * `` must be the same data type as field * `` can be `AND`, `OR`, `NOT` Examples of valid filters: * `metadata.owner` returns endpoints that have a metadata with the key `owner`, this is the same as `metadata:owner` * `metadata.protocol=gRPC` returns endpoints that have key/value `protocol=gRPC` * `address=192.108.1.105` returns endpoints that have this address * `port>8080` returns endpoints that have port number larger than 8080 * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` returns endpoints that have name that is alphabetically later than the string, so "endpoint-e" is returned but "endpoint-a" is not * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have `owner` in metadata key but value is not `sd` AND have key/value `foo=bar` * `doesnotexist.foo=bar` returns an empty list. Note that endpoint doesn't have a field called "doesnotexist". Since the filter does not match any endpoints, it returns no results * `attributes.kubernetes_resource_type=KUBERNETES_RESOURCE_TYPE_CLUSTER_ IP` returns endpoints with the corresponding kubernetes_resource_type For more information about filtering, see [API Filtering](https://aip.dev/160).
2540 ///
2541 /// Sets the *filter* query property to the given value.
2542 pub fn filter(
2543 mut self,
2544 new_value: &str,
2545 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> {
2546 self._filter = Some(new_value.to_string());
2547 self
2548 }
2549 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2550 /// while executing the actual API request.
2551 ///
2552 /// ````text
2553 /// It should be used to handle progress information, and to implement a certain level of resilience.
2554 /// ````
2555 ///
2556 /// Sets the *delegate* property to the given value.
2557 pub fn delegate(
2558 mut self,
2559 new_value: &'a mut dyn common::Delegate,
2560 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> {
2561 self._delegate = Some(new_value);
2562 self
2563 }
2564
2565 /// Set any additional parameter of the query string used in the request.
2566 /// It should be used to set parameters which are not yet available through their own
2567 /// setters.
2568 ///
2569 /// Please note that this method must not be used to set any of the known parameters
2570 /// which have their own setter method. If done anyway, the request will fail.
2571 ///
2572 /// # Additional Parameters
2573 ///
2574 /// * *$.xgafv* (query-string) - V1 error format.
2575 /// * *access_token* (query-string) - OAuth access token.
2576 /// * *alt* (query-string) - Data format for response.
2577 /// * *callback* (query-string) - JSONP
2578 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2579 /// * *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.
2580 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2581 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2582 /// * *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.
2583 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2584 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2585 pub fn param<T>(
2586 mut self,
2587 name: T,
2588 value: T,
2589 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C>
2590 where
2591 T: AsRef<str>,
2592 {
2593 self._additional_params
2594 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2595 self
2596 }
2597
2598 /// Identifies the authorization scope for the method you are building.
2599 ///
2600 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2601 /// [`Scope::CloudPlatform`].
2602 ///
2603 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2604 /// tokens for more than one scope.
2605 ///
2606 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2607 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2608 /// sufficient, a read-write scope will do as well.
2609 pub fn add_scope<St>(
2610 mut self,
2611 scope: St,
2612 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C>
2613 where
2614 St: AsRef<str>,
2615 {
2616 self._scopes.insert(String::from(scope.as_ref()));
2617 self
2618 }
2619 /// Identifies the authorization scope(s) for the method you are building.
2620 ///
2621 /// See [`Self::add_scope()`] for details.
2622 pub fn add_scopes<I, St>(
2623 mut self,
2624 scopes: I,
2625 ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C>
2626 where
2627 I: IntoIterator<Item = St>,
2628 St: AsRef<str>,
2629 {
2630 self._scopes
2631 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2632 self
2633 }
2634
2635 /// Removes all scopes, and no default scope will be used either.
2636 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2637 /// for details).
2638 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> {
2639 self._scopes.clear();
2640 self
2641 }
2642}
2643
2644/// Updates an endpoint.
2645///
2646/// A builder for the *locations.namespaces.services.endpoints.patch* method supported by a *project* resource.
2647/// It is not used directly, but through a [`ProjectMethods`] instance.
2648///
2649/// # Example
2650///
2651/// Instantiate a resource method builder
2652///
2653/// ```test_harness,no_run
2654/// # extern crate hyper;
2655/// # extern crate hyper_rustls;
2656/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
2657/// use servicedirectory1_beta1::api::Endpoint;
2658/// # async fn dox() {
2659/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2660///
2661/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2662/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2663/// # .with_native_roots()
2664/// # .unwrap()
2665/// # .https_only()
2666/// # .enable_http2()
2667/// # .build();
2668///
2669/// # let executor = hyper_util::rt::TokioExecutor::new();
2670/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2671/// # secret,
2672/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2673/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2674/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2675/// # ),
2676/// # ).build().await.unwrap();
2677///
2678/// # let client = hyper_util::client::legacy::Client::builder(
2679/// # hyper_util::rt::TokioExecutor::new()
2680/// # )
2681/// # .build(
2682/// # hyper_rustls::HttpsConnectorBuilder::new()
2683/// # .with_native_roots()
2684/// # .unwrap()
2685/// # .https_or_http()
2686/// # .enable_http2()
2687/// # .build()
2688/// # );
2689/// # let mut hub = ServiceDirectory::new(client, auth);
2690/// // As the method needs a request, you would usually fill it with the desired information
2691/// // into the respective structure. Some of the parts shown here might not be applicable !
2692/// // Values shown here are possibly random and not representative !
2693/// let mut req = Endpoint::default();
2694///
2695/// // You can configure optional parameters by calling the respective setters at will, and
2696/// // execute the final call using `doit()`.
2697/// // Values shown here are possibly random and not representative !
2698/// let result = hub.projects().locations_namespaces_services_endpoints_patch(req, "name")
2699/// .update_mask(FieldMask::new::<&str>(&[]))
2700/// .doit().await;
2701/// # }
2702/// ```
2703pub struct ProjectLocationNamespaceServiceEndpointPatchCall<'a, C>
2704where
2705 C: 'a,
2706{
2707 hub: &'a ServiceDirectory<C>,
2708 _request: Endpoint,
2709 _name: String,
2710 _update_mask: Option<common::FieldMask>,
2711 _delegate: Option<&'a mut dyn common::Delegate>,
2712 _additional_params: HashMap<String, String>,
2713 _scopes: BTreeSet<String>,
2714}
2715
2716impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> {}
2717
2718impl<'a, C> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C>
2719where
2720 C: common::Connector,
2721{
2722 /// Perform the operation you have build so far.
2723 pub async fn doit(mut self) -> common::Result<(common::Response, Endpoint)> {
2724 use std::borrow::Cow;
2725 use std::io::{Read, Seek};
2726
2727 use common::{url::Params, ToParts};
2728 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2729
2730 let mut dd = common::DefaultDelegate;
2731 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2732 dlg.begin(common::MethodInfo {
2733 id: "servicedirectory.projects.locations.namespaces.services.endpoints.patch",
2734 http_method: hyper::Method::PATCH,
2735 });
2736
2737 for &field in ["alt", "name", "updateMask"].iter() {
2738 if self._additional_params.contains_key(field) {
2739 dlg.finished(false);
2740 return Err(common::Error::FieldClash(field));
2741 }
2742 }
2743
2744 let mut params = Params::with_capacity(5 + self._additional_params.len());
2745 params.push("name", self._name);
2746 if let Some(value) = self._update_mask.as_ref() {
2747 params.push("updateMask", value.to_string());
2748 }
2749
2750 params.extend(self._additional_params.iter());
2751
2752 params.push("alt", "json");
2753 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2754 if self._scopes.is_empty() {
2755 self._scopes
2756 .insert(Scope::CloudPlatform.as_ref().to_string());
2757 }
2758
2759 #[allow(clippy::single_element_loop)]
2760 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2761 url = params.uri_replacement(url, param_name, find_this, true);
2762 }
2763 {
2764 let to_remove = ["name"];
2765 params.remove_params(&to_remove);
2766 }
2767
2768 let url = params.parse_with_url(&url);
2769
2770 let mut json_mime_type = mime::APPLICATION_JSON;
2771 let mut request_value_reader = {
2772 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2773 common::remove_json_null_values(&mut value);
2774 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2775 serde_json::to_writer(&mut dst, &value).unwrap();
2776 dst
2777 };
2778 let request_size = request_value_reader
2779 .seek(std::io::SeekFrom::End(0))
2780 .unwrap();
2781 request_value_reader
2782 .seek(std::io::SeekFrom::Start(0))
2783 .unwrap();
2784
2785 loop {
2786 let token = match self
2787 .hub
2788 .auth
2789 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2790 .await
2791 {
2792 Ok(token) => token,
2793 Err(e) => match dlg.token(e) {
2794 Ok(token) => token,
2795 Err(e) => {
2796 dlg.finished(false);
2797 return Err(common::Error::MissingToken(e));
2798 }
2799 },
2800 };
2801 request_value_reader
2802 .seek(std::io::SeekFrom::Start(0))
2803 .unwrap();
2804 let mut req_result = {
2805 let client = &self.hub.client;
2806 dlg.pre_request();
2807 let mut req_builder = hyper::Request::builder()
2808 .method(hyper::Method::PATCH)
2809 .uri(url.as_str())
2810 .header(USER_AGENT, self.hub._user_agent.clone());
2811
2812 if let Some(token) = token.as_ref() {
2813 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2814 }
2815
2816 let request = req_builder
2817 .header(CONTENT_TYPE, json_mime_type.to_string())
2818 .header(CONTENT_LENGTH, request_size as u64)
2819 .body(common::to_body(
2820 request_value_reader.get_ref().clone().into(),
2821 ));
2822
2823 client.request(request.unwrap()).await
2824 };
2825
2826 match req_result {
2827 Err(err) => {
2828 if let common::Retry::After(d) = dlg.http_error(&err) {
2829 sleep(d).await;
2830 continue;
2831 }
2832 dlg.finished(false);
2833 return Err(common::Error::HttpError(err));
2834 }
2835 Ok(res) => {
2836 let (mut parts, body) = res.into_parts();
2837 let mut body = common::Body::new(body);
2838 if !parts.status.is_success() {
2839 let bytes = common::to_bytes(body).await.unwrap_or_default();
2840 let error = serde_json::from_str(&common::to_string(&bytes));
2841 let response = common::to_response(parts, bytes.into());
2842
2843 if let common::Retry::After(d) =
2844 dlg.http_failure(&response, error.as_ref().ok())
2845 {
2846 sleep(d).await;
2847 continue;
2848 }
2849
2850 dlg.finished(false);
2851
2852 return Err(match error {
2853 Ok(value) => common::Error::BadRequest(value),
2854 _ => common::Error::Failure(response),
2855 });
2856 }
2857 let response = {
2858 let bytes = common::to_bytes(body).await.unwrap_or_default();
2859 let encoded = common::to_string(&bytes);
2860 match serde_json::from_str(&encoded) {
2861 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2862 Err(error) => {
2863 dlg.response_json_decode_error(&encoded, &error);
2864 return Err(common::Error::JsonDecodeError(
2865 encoded.to_string(),
2866 error,
2867 ));
2868 }
2869 }
2870 };
2871
2872 dlg.finished(true);
2873 return Ok(response);
2874 }
2875 }
2876 }
2877 }
2878
2879 ///
2880 /// Sets the *request* property to the given value.
2881 ///
2882 /// Even though the property as already been set when instantiating this call,
2883 /// we provide this method for API completeness.
2884 pub fn request(
2885 mut self,
2886 new_value: Endpoint,
2887 ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> {
2888 self._request = new_value;
2889 self
2890 }
2891 /// Immutable. The resource name for the endpoint in the format `projects/*/locations/*/namespaces/*/services/*/endpoints/*`.
2892 ///
2893 /// Sets the *name* path property to the given value.
2894 ///
2895 /// Even though the property as already been set when instantiating this call,
2896 /// we provide this method for API completeness.
2897 pub fn name(
2898 mut self,
2899 new_value: &str,
2900 ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> {
2901 self._name = new_value.to_string();
2902 self
2903 }
2904 /// Required. List of fields to be updated in this request.
2905 ///
2906 /// Sets the *update mask* query property to the given value.
2907 pub fn update_mask(
2908 mut self,
2909 new_value: common::FieldMask,
2910 ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> {
2911 self._update_mask = Some(new_value);
2912 self
2913 }
2914 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2915 /// while executing the actual API request.
2916 ///
2917 /// ````text
2918 /// It should be used to handle progress information, and to implement a certain level of resilience.
2919 /// ````
2920 ///
2921 /// Sets the *delegate* property to the given value.
2922 pub fn delegate(
2923 mut self,
2924 new_value: &'a mut dyn common::Delegate,
2925 ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> {
2926 self._delegate = Some(new_value);
2927 self
2928 }
2929
2930 /// Set any additional parameter of the query string used in the request.
2931 /// It should be used to set parameters which are not yet available through their own
2932 /// setters.
2933 ///
2934 /// Please note that this method must not be used to set any of the known parameters
2935 /// which have their own setter method. If done anyway, the request will fail.
2936 ///
2937 /// # Additional Parameters
2938 ///
2939 /// * *$.xgafv* (query-string) - V1 error format.
2940 /// * *access_token* (query-string) - OAuth access token.
2941 /// * *alt* (query-string) - Data format for response.
2942 /// * *callback* (query-string) - JSONP
2943 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2944 /// * *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.
2945 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2946 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2947 /// * *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.
2948 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2949 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2950 pub fn param<T>(
2951 mut self,
2952 name: T,
2953 value: T,
2954 ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C>
2955 where
2956 T: AsRef<str>,
2957 {
2958 self._additional_params
2959 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2960 self
2961 }
2962
2963 /// Identifies the authorization scope for the method you are building.
2964 ///
2965 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2966 /// [`Scope::CloudPlatform`].
2967 ///
2968 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2969 /// tokens for more than one scope.
2970 ///
2971 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2972 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2973 /// sufficient, a read-write scope will do as well.
2974 pub fn add_scope<St>(
2975 mut self,
2976 scope: St,
2977 ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C>
2978 where
2979 St: AsRef<str>,
2980 {
2981 self._scopes.insert(String::from(scope.as_ref()));
2982 self
2983 }
2984 /// Identifies the authorization scope(s) for the method you are building.
2985 ///
2986 /// See [`Self::add_scope()`] for details.
2987 pub fn add_scopes<I, St>(
2988 mut self,
2989 scopes: I,
2990 ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C>
2991 where
2992 I: IntoIterator<Item = St>,
2993 St: AsRef<str>,
2994 {
2995 self._scopes
2996 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2997 self
2998 }
2999
3000 /// Removes all scopes, and no default scope will be used either.
3001 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3002 /// for details).
3003 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> {
3004 self._scopes.clear();
3005 self
3006 }
3007}
3008
3009/// Creates a service, and returns the new service.
3010///
3011/// A builder for the *locations.namespaces.services.create* method supported by a *project* resource.
3012/// It is not used directly, but through a [`ProjectMethods`] instance.
3013///
3014/// # Example
3015///
3016/// Instantiate a resource method builder
3017///
3018/// ```test_harness,no_run
3019/// # extern crate hyper;
3020/// # extern crate hyper_rustls;
3021/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
3022/// use servicedirectory1_beta1::api::Service;
3023/// # async fn dox() {
3024/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3025///
3026/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3027/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3028/// # .with_native_roots()
3029/// # .unwrap()
3030/// # .https_only()
3031/// # .enable_http2()
3032/// # .build();
3033///
3034/// # let executor = hyper_util::rt::TokioExecutor::new();
3035/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3036/// # secret,
3037/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3038/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3039/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3040/// # ),
3041/// # ).build().await.unwrap();
3042///
3043/// # let client = hyper_util::client::legacy::Client::builder(
3044/// # hyper_util::rt::TokioExecutor::new()
3045/// # )
3046/// # .build(
3047/// # hyper_rustls::HttpsConnectorBuilder::new()
3048/// # .with_native_roots()
3049/// # .unwrap()
3050/// # .https_or_http()
3051/// # .enable_http2()
3052/// # .build()
3053/// # );
3054/// # let mut hub = ServiceDirectory::new(client, auth);
3055/// // As the method needs a request, you would usually fill it with the desired information
3056/// // into the respective structure. Some of the parts shown here might not be applicable !
3057/// // Values shown here are possibly random and not representative !
3058/// let mut req = Service::default();
3059///
3060/// // You can configure optional parameters by calling the respective setters at will, and
3061/// // execute the final call using `doit()`.
3062/// // Values shown here are possibly random and not representative !
3063/// let result = hub.projects().locations_namespaces_services_create(req, "parent")
3064/// .service_id("Lorem")
3065/// .doit().await;
3066/// # }
3067/// ```
3068pub struct ProjectLocationNamespaceServiceCreateCall<'a, C>
3069where
3070 C: 'a,
3071{
3072 hub: &'a ServiceDirectory<C>,
3073 _request: Service,
3074 _parent: String,
3075 _service_id: Option<String>,
3076 _delegate: Option<&'a mut dyn common::Delegate>,
3077 _additional_params: HashMap<String, String>,
3078 _scopes: BTreeSet<String>,
3079}
3080
3081impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceCreateCall<'a, C> {}
3082
3083impl<'a, C> ProjectLocationNamespaceServiceCreateCall<'a, C>
3084where
3085 C: common::Connector,
3086{
3087 /// Perform the operation you have build so far.
3088 pub async fn doit(mut self) -> common::Result<(common::Response, Service)> {
3089 use std::borrow::Cow;
3090 use std::io::{Read, Seek};
3091
3092 use common::{url::Params, ToParts};
3093 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3094
3095 let mut dd = common::DefaultDelegate;
3096 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3097 dlg.begin(common::MethodInfo {
3098 id: "servicedirectory.projects.locations.namespaces.services.create",
3099 http_method: hyper::Method::POST,
3100 });
3101
3102 for &field in ["alt", "parent", "serviceId"].iter() {
3103 if self._additional_params.contains_key(field) {
3104 dlg.finished(false);
3105 return Err(common::Error::FieldClash(field));
3106 }
3107 }
3108
3109 let mut params = Params::with_capacity(5 + self._additional_params.len());
3110 params.push("parent", self._parent);
3111 if let Some(value) = self._service_id.as_ref() {
3112 params.push("serviceId", value);
3113 }
3114
3115 params.extend(self._additional_params.iter());
3116
3117 params.push("alt", "json");
3118 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/services";
3119 if self._scopes.is_empty() {
3120 self._scopes
3121 .insert(Scope::CloudPlatform.as_ref().to_string());
3122 }
3123
3124 #[allow(clippy::single_element_loop)]
3125 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3126 url = params.uri_replacement(url, param_name, find_this, true);
3127 }
3128 {
3129 let to_remove = ["parent"];
3130 params.remove_params(&to_remove);
3131 }
3132
3133 let url = params.parse_with_url(&url);
3134
3135 let mut json_mime_type = mime::APPLICATION_JSON;
3136 let mut request_value_reader = {
3137 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3138 common::remove_json_null_values(&mut value);
3139 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3140 serde_json::to_writer(&mut dst, &value).unwrap();
3141 dst
3142 };
3143 let request_size = request_value_reader
3144 .seek(std::io::SeekFrom::End(0))
3145 .unwrap();
3146 request_value_reader
3147 .seek(std::io::SeekFrom::Start(0))
3148 .unwrap();
3149
3150 loop {
3151 let token = match self
3152 .hub
3153 .auth
3154 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3155 .await
3156 {
3157 Ok(token) => token,
3158 Err(e) => match dlg.token(e) {
3159 Ok(token) => token,
3160 Err(e) => {
3161 dlg.finished(false);
3162 return Err(common::Error::MissingToken(e));
3163 }
3164 },
3165 };
3166 request_value_reader
3167 .seek(std::io::SeekFrom::Start(0))
3168 .unwrap();
3169 let mut req_result = {
3170 let client = &self.hub.client;
3171 dlg.pre_request();
3172 let mut req_builder = hyper::Request::builder()
3173 .method(hyper::Method::POST)
3174 .uri(url.as_str())
3175 .header(USER_AGENT, self.hub._user_agent.clone());
3176
3177 if let Some(token) = token.as_ref() {
3178 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3179 }
3180
3181 let request = req_builder
3182 .header(CONTENT_TYPE, json_mime_type.to_string())
3183 .header(CONTENT_LENGTH, request_size as u64)
3184 .body(common::to_body(
3185 request_value_reader.get_ref().clone().into(),
3186 ));
3187
3188 client.request(request.unwrap()).await
3189 };
3190
3191 match req_result {
3192 Err(err) => {
3193 if let common::Retry::After(d) = dlg.http_error(&err) {
3194 sleep(d).await;
3195 continue;
3196 }
3197 dlg.finished(false);
3198 return Err(common::Error::HttpError(err));
3199 }
3200 Ok(res) => {
3201 let (mut parts, body) = res.into_parts();
3202 let mut body = common::Body::new(body);
3203 if !parts.status.is_success() {
3204 let bytes = common::to_bytes(body).await.unwrap_or_default();
3205 let error = serde_json::from_str(&common::to_string(&bytes));
3206 let response = common::to_response(parts, bytes.into());
3207
3208 if let common::Retry::After(d) =
3209 dlg.http_failure(&response, error.as_ref().ok())
3210 {
3211 sleep(d).await;
3212 continue;
3213 }
3214
3215 dlg.finished(false);
3216
3217 return Err(match error {
3218 Ok(value) => common::Error::BadRequest(value),
3219 _ => common::Error::Failure(response),
3220 });
3221 }
3222 let response = {
3223 let bytes = common::to_bytes(body).await.unwrap_or_default();
3224 let encoded = common::to_string(&bytes);
3225 match serde_json::from_str(&encoded) {
3226 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3227 Err(error) => {
3228 dlg.response_json_decode_error(&encoded, &error);
3229 return Err(common::Error::JsonDecodeError(
3230 encoded.to_string(),
3231 error,
3232 ));
3233 }
3234 }
3235 };
3236
3237 dlg.finished(true);
3238 return Ok(response);
3239 }
3240 }
3241 }
3242 }
3243
3244 ///
3245 /// Sets the *request* property to the given value.
3246 ///
3247 /// Even though the property as already been set when instantiating this call,
3248 /// we provide this method for API completeness.
3249 pub fn request(
3250 mut self,
3251 new_value: Service,
3252 ) -> ProjectLocationNamespaceServiceCreateCall<'a, C> {
3253 self._request = new_value;
3254 self
3255 }
3256 /// Required. The resource name of the namespace this service will belong to.
3257 ///
3258 /// Sets the *parent* path property to the given value.
3259 ///
3260 /// Even though the property as already been set when instantiating this call,
3261 /// we provide this method for API completeness.
3262 pub fn parent(mut self, new_value: &str) -> ProjectLocationNamespaceServiceCreateCall<'a, C> {
3263 self._parent = new_value.to_string();
3264 self
3265 }
3266 /// Required. The Resource ID must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
3267 ///
3268 /// Sets the *service id* query property to the given value.
3269 pub fn service_id(
3270 mut self,
3271 new_value: &str,
3272 ) -> ProjectLocationNamespaceServiceCreateCall<'a, C> {
3273 self._service_id = Some(new_value.to_string());
3274 self
3275 }
3276 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3277 /// while executing the actual API request.
3278 ///
3279 /// ````text
3280 /// It should be used to handle progress information, and to implement a certain level of resilience.
3281 /// ````
3282 ///
3283 /// Sets the *delegate* property to the given value.
3284 pub fn delegate(
3285 mut self,
3286 new_value: &'a mut dyn common::Delegate,
3287 ) -> ProjectLocationNamespaceServiceCreateCall<'a, C> {
3288 self._delegate = Some(new_value);
3289 self
3290 }
3291
3292 /// Set any additional parameter of the query string used in the request.
3293 /// It should be used to set parameters which are not yet available through their own
3294 /// setters.
3295 ///
3296 /// Please note that this method must not be used to set any of the known parameters
3297 /// which have their own setter method. If done anyway, the request will fail.
3298 ///
3299 /// # Additional Parameters
3300 ///
3301 /// * *$.xgafv* (query-string) - V1 error format.
3302 /// * *access_token* (query-string) - OAuth access token.
3303 /// * *alt* (query-string) - Data format for response.
3304 /// * *callback* (query-string) - JSONP
3305 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3306 /// * *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.
3307 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3308 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3309 /// * *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.
3310 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3311 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3312 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceServiceCreateCall<'a, C>
3313 where
3314 T: AsRef<str>,
3315 {
3316 self._additional_params
3317 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3318 self
3319 }
3320
3321 /// Identifies the authorization scope for the method you are building.
3322 ///
3323 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3324 /// [`Scope::CloudPlatform`].
3325 ///
3326 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3327 /// tokens for more than one scope.
3328 ///
3329 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3330 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3331 /// sufficient, a read-write scope will do as well.
3332 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceServiceCreateCall<'a, C>
3333 where
3334 St: AsRef<str>,
3335 {
3336 self._scopes.insert(String::from(scope.as_ref()));
3337 self
3338 }
3339 /// Identifies the authorization scope(s) for the method you are building.
3340 ///
3341 /// See [`Self::add_scope()`] for details.
3342 pub fn add_scopes<I, St>(
3343 mut self,
3344 scopes: I,
3345 ) -> ProjectLocationNamespaceServiceCreateCall<'a, C>
3346 where
3347 I: IntoIterator<Item = St>,
3348 St: AsRef<str>,
3349 {
3350 self._scopes
3351 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3352 self
3353 }
3354
3355 /// Removes all scopes, and no default scope will be used either.
3356 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3357 /// for details).
3358 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceCreateCall<'a, C> {
3359 self._scopes.clear();
3360 self
3361 }
3362}
3363
3364/// Deletes a service. This also deletes all endpoints associated with the service.
3365///
3366/// A builder for the *locations.namespaces.services.delete* method supported by a *project* resource.
3367/// It is not used directly, but through a [`ProjectMethods`] instance.
3368///
3369/// # Example
3370///
3371/// Instantiate a resource method builder
3372///
3373/// ```test_harness,no_run
3374/// # extern crate hyper;
3375/// # extern crate hyper_rustls;
3376/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
3377/// # async fn dox() {
3378/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3379///
3380/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3381/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3382/// # .with_native_roots()
3383/// # .unwrap()
3384/// # .https_only()
3385/// # .enable_http2()
3386/// # .build();
3387///
3388/// # let executor = hyper_util::rt::TokioExecutor::new();
3389/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3390/// # secret,
3391/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3392/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3393/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3394/// # ),
3395/// # ).build().await.unwrap();
3396///
3397/// # let client = hyper_util::client::legacy::Client::builder(
3398/// # hyper_util::rt::TokioExecutor::new()
3399/// # )
3400/// # .build(
3401/// # hyper_rustls::HttpsConnectorBuilder::new()
3402/// # .with_native_roots()
3403/// # .unwrap()
3404/// # .https_or_http()
3405/// # .enable_http2()
3406/// # .build()
3407/// # );
3408/// # let mut hub = ServiceDirectory::new(client, auth);
3409/// // You can configure optional parameters by calling the respective setters at will, and
3410/// // execute the final call using `doit()`.
3411/// // Values shown here are possibly random and not representative !
3412/// let result = hub.projects().locations_namespaces_services_delete("name")
3413/// .doit().await;
3414/// # }
3415/// ```
3416pub struct ProjectLocationNamespaceServiceDeleteCall<'a, C>
3417where
3418 C: 'a,
3419{
3420 hub: &'a ServiceDirectory<C>,
3421 _name: String,
3422 _delegate: Option<&'a mut dyn common::Delegate>,
3423 _additional_params: HashMap<String, String>,
3424 _scopes: BTreeSet<String>,
3425}
3426
3427impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceDeleteCall<'a, C> {}
3428
3429impl<'a, C> ProjectLocationNamespaceServiceDeleteCall<'a, C>
3430where
3431 C: common::Connector,
3432{
3433 /// Perform the operation you have build so far.
3434 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3435 use std::borrow::Cow;
3436 use std::io::{Read, Seek};
3437
3438 use common::{url::Params, ToParts};
3439 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3440
3441 let mut dd = common::DefaultDelegate;
3442 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3443 dlg.begin(common::MethodInfo {
3444 id: "servicedirectory.projects.locations.namespaces.services.delete",
3445 http_method: hyper::Method::DELETE,
3446 });
3447
3448 for &field in ["alt", "name"].iter() {
3449 if self._additional_params.contains_key(field) {
3450 dlg.finished(false);
3451 return Err(common::Error::FieldClash(field));
3452 }
3453 }
3454
3455 let mut params = Params::with_capacity(3 + self._additional_params.len());
3456 params.push("name", self._name);
3457
3458 params.extend(self._additional_params.iter());
3459
3460 params.push("alt", "json");
3461 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3462 if self._scopes.is_empty() {
3463 self._scopes
3464 .insert(Scope::CloudPlatform.as_ref().to_string());
3465 }
3466
3467 #[allow(clippy::single_element_loop)]
3468 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3469 url = params.uri_replacement(url, param_name, find_this, true);
3470 }
3471 {
3472 let to_remove = ["name"];
3473 params.remove_params(&to_remove);
3474 }
3475
3476 let url = params.parse_with_url(&url);
3477
3478 loop {
3479 let token = match self
3480 .hub
3481 .auth
3482 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3483 .await
3484 {
3485 Ok(token) => token,
3486 Err(e) => match dlg.token(e) {
3487 Ok(token) => token,
3488 Err(e) => {
3489 dlg.finished(false);
3490 return Err(common::Error::MissingToken(e));
3491 }
3492 },
3493 };
3494 let mut req_result = {
3495 let client = &self.hub.client;
3496 dlg.pre_request();
3497 let mut req_builder = hyper::Request::builder()
3498 .method(hyper::Method::DELETE)
3499 .uri(url.as_str())
3500 .header(USER_AGENT, self.hub._user_agent.clone());
3501
3502 if let Some(token) = token.as_ref() {
3503 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3504 }
3505
3506 let request = req_builder
3507 .header(CONTENT_LENGTH, 0_u64)
3508 .body(common::to_body::<String>(None));
3509
3510 client.request(request.unwrap()).await
3511 };
3512
3513 match req_result {
3514 Err(err) => {
3515 if let common::Retry::After(d) = dlg.http_error(&err) {
3516 sleep(d).await;
3517 continue;
3518 }
3519 dlg.finished(false);
3520 return Err(common::Error::HttpError(err));
3521 }
3522 Ok(res) => {
3523 let (mut parts, body) = res.into_parts();
3524 let mut body = common::Body::new(body);
3525 if !parts.status.is_success() {
3526 let bytes = common::to_bytes(body).await.unwrap_or_default();
3527 let error = serde_json::from_str(&common::to_string(&bytes));
3528 let response = common::to_response(parts, bytes.into());
3529
3530 if let common::Retry::After(d) =
3531 dlg.http_failure(&response, error.as_ref().ok())
3532 {
3533 sleep(d).await;
3534 continue;
3535 }
3536
3537 dlg.finished(false);
3538
3539 return Err(match error {
3540 Ok(value) => common::Error::BadRequest(value),
3541 _ => common::Error::Failure(response),
3542 });
3543 }
3544 let response = {
3545 let bytes = common::to_bytes(body).await.unwrap_or_default();
3546 let encoded = common::to_string(&bytes);
3547 match serde_json::from_str(&encoded) {
3548 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3549 Err(error) => {
3550 dlg.response_json_decode_error(&encoded, &error);
3551 return Err(common::Error::JsonDecodeError(
3552 encoded.to_string(),
3553 error,
3554 ));
3555 }
3556 }
3557 };
3558
3559 dlg.finished(true);
3560 return Ok(response);
3561 }
3562 }
3563 }
3564 }
3565
3566 /// Required. The name of the service to delete.
3567 ///
3568 /// Sets the *name* path property to the given value.
3569 ///
3570 /// Even though the property as already been set when instantiating this call,
3571 /// we provide this method for API completeness.
3572 pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> {
3573 self._name = new_value.to_string();
3574 self
3575 }
3576 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3577 /// while executing the actual API request.
3578 ///
3579 /// ````text
3580 /// It should be used to handle progress information, and to implement a certain level of resilience.
3581 /// ````
3582 ///
3583 /// Sets the *delegate* property to the given value.
3584 pub fn delegate(
3585 mut self,
3586 new_value: &'a mut dyn common::Delegate,
3587 ) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> {
3588 self._delegate = Some(new_value);
3589 self
3590 }
3591
3592 /// Set any additional parameter of the query string used in the request.
3593 /// It should be used to set parameters which are not yet available through their own
3594 /// setters.
3595 ///
3596 /// Please note that this method must not be used to set any of the known parameters
3597 /// which have their own setter method. If done anyway, the request will fail.
3598 ///
3599 /// # Additional Parameters
3600 ///
3601 /// * *$.xgafv* (query-string) - V1 error format.
3602 /// * *access_token* (query-string) - OAuth access token.
3603 /// * *alt* (query-string) - Data format for response.
3604 /// * *callback* (query-string) - JSONP
3605 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3606 /// * *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.
3607 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3608 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3609 /// * *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.
3610 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3611 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3612 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceServiceDeleteCall<'a, C>
3613 where
3614 T: AsRef<str>,
3615 {
3616 self._additional_params
3617 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3618 self
3619 }
3620
3621 /// Identifies the authorization scope for the method you are building.
3622 ///
3623 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3624 /// [`Scope::CloudPlatform`].
3625 ///
3626 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3627 /// tokens for more than one scope.
3628 ///
3629 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3630 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3631 /// sufficient, a read-write scope will do as well.
3632 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceServiceDeleteCall<'a, C>
3633 where
3634 St: AsRef<str>,
3635 {
3636 self._scopes.insert(String::from(scope.as_ref()));
3637 self
3638 }
3639 /// Identifies the authorization scope(s) for the method you are building.
3640 ///
3641 /// See [`Self::add_scope()`] for details.
3642 pub fn add_scopes<I, St>(
3643 mut self,
3644 scopes: I,
3645 ) -> ProjectLocationNamespaceServiceDeleteCall<'a, C>
3646 where
3647 I: IntoIterator<Item = St>,
3648 St: AsRef<str>,
3649 {
3650 self._scopes
3651 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3652 self
3653 }
3654
3655 /// Removes all scopes, and no default scope will be used either.
3656 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3657 /// for details).
3658 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> {
3659 self._scopes.clear();
3660 self
3661 }
3662}
3663
3664/// Gets a service.
3665///
3666/// A builder for the *locations.namespaces.services.get* method supported by a *project* resource.
3667/// It is not used directly, but through a [`ProjectMethods`] instance.
3668///
3669/// # Example
3670///
3671/// Instantiate a resource method builder
3672///
3673/// ```test_harness,no_run
3674/// # extern crate hyper;
3675/// # extern crate hyper_rustls;
3676/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
3677/// # async fn dox() {
3678/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3679///
3680/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3681/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3682/// # .with_native_roots()
3683/// # .unwrap()
3684/// # .https_only()
3685/// # .enable_http2()
3686/// # .build();
3687///
3688/// # let executor = hyper_util::rt::TokioExecutor::new();
3689/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3690/// # secret,
3691/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3692/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3693/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3694/// # ),
3695/// # ).build().await.unwrap();
3696///
3697/// # let client = hyper_util::client::legacy::Client::builder(
3698/// # hyper_util::rt::TokioExecutor::new()
3699/// # )
3700/// # .build(
3701/// # hyper_rustls::HttpsConnectorBuilder::new()
3702/// # .with_native_roots()
3703/// # .unwrap()
3704/// # .https_or_http()
3705/// # .enable_http2()
3706/// # .build()
3707/// # );
3708/// # let mut hub = ServiceDirectory::new(client, auth);
3709/// // You can configure optional parameters by calling the respective setters at will, and
3710/// // execute the final call using `doit()`.
3711/// // Values shown here are possibly random and not representative !
3712/// let result = hub.projects().locations_namespaces_services_get("name")
3713/// .doit().await;
3714/// # }
3715/// ```
3716pub struct ProjectLocationNamespaceServiceGetCall<'a, C>
3717where
3718 C: 'a,
3719{
3720 hub: &'a ServiceDirectory<C>,
3721 _name: String,
3722 _delegate: Option<&'a mut dyn common::Delegate>,
3723 _additional_params: HashMap<String, String>,
3724 _scopes: BTreeSet<String>,
3725}
3726
3727impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceGetCall<'a, C> {}
3728
3729impl<'a, C> ProjectLocationNamespaceServiceGetCall<'a, C>
3730where
3731 C: common::Connector,
3732{
3733 /// Perform the operation you have build so far.
3734 pub async fn doit(mut self) -> common::Result<(common::Response, Service)> {
3735 use std::borrow::Cow;
3736 use std::io::{Read, Seek};
3737
3738 use common::{url::Params, ToParts};
3739 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3740
3741 let mut dd = common::DefaultDelegate;
3742 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3743 dlg.begin(common::MethodInfo {
3744 id: "servicedirectory.projects.locations.namespaces.services.get",
3745 http_method: hyper::Method::GET,
3746 });
3747
3748 for &field in ["alt", "name"].iter() {
3749 if self._additional_params.contains_key(field) {
3750 dlg.finished(false);
3751 return Err(common::Error::FieldClash(field));
3752 }
3753 }
3754
3755 let mut params = Params::with_capacity(3 + self._additional_params.len());
3756 params.push("name", self._name);
3757
3758 params.extend(self._additional_params.iter());
3759
3760 params.push("alt", "json");
3761 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3762 if self._scopes.is_empty() {
3763 self._scopes
3764 .insert(Scope::CloudPlatform.as_ref().to_string());
3765 }
3766
3767 #[allow(clippy::single_element_loop)]
3768 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3769 url = params.uri_replacement(url, param_name, find_this, true);
3770 }
3771 {
3772 let to_remove = ["name"];
3773 params.remove_params(&to_remove);
3774 }
3775
3776 let url = params.parse_with_url(&url);
3777
3778 loop {
3779 let token = match self
3780 .hub
3781 .auth
3782 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3783 .await
3784 {
3785 Ok(token) => token,
3786 Err(e) => match dlg.token(e) {
3787 Ok(token) => token,
3788 Err(e) => {
3789 dlg.finished(false);
3790 return Err(common::Error::MissingToken(e));
3791 }
3792 },
3793 };
3794 let mut req_result = {
3795 let client = &self.hub.client;
3796 dlg.pre_request();
3797 let mut req_builder = hyper::Request::builder()
3798 .method(hyper::Method::GET)
3799 .uri(url.as_str())
3800 .header(USER_AGENT, self.hub._user_agent.clone());
3801
3802 if let Some(token) = token.as_ref() {
3803 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3804 }
3805
3806 let request = req_builder
3807 .header(CONTENT_LENGTH, 0_u64)
3808 .body(common::to_body::<String>(None));
3809
3810 client.request(request.unwrap()).await
3811 };
3812
3813 match req_result {
3814 Err(err) => {
3815 if let common::Retry::After(d) = dlg.http_error(&err) {
3816 sleep(d).await;
3817 continue;
3818 }
3819 dlg.finished(false);
3820 return Err(common::Error::HttpError(err));
3821 }
3822 Ok(res) => {
3823 let (mut parts, body) = res.into_parts();
3824 let mut body = common::Body::new(body);
3825 if !parts.status.is_success() {
3826 let bytes = common::to_bytes(body).await.unwrap_or_default();
3827 let error = serde_json::from_str(&common::to_string(&bytes));
3828 let response = common::to_response(parts, bytes.into());
3829
3830 if let common::Retry::After(d) =
3831 dlg.http_failure(&response, error.as_ref().ok())
3832 {
3833 sleep(d).await;
3834 continue;
3835 }
3836
3837 dlg.finished(false);
3838
3839 return Err(match error {
3840 Ok(value) => common::Error::BadRequest(value),
3841 _ => common::Error::Failure(response),
3842 });
3843 }
3844 let response = {
3845 let bytes = common::to_bytes(body).await.unwrap_or_default();
3846 let encoded = common::to_string(&bytes);
3847 match serde_json::from_str(&encoded) {
3848 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3849 Err(error) => {
3850 dlg.response_json_decode_error(&encoded, &error);
3851 return Err(common::Error::JsonDecodeError(
3852 encoded.to_string(),
3853 error,
3854 ));
3855 }
3856 }
3857 };
3858
3859 dlg.finished(true);
3860 return Ok(response);
3861 }
3862 }
3863 }
3864 }
3865
3866 /// Required. The name of the service to get.
3867 ///
3868 /// Sets the *name* path property to the given value.
3869 ///
3870 /// Even though the property as already been set when instantiating this call,
3871 /// we provide this method for API completeness.
3872 pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceServiceGetCall<'a, C> {
3873 self._name = new_value.to_string();
3874 self
3875 }
3876 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3877 /// while executing the actual API request.
3878 ///
3879 /// ````text
3880 /// It should be used to handle progress information, and to implement a certain level of resilience.
3881 /// ````
3882 ///
3883 /// Sets the *delegate* property to the given value.
3884 pub fn delegate(
3885 mut self,
3886 new_value: &'a mut dyn common::Delegate,
3887 ) -> ProjectLocationNamespaceServiceGetCall<'a, C> {
3888 self._delegate = Some(new_value);
3889 self
3890 }
3891
3892 /// Set any additional parameter of the query string used in the request.
3893 /// It should be used to set parameters which are not yet available through their own
3894 /// setters.
3895 ///
3896 /// Please note that this method must not be used to set any of the known parameters
3897 /// which have their own setter method. If done anyway, the request will fail.
3898 ///
3899 /// # Additional Parameters
3900 ///
3901 /// * *$.xgafv* (query-string) - V1 error format.
3902 /// * *access_token* (query-string) - OAuth access token.
3903 /// * *alt* (query-string) - Data format for response.
3904 /// * *callback* (query-string) - JSONP
3905 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3906 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3907 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3908 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3909 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3910 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3911 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3912 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceServiceGetCall<'a, C>
3913 where
3914 T: AsRef<str>,
3915 {
3916 self._additional_params
3917 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3918 self
3919 }
3920
3921 /// Identifies the authorization scope for the method you are building.
3922 ///
3923 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3924 /// [`Scope::CloudPlatform`].
3925 ///
3926 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3927 /// tokens for more than one scope.
3928 ///
3929 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3930 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3931 /// sufficient, a read-write scope will do as well.
3932 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceServiceGetCall<'a, C>
3933 where
3934 St: AsRef<str>,
3935 {
3936 self._scopes.insert(String::from(scope.as_ref()));
3937 self
3938 }
3939 /// Identifies the authorization scope(s) for the method you are building.
3940 ///
3941 /// See [`Self::add_scope()`] for details.
3942 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespaceServiceGetCall<'a, C>
3943 where
3944 I: IntoIterator<Item = St>,
3945 St: AsRef<str>,
3946 {
3947 self._scopes
3948 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3949 self
3950 }
3951
3952 /// Removes all scopes, and no default scope will be used either.
3953 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3954 /// for details).
3955 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceGetCall<'a, C> {
3956 self._scopes.clear();
3957 self
3958 }
3959}
3960
3961/// Gets the IAM Policy for a resource
3962///
3963/// A builder for the *locations.namespaces.services.getIamPolicy* method supported by a *project* resource.
3964/// It is not used directly, but through a [`ProjectMethods`] instance.
3965///
3966/// # Example
3967///
3968/// Instantiate a resource method builder
3969///
3970/// ```test_harness,no_run
3971/// # extern crate hyper;
3972/// # extern crate hyper_rustls;
3973/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
3974/// use servicedirectory1_beta1::api::GetIamPolicyRequest;
3975/// # async fn dox() {
3976/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3977///
3978/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3979/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3980/// # .with_native_roots()
3981/// # .unwrap()
3982/// # .https_only()
3983/// # .enable_http2()
3984/// # .build();
3985///
3986/// # let executor = hyper_util::rt::TokioExecutor::new();
3987/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3988/// # secret,
3989/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3990/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3991/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3992/// # ),
3993/// # ).build().await.unwrap();
3994///
3995/// # let client = hyper_util::client::legacy::Client::builder(
3996/// # hyper_util::rt::TokioExecutor::new()
3997/// # )
3998/// # .build(
3999/// # hyper_rustls::HttpsConnectorBuilder::new()
4000/// # .with_native_roots()
4001/// # .unwrap()
4002/// # .https_or_http()
4003/// # .enable_http2()
4004/// # .build()
4005/// # );
4006/// # let mut hub = ServiceDirectory::new(client, auth);
4007/// // As the method needs a request, you would usually fill it with the desired information
4008/// // into the respective structure. Some of the parts shown here might not be applicable !
4009/// // Values shown here are possibly random and not representative !
4010/// let mut req = GetIamPolicyRequest::default();
4011///
4012/// // You can configure optional parameters by calling the respective setters at will, and
4013/// // execute the final call using `doit()`.
4014/// // Values shown here are possibly random and not representative !
4015/// let result = hub.projects().locations_namespaces_services_get_iam_policy(req, "resource")
4016/// .doit().await;
4017/// # }
4018/// ```
4019pub struct ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C>
4020where
4021 C: 'a,
4022{
4023 hub: &'a ServiceDirectory<C>,
4024 _request: GetIamPolicyRequest,
4025 _resource: String,
4026 _delegate: Option<&'a mut dyn common::Delegate>,
4027 _additional_params: HashMap<String, String>,
4028 _scopes: BTreeSet<String>,
4029}
4030
4031impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> {}
4032
4033impl<'a, C> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C>
4034where
4035 C: common::Connector,
4036{
4037 /// Perform the operation you have build so far.
4038 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4039 use std::borrow::Cow;
4040 use std::io::{Read, Seek};
4041
4042 use common::{url::Params, ToParts};
4043 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4044
4045 let mut dd = common::DefaultDelegate;
4046 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4047 dlg.begin(common::MethodInfo {
4048 id: "servicedirectory.projects.locations.namespaces.services.getIamPolicy",
4049 http_method: hyper::Method::POST,
4050 });
4051
4052 for &field in ["alt", "resource"].iter() {
4053 if self._additional_params.contains_key(field) {
4054 dlg.finished(false);
4055 return Err(common::Error::FieldClash(field));
4056 }
4057 }
4058
4059 let mut params = Params::with_capacity(4 + self._additional_params.len());
4060 params.push("resource", self._resource);
4061
4062 params.extend(self._additional_params.iter());
4063
4064 params.push("alt", "json");
4065 let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:getIamPolicy";
4066 if self._scopes.is_empty() {
4067 self._scopes
4068 .insert(Scope::CloudPlatform.as_ref().to_string());
4069 }
4070
4071 #[allow(clippy::single_element_loop)]
4072 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4073 url = params.uri_replacement(url, param_name, find_this, true);
4074 }
4075 {
4076 let to_remove = ["resource"];
4077 params.remove_params(&to_remove);
4078 }
4079
4080 let url = params.parse_with_url(&url);
4081
4082 let mut json_mime_type = mime::APPLICATION_JSON;
4083 let mut request_value_reader = {
4084 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4085 common::remove_json_null_values(&mut value);
4086 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4087 serde_json::to_writer(&mut dst, &value).unwrap();
4088 dst
4089 };
4090 let request_size = request_value_reader
4091 .seek(std::io::SeekFrom::End(0))
4092 .unwrap();
4093 request_value_reader
4094 .seek(std::io::SeekFrom::Start(0))
4095 .unwrap();
4096
4097 loop {
4098 let token = match self
4099 .hub
4100 .auth
4101 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4102 .await
4103 {
4104 Ok(token) => token,
4105 Err(e) => match dlg.token(e) {
4106 Ok(token) => token,
4107 Err(e) => {
4108 dlg.finished(false);
4109 return Err(common::Error::MissingToken(e));
4110 }
4111 },
4112 };
4113 request_value_reader
4114 .seek(std::io::SeekFrom::Start(0))
4115 .unwrap();
4116 let mut req_result = {
4117 let client = &self.hub.client;
4118 dlg.pre_request();
4119 let mut req_builder = hyper::Request::builder()
4120 .method(hyper::Method::POST)
4121 .uri(url.as_str())
4122 .header(USER_AGENT, self.hub._user_agent.clone());
4123
4124 if let Some(token) = token.as_ref() {
4125 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4126 }
4127
4128 let request = req_builder
4129 .header(CONTENT_TYPE, json_mime_type.to_string())
4130 .header(CONTENT_LENGTH, request_size as u64)
4131 .body(common::to_body(
4132 request_value_reader.get_ref().clone().into(),
4133 ));
4134
4135 client.request(request.unwrap()).await
4136 };
4137
4138 match req_result {
4139 Err(err) => {
4140 if let common::Retry::After(d) = dlg.http_error(&err) {
4141 sleep(d).await;
4142 continue;
4143 }
4144 dlg.finished(false);
4145 return Err(common::Error::HttpError(err));
4146 }
4147 Ok(res) => {
4148 let (mut parts, body) = res.into_parts();
4149 let mut body = common::Body::new(body);
4150 if !parts.status.is_success() {
4151 let bytes = common::to_bytes(body).await.unwrap_or_default();
4152 let error = serde_json::from_str(&common::to_string(&bytes));
4153 let response = common::to_response(parts, bytes.into());
4154
4155 if let common::Retry::After(d) =
4156 dlg.http_failure(&response, error.as_ref().ok())
4157 {
4158 sleep(d).await;
4159 continue;
4160 }
4161
4162 dlg.finished(false);
4163
4164 return Err(match error {
4165 Ok(value) => common::Error::BadRequest(value),
4166 _ => common::Error::Failure(response),
4167 });
4168 }
4169 let response = {
4170 let bytes = common::to_bytes(body).await.unwrap_or_default();
4171 let encoded = common::to_string(&bytes);
4172 match serde_json::from_str(&encoded) {
4173 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4174 Err(error) => {
4175 dlg.response_json_decode_error(&encoded, &error);
4176 return Err(common::Error::JsonDecodeError(
4177 encoded.to_string(),
4178 error,
4179 ));
4180 }
4181 }
4182 };
4183
4184 dlg.finished(true);
4185 return Ok(response);
4186 }
4187 }
4188 }
4189 }
4190
4191 ///
4192 /// Sets the *request* property to the given value.
4193 ///
4194 /// Even though the property as already been set when instantiating this call,
4195 /// we provide this method for API completeness.
4196 pub fn request(
4197 mut self,
4198 new_value: GetIamPolicyRequest,
4199 ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> {
4200 self._request = new_value;
4201 self
4202 }
4203 /// 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.
4204 ///
4205 /// Sets the *resource* path property to the given value.
4206 ///
4207 /// Even though the property as already been set when instantiating this call,
4208 /// we provide this method for API completeness.
4209 pub fn resource(
4210 mut self,
4211 new_value: &str,
4212 ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> {
4213 self._resource = new_value.to_string();
4214 self
4215 }
4216 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4217 /// while executing the actual API request.
4218 ///
4219 /// ````text
4220 /// It should be used to handle progress information, and to implement a certain level of resilience.
4221 /// ````
4222 ///
4223 /// Sets the *delegate* property to the given value.
4224 pub fn delegate(
4225 mut self,
4226 new_value: &'a mut dyn common::Delegate,
4227 ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> {
4228 self._delegate = Some(new_value);
4229 self
4230 }
4231
4232 /// Set any additional parameter of the query string used in the request.
4233 /// It should be used to set parameters which are not yet available through their own
4234 /// setters.
4235 ///
4236 /// Please note that this method must not be used to set any of the known parameters
4237 /// which have their own setter method. If done anyway, the request will fail.
4238 ///
4239 /// # Additional Parameters
4240 ///
4241 /// * *$.xgafv* (query-string) - V1 error format.
4242 /// * *access_token* (query-string) - OAuth access token.
4243 /// * *alt* (query-string) - Data format for response.
4244 /// * *callback* (query-string) - JSONP
4245 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4246 /// * *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.
4247 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4248 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4249 /// * *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.
4250 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4251 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4252 pub fn param<T>(
4253 mut self,
4254 name: T,
4255 value: T,
4256 ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C>
4257 where
4258 T: AsRef<str>,
4259 {
4260 self._additional_params
4261 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4262 self
4263 }
4264
4265 /// Identifies the authorization scope for the method you are building.
4266 ///
4267 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4268 /// [`Scope::CloudPlatform`].
4269 ///
4270 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4271 /// tokens for more than one scope.
4272 ///
4273 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4274 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4275 /// sufficient, a read-write scope will do as well.
4276 pub fn add_scope<St>(
4277 mut self,
4278 scope: St,
4279 ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C>
4280 where
4281 St: AsRef<str>,
4282 {
4283 self._scopes.insert(String::from(scope.as_ref()));
4284 self
4285 }
4286 /// Identifies the authorization scope(s) for the method you are building.
4287 ///
4288 /// See [`Self::add_scope()`] for details.
4289 pub fn add_scopes<I, St>(
4290 mut self,
4291 scopes: I,
4292 ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C>
4293 where
4294 I: IntoIterator<Item = St>,
4295 St: AsRef<str>,
4296 {
4297 self._scopes
4298 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4299 self
4300 }
4301
4302 /// Removes all scopes, and no default scope will be used either.
4303 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4304 /// for details).
4305 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> {
4306 self._scopes.clear();
4307 self
4308 }
4309}
4310
4311/// Lists all services belonging to a namespace.
4312///
4313/// A builder for the *locations.namespaces.services.list* method supported by a *project* resource.
4314/// It is not used directly, but through a [`ProjectMethods`] instance.
4315///
4316/// # Example
4317///
4318/// Instantiate a resource method builder
4319///
4320/// ```test_harness,no_run
4321/// # extern crate hyper;
4322/// # extern crate hyper_rustls;
4323/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
4324/// # async fn dox() {
4325/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4326///
4327/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4328/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4329/// # .with_native_roots()
4330/// # .unwrap()
4331/// # .https_only()
4332/// # .enable_http2()
4333/// # .build();
4334///
4335/// # let executor = hyper_util::rt::TokioExecutor::new();
4336/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4337/// # secret,
4338/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4339/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4340/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4341/// # ),
4342/// # ).build().await.unwrap();
4343///
4344/// # let client = hyper_util::client::legacy::Client::builder(
4345/// # hyper_util::rt::TokioExecutor::new()
4346/// # )
4347/// # .build(
4348/// # hyper_rustls::HttpsConnectorBuilder::new()
4349/// # .with_native_roots()
4350/// # .unwrap()
4351/// # .https_or_http()
4352/// # .enable_http2()
4353/// # .build()
4354/// # );
4355/// # let mut hub = ServiceDirectory::new(client, auth);
4356/// // You can configure optional parameters by calling the respective setters at will, and
4357/// // execute the final call using `doit()`.
4358/// // Values shown here are possibly random and not representative !
4359/// let result = hub.projects().locations_namespaces_services_list("parent")
4360/// .page_token("ipsum")
4361/// .page_size(-88)
4362/// .order_by("amet")
4363/// .filter("duo")
4364/// .doit().await;
4365/// # }
4366/// ```
4367pub struct ProjectLocationNamespaceServiceListCall<'a, C>
4368where
4369 C: 'a,
4370{
4371 hub: &'a ServiceDirectory<C>,
4372 _parent: String,
4373 _page_token: Option<String>,
4374 _page_size: Option<i32>,
4375 _order_by: Option<String>,
4376 _filter: Option<String>,
4377 _delegate: Option<&'a mut dyn common::Delegate>,
4378 _additional_params: HashMap<String, String>,
4379 _scopes: BTreeSet<String>,
4380}
4381
4382impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceListCall<'a, C> {}
4383
4384impl<'a, C> ProjectLocationNamespaceServiceListCall<'a, C>
4385where
4386 C: common::Connector,
4387{
4388 /// Perform the operation you have build so far.
4389 pub async fn doit(mut self) -> common::Result<(common::Response, ListServicesResponse)> {
4390 use std::borrow::Cow;
4391 use std::io::{Read, Seek};
4392
4393 use common::{url::Params, ToParts};
4394 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4395
4396 let mut dd = common::DefaultDelegate;
4397 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4398 dlg.begin(common::MethodInfo {
4399 id: "servicedirectory.projects.locations.namespaces.services.list",
4400 http_method: hyper::Method::GET,
4401 });
4402
4403 for &field in [
4404 "alt",
4405 "parent",
4406 "pageToken",
4407 "pageSize",
4408 "orderBy",
4409 "filter",
4410 ]
4411 .iter()
4412 {
4413 if self._additional_params.contains_key(field) {
4414 dlg.finished(false);
4415 return Err(common::Error::FieldClash(field));
4416 }
4417 }
4418
4419 let mut params = Params::with_capacity(7 + self._additional_params.len());
4420 params.push("parent", self._parent);
4421 if let Some(value) = self._page_token.as_ref() {
4422 params.push("pageToken", value);
4423 }
4424 if let Some(value) = self._page_size.as_ref() {
4425 params.push("pageSize", value.to_string());
4426 }
4427 if let Some(value) = self._order_by.as_ref() {
4428 params.push("orderBy", value);
4429 }
4430 if let Some(value) = self._filter.as_ref() {
4431 params.push("filter", value);
4432 }
4433
4434 params.extend(self._additional_params.iter());
4435
4436 params.push("alt", "json");
4437 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/services";
4438 if self._scopes.is_empty() {
4439 self._scopes
4440 .insert(Scope::CloudPlatform.as_ref().to_string());
4441 }
4442
4443 #[allow(clippy::single_element_loop)]
4444 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4445 url = params.uri_replacement(url, param_name, find_this, true);
4446 }
4447 {
4448 let to_remove = ["parent"];
4449 params.remove_params(&to_remove);
4450 }
4451
4452 let url = params.parse_with_url(&url);
4453
4454 loop {
4455 let token = match self
4456 .hub
4457 .auth
4458 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4459 .await
4460 {
4461 Ok(token) => token,
4462 Err(e) => match dlg.token(e) {
4463 Ok(token) => token,
4464 Err(e) => {
4465 dlg.finished(false);
4466 return Err(common::Error::MissingToken(e));
4467 }
4468 },
4469 };
4470 let mut req_result = {
4471 let client = &self.hub.client;
4472 dlg.pre_request();
4473 let mut req_builder = hyper::Request::builder()
4474 .method(hyper::Method::GET)
4475 .uri(url.as_str())
4476 .header(USER_AGENT, self.hub._user_agent.clone());
4477
4478 if let Some(token) = token.as_ref() {
4479 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4480 }
4481
4482 let request = req_builder
4483 .header(CONTENT_LENGTH, 0_u64)
4484 .body(common::to_body::<String>(None));
4485
4486 client.request(request.unwrap()).await
4487 };
4488
4489 match req_result {
4490 Err(err) => {
4491 if let common::Retry::After(d) = dlg.http_error(&err) {
4492 sleep(d).await;
4493 continue;
4494 }
4495 dlg.finished(false);
4496 return Err(common::Error::HttpError(err));
4497 }
4498 Ok(res) => {
4499 let (mut parts, body) = res.into_parts();
4500 let mut body = common::Body::new(body);
4501 if !parts.status.is_success() {
4502 let bytes = common::to_bytes(body).await.unwrap_or_default();
4503 let error = serde_json::from_str(&common::to_string(&bytes));
4504 let response = common::to_response(parts, bytes.into());
4505
4506 if let common::Retry::After(d) =
4507 dlg.http_failure(&response, error.as_ref().ok())
4508 {
4509 sleep(d).await;
4510 continue;
4511 }
4512
4513 dlg.finished(false);
4514
4515 return Err(match error {
4516 Ok(value) => common::Error::BadRequest(value),
4517 _ => common::Error::Failure(response),
4518 });
4519 }
4520 let response = {
4521 let bytes = common::to_bytes(body).await.unwrap_or_default();
4522 let encoded = common::to_string(&bytes);
4523 match serde_json::from_str(&encoded) {
4524 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4525 Err(error) => {
4526 dlg.response_json_decode_error(&encoded, &error);
4527 return Err(common::Error::JsonDecodeError(
4528 encoded.to_string(),
4529 error,
4530 ));
4531 }
4532 }
4533 };
4534
4535 dlg.finished(true);
4536 return Ok(response);
4537 }
4538 }
4539 }
4540 }
4541
4542 /// Required. The resource name of the namespace whose services you'd like to list.
4543 ///
4544 /// Sets the *parent* path property to the given value.
4545 ///
4546 /// Even though the property as already been set when instantiating this call,
4547 /// we provide this method for API completeness.
4548 pub fn parent(mut self, new_value: &str) -> ProjectLocationNamespaceServiceListCall<'a, C> {
4549 self._parent = new_value.to_string();
4550 self
4551 }
4552 /// Optional. The next_page_token value returned from a previous List request, if any.
4553 ///
4554 /// Sets the *page token* query property to the given value.
4555 pub fn page_token(mut self, new_value: &str) -> ProjectLocationNamespaceServiceListCall<'a, C> {
4556 self._page_token = Some(new_value.to_string());
4557 self
4558 }
4559 /// Optional. The maximum number of items to return. The default value is 100.
4560 ///
4561 /// Sets the *page size* query property to the given value.
4562 pub fn page_size(mut self, new_value: i32) -> ProjectLocationNamespaceServiceListCall<'a, C> {
4563 self._page_size = Some(new_value);
4564 self
4565 }
4566 /// Optional. The order to list results by. General `order_by` string syntax: ` () (,)` * `` allows value: `name` * `` ascending or descending order by ``. If this is left blank, `asc` is used Note that an empty `order_by` string results in default order, which is order by `name` in ascending order.
4567 ///
4568 /// Sets the *order by* query property to the given value.
4569 pub fn order_by(mut self, new_value: &str) -> ProjectLocationNamespaceServiceListCall<'a, C> {
4570 self._order_by = Some(new_value.to_string());
4571 self
4572 }
4573 /// Optional. The filter to list results by. General `filter` string syntax: ` ()` * `` can be `name` or `metadata.` for map field * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` means `HAS`, and is roughly the same as `=` * `` must be the same data type as field * `` can be `AND`, `OR`, `NOT` Examples of valid filters: * `metadata.owner` returns services that have a metadata with the key `owner`, this is the same as `metadata:owner` * `metadata.protocol=gRPC` returns services that have key/value `protocol=gRPC` * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` returns services that have name that is alphabetically later than the string, so "service-e" is returned but "service-a" is not * `metadata.owner!=sd AND metadata.foo=bar` returns services that have `owner` in metadata key but value is not `sd` AND have key/value `foo=bar` * `doesnotexist.foo=bar` returns an empty list. Note that service doesn't have a field called "doesnotexist". Since the filter does not match any services, it returns no results * `attributes.managed_registration=true` returns services that are managed by a GCP product or service For more information about filtering, see [API Filtering](https://aip.dev/160).
4574 ///
4575 /// Sets the *filter* query property to the given value.
4576 pub fn filter(mut self, new_value: &str) -> ProjectLocationNamespaceServiceListCall<'a, C> {
4577 self._filter = Some(new_value.to_string());
4578 self
4579 }
4580 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4581 /// while executing the actual API request.
4582 ///
4583 /// ````text
4584 /// It should be used to handle progress information, and to implement a certain level of resilience.
4585 /// ````
4586 ///
4587 /// Sets the *delegate* property to the given value.
4588 pub fn delegate(
4589 mut self,
4590 new_value: &'a mut dyn common::Delegate,
4591 ) -> ProjectLocationNamespaceServiceListCall<'a, C> {
4592 self._delegate = Some(new_value);
4593 self
4594 }
4595
4596 /// Set any additional parameter of the query string used in the request.
4597 /// It should be used to set parameters which are not yet available through their own
4598 /// setters.
4599 ///
4600 /// Please note that this method must not be used to set any of the known parameters
4601 /// which have their own setter method. If done anyway, the request will fail.
4602 ///
4603 /// # Additional Parameters
4604 ///
4605 /// * *$.xgafv* (query-string) - V1 error format.
4606 /// * *access_token* (query-string) - OAuth access token.
4607 /// * *alt* (query-string) - Data format for response.
4608 /// * *callback* (query-string) - JSONP
4609 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4610 /// * *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.
4611 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4612 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4613 /// * *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.
4614 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4615 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4616 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceServiceListCall<'a, C>
4617 where
4618 T: AsRef<str>,
4619 {
4620 self._additional_params
4621 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4622 self
4623 }
4624
4625 /// Identifies the authorization scope for the method you are building.
4626 ///
4627 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4628 /// [`Scope::CloudPlatform`].
4629 ///
4630 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4631 /// tokens for more than one scope.
4632 ///
4633 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4634 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4635 /// sufficient, a read-write scope will do as well.
4636 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceServiceListCall<'a, C>
4637 where
4638 St: AsRef<str>,
4639 {
4640 self._scopes.insert(String::from(scope.as_ref()));
4641 self
4642 }
4643 /// Identifies the authorization scope(s) for the method you are building.
4644 ///
4645 /// See [`Self::add_scope()`] for details.
4646 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespaceServiceListCall<'a, C>
4647 where
4648 I: IntoIterator<Item = St>,
4649 St: AsRef<str>,
4650 {
4651 self._scopes
4652 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4653 self
4654 }
4655
4656 /// Removes all scopes, and no default scope will be used either.
4657 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4658 /// for details).
4659 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceListCall<'a, C> {
4660 self._scopes.clear();
4661 self
4662 }
4663}
4664
4665/// Updates a service.
4666///
4667/// A builder for the *locations.namespaces.services.patch* method supported by a *project* resource.
4668/// It is not used directly, but through a [`ProjectMethods`] instance.
4669///
4670/// # Example
4671///
4672/// Instantiate a resource method builder
4673///
4674/// ```test_harness,no_run
4675/// # extern crate hyper;
4676/// # extern crate hyper_rustls;
4677/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
4678/// use servicedirectory1_beta1::api::Service;
4679/// # async fn dox() {
4680/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4681///
4682/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4683/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4684/// # .with_native_roots()
4685/// # .unwrap()
4686/// # .https_only()
4687/// # .enable_http2()
4688/// # .build();
4689///
4690/// # let executor = hyper_util::rt::TokioExecutor::new();
4691/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4692/// # secret,
4693/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4694/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4695/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4696/// # ),
4697/// # ).build().await.unwrap();
4698///
4699/// # let client = hyper_util::client::legacy::Client::builder(
4700/// # hyper_util::rt::TokioExecutor::new()
4701/// # )
4702/// # .build(
4703/// # hyper_rustls::HttpsConnectorBuilder::new()
4704/// # .with_native_roots()
4705/// # .unwrap()
4706/// # .https_or_http()
4707/// # .enable_http2()
4708/// # .build()
4709/// # );
4710/// # let mut hub = ServiceDirectory::new(client, auth);
4711/// // As the method needs a request, you would usually fill it with the desired information
4712/// // into the respective structure. Some of the parts shown here might not be applicable !
4713/// // Values shown here are possibly random and not representative !
4714/// let mut req = Service::default();
4715///
4716/// // You can configure optional parameters by calling the respective setters at will, and
4717/// // execute the final call using `doit()`.
4718/// // Values shown here are possibly random and not representative !
4719/// let result = hub.projects().locations_namespaces_services_patch(req, "name")
4720/// .update_mask(FieldMask::new::<&str>(&[]))
4721/// .doit().await;
4722/// # }
4723/// ```
4724pub struct ProjectLocationNamespaceServicePatchCall<'a, C>
4725where
4726 C: 'a,
4727{
4728 hub: &'a ServiceDirectory<C>,
4729 _request: Service,
4730 _name: String,
4731 _update_mask: Option<common::FieldMask>,
4732 _delegate: Option<&'a mut dyn common::Delegate>,
4733 _additional_params: HashMap<String, String>,
4734 _scopes: BTreeSet<String>,
4735}
4736
4737impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServicePatchCall<'a, C> {}
4738
4739impl<'a, C> ProjectLocationNamespaceServicePatchCall<'a, C>
4740where
4741 C: common::Connector,
4742{
4743 /// Perform the operation you have build so far.
4744 pub async fn doit(mut self) -> common::Result<(common::Response, Service)> {
4745 use std::borrow::Cow;
4746 use std::io::{Read, Seek};
4747
4748 use common::{url::Params, ToParts};
4749 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4750
4751 let mut dd = common::DefaultDelegate;
4752 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4753 dlg.begin(common::MethodInfo {
4754 id: "servicedirectory.projects.locations.namespaces.services.patch",
4755 http_method: hyper::Method::PATCH,
4756 });
4757
4758 for &field in ["alt", "name", "updateMask"].iter() {
4759 if self._additional_params.contains_key(field) {
4760 dlg.finished(false);
4761 return Err(common::Error::FieldClash(field));
4762 }
4763 }
4764
4765 let mut params = Params::with_capacity(5 + self._additional_params.len());
4766 params.push("name", self._name);
4767 if let Some(value) = self._update_mask.as_ref() {
4768 params.push("updateMask", value.to_string());
4769 }
4770
4771 params.extend(self._additional_params.iter());
4772
4773 params.push("alt", "json");
4774 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
4775 if self._scopes.is_empty() {
4776 self._scopes
4777 .insert(Scope::CloudPlatform.as_ref().to_string());
4778 }
4779
4780 #[allow(clippy::single_element_loop)]
4781 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4782 url = params.uri_replacement(url, param_name, find_this, true);
4783 }
4784 {
4785 let to_remove = ["name"];
4786 params.remove_params(&to_remove);
4787 }
4788
4789 let url = params.parse_with_url(&url);
4790
4791 let mut json_mime_type = mime::APPLICATION_JSON;
4792 let mut request_value_reader = {
4793 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4794 common::remove_json_null_values(&mut value);
4795 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4796 serde_json::to_writer(&mut dst, &value).unwrap();
4797 dst
4798 };
4799 let request_size = request_value_reader
4800 .seek(std::io::SeekFrom::End(0))
4801 .unwrap();
4802 request_value_reader
4803 .seek(std::io::SeekFrom::Start(0))
4804 .unwrap();
4805
4806 loop {
4807 let token = match self
4808 .hub
4809 .auth
4810 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4811 .await
4812 {
4813 Ok(token) => token,
4814 Err(e) => match dlg.token(e) {
4815 Ok(token) => token,
4816 Err(e) => {
4817 dlg.finished(false);
4818 return Err(common::Error::MissingToken(e));
4819 }
4820 },
4821 };
4822 request_value_reader
4823 .seek(std::io::SeekFrom::Start(0))
4824 .unwrap();
4825 let mut req_result = {
4826 let client = &self.hub.client;
4827 dlg.pre_request();
4828 let mut req_builder = hyper::Request::builder()
4829 .method(hyper::Method::PATCH)
4830 .uri(url.as_str())
4831 .header(USER_AGENT, self.hub._user_agent.clone());
4832
4833 if let Some(token) = token.as_ref() {
4834 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4835 }
4836
4837 let request = req_builder
4838 .header(CONTENT_TYPE, json_mime_type.to_string())
4839 .header(CONTENT_LENGTH, request_size as u64)
4840 .body(common::to_body(
4841 request_value_reader.get_ref().clone().into(),
4842 ));
4843
4844 client.request(request.unwrap()).await
4845 };
4846
4847 match req_result {
4848 Err(err) => {
4849 if let common::Retry::After(d) = dlg.http_error(&err) {
4850 sleep(d).await;
4851 continue;
4852 }
4853 dlg.finished(false);
4854 return Err(common::Error::HttpError(err));
4855 }
4856 Ok(res) => {
4857 let (mut parts, body) = res.into_parts();
4858 let mut body = common::Body::new(body);
4859 if !parts.status.is_success() {
4860 let bytes = common::to_bytes(body).await.unwrap_or_default();
4861 let error = serde_json::from_str(&common::to_string(&bytes));
4862 let response = common::to_response(parts, bytes.into());
4863
4864 if let common::Retry::After(d) =
4865 dlg.http_failure(&response, error.as_ref().ok())
4866 {
4867 sleep(d).await;
4868 continue;
4869 }
4870
4871 dlg.finished(false);
4872
4873 return Err(match error {
4874 Ok(value) => common::Error::BadRequest(value),
4875 _ => common::Error::Failure(response),
4876 });
4877 }
4878 let response = {
4879 let bytes = common::to_bytes(body).await.unwrap_or_default();
4880 let encoded = common::to_string(&bytes);
4881 match serde_json::from_str(&encoded) {
4882 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4883 Err(error) => {
4884 dlg.response_json_decode_error(&encoded, &error);
4885 return Err(common::Error::JsonDecodeError(
4886 encoded.to_string(),
4887 error,
4888 ));
4889 }
4890 }
4891 };
4892
4893 dlg.finished(true);
4894 return Ok(response);
4895 }
4896 }
4897 }
4898 }
4899
4900 ///
4901 /// Sets the *request* property to the given value.
4902 ///
4903 /// Even though the property as already been set when instantiating this call,
4904 /// we provide this method for API completeness.
4905 pub fn request(
4906 mut self,
4907 new_value: Service,
4908 ) -> ProjectLocationNamespaceServicePatchCall<'a, C> {
4909 self._request = new_value;
4910 self
4911 }
4912 /// Immutable. The resource name for the service in the format `projects/*/locations/*/namespaces/*/services/*`.
4913 ///
4914 /// Sets the *name* path property to the given value.
4915 ///
4916 /// Even though the property as already been set when instantiating this call,
4917 /// we provide this method for API completeness.
4918 pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceServicePatchCall<'a, C> {
4919 self._name = new_value.to_string();
4920 self
4921 }
4922 /// Required. List of fields to be updated in this request.
4923 ///
4924 /// Sets the *update mask* query property to the given value.
4925 pub fn update_mask(
4926 mut self,
4927 new_value: common::FieldMask,
4928 ) -> ProjectLocationNamespaceServicePatchCall<'a, C> {
4929 self._update_mask = Some(new_value);
4930 self
4931 }
4932 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4933 /// while executing the actual API request.
4934 ///
4935 /// ````text
4936 /// It should be used to handle progress information, and to implement a certain level of resilience.
4937 /// ````
4938 ///
4939 /// Sets the *delegate* property to the given value.
4940 pub fn delegate(
4941 mut self,
4942 new_value: &'a mut dyn common::Delegate,
4943 ) -> ProjectLocationNamespaceServicePatchCall<'a, C> {
4944 self._delegate = Some(new_value);
4945 self
4946 }
4947
4948 /// Set any additional parameter of the query string used in the request.
4949 /// It should be used to set parameters which are not yet available through their own
4950 /// setters.
4951 ///
4952 /// Please note that this method must not be used to set any of the known parameters
4953 /// which have their own setter method. If done anyway, the request will fail.
4954 ///
4955 /// # Additional Parameters
4956 ///
4957 /// * *$.xgafv* (query-string) - V1 error format.
4958 /// * *access_token* (query-string) - OAuth access token.
4959 /// * *alt* (query-string) - Data format for response.
4960 /// * *callback* (query-string) - JSONP
4961 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4962 /// * *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.
4963 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4964 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4965 /// * *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.
4966 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4967 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4968 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceServicePatchCall<'a, C>
4969 where
4970 T: AsRef<str>,
4971 {
4972 self._additional_params
4973 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4974 self
4975 }
4976
4977 /// Identifies the authorization scope for the method you are building.
4978 ///
4979 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4980 /// [`Scope::CloudPlatform`].
4981 ///
4982 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4983 /// tokens for more than one scope.
4984 ///
4985 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4986 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4987 /// sufficient, a read-write scope will do as well.
4988 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceServicePatchCall<'a, C>
4989 where
4990 St: AsRef<str>,
4991 {
4992 self._scopes.insert(String::from(scope.as_ref()));
4993 self
4994 }
4995 /// Identifies the authorization scope(s) for the method you are building.
4996 ///
4997 /// See [`Self::add_scope()`] for details.
4998 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespaceServicePatchCall<'a, C>
4999 where
5000 I: IntoIterator<Item = St>,
5001 St: AsRef<str>,
5002 {
5003 self._scopes
5004 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5005 self
5006 }
5007
5008 /// Removes all scopes, and no default scope will be used either.
5009 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5010 /// for details).
5011 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServicePatchCall<'a, C> {
5012 self._scopes.clear();
5013 self
5014 }
5015}
5016
5017/// Returns a service and its associated endpoints. Resolving a service is not considered an active developer method.
5018///
5019/// A builder for the *locations.namespaces.services.resolve* method supported by a *project* resource.
5020/// It is not used directly, but through a [`ProjectMethods`] instance.
5021///
5022/// # Example
5023///
5024/// Instantiate a resource method builder
5025///
5026/// ```test_harness,no_run
5027/// # extern crate hyper;
5028/// # extern crate hyper_rustls;
5029/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
5030/// use servicedirectory1_beta1::api::ResolveServiceRequest;
5031/// # async fn dox() {
5032/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5033///
5034/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5035/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5036/// # .with_native_roots()
5037/// # .unwrap()
5038/// # .https_only()
5039/// # .enable_http2()
5040/// # .build();
5041///
5042/// # let executor = hyper_util::rt::TokioExecutor::new();
5043/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5044/// # secret,
5045/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5046/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5047/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5048/// # ),
5049/// # ).build().await.unwrap();
5050///
5051/// # let client = hyper_util::client::legacy::Client::builder(
5052/// # hyper_util::rt::TokioExecutor::new()
5053/// # )
5054/// # .build(
5055/// # hyper_rustls::HttpsConnectorBuilder::new()
5056/// # .with_native_roots()
5057/// # .unwrap()
5058/// # .https_or_http()
5059/// # .enable_http2()
5060/// # .build()
5061/// # );
5062/// # let mut hub = ServiceDirectory::new(client, auth);
5063/// // As the method needs a request, you would usually fill it with the desired information
5064/// // into the respective structure. Some of the parts shown here might not be applicable !
5065/// // Values shown here are possibly random and not representative !
5066/// let mut req = ResolveServiceRequest::default();
5067///
5068/// // You can configure optional parameters by calling the respective setters at will, and
5069/// // execute the final call using `doit()`.
5070/// // Values shown here are possibly random and not representative !
5071/// let result = hub.projects().locations_namespaces_services_resolve(req, "name")
5072/// .doit().await;
5073/// # }
5074/// ```
5075pub struct ProjectLocationNamespaceServiceResolveCall<'a, C>
5076where
5077 C: 'a,
5078{
5079 hub: &'a ServiceDirectory<C>,
5080 _request: ResolveServiceRequest,
5081 _name: String,
5082 _delegate: Option<&'a mut dyn common::Delegate>,
5083 _additional_params: HashMap<String, String>,
5084 _scopes: BTreeSet<String>,
5085}
5086
5087impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceResolveCall<'a, C> {}
5088
5089impl<'a, C> ProjectLocationNamespaceServiceResolveCall<'a, C>
5090where
5091 C: common::Connector,
5092{
5093 /// Perform the operation you have build so far.
5094 pub async fn doit(mut self) -> common::Result<(common::Response, ResolveServiceResponse)> {
5095 use std::borrow::Cow;
5096 use std::io::{Read, Seek};
5097
5098 use common::{url::Params, ToParts};
5099 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5100
5101 let mut dd = common::DefaultDelegate;
5102 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5103 dlg.begin(common::MethodInfo {
5104 id: "servicedirectory.projects.locations.namespaces.services.resolve",
5105 http_method: hyper::Method::POST,
5106 });
5107
5108 for &field in ["alt", "name"].iter() {
5109 if self._additional_params.contains_key(field) {
5110 dlg.finished(false);
5111 return Err(common::Error::FieldClash(field));
5112 }
5113 }
5114
5115 let mut params = Params::with_capacity(4 + self._additional_params.len());
5116 params.push("name", self._name);
5117
5118 params.extend(self._additional_params.iter());
5119
5120 params.push("alt", "json");
5121 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:resolve";
5122 if self._scopes.is_empty() {
5123 self._scopes
5124 .insert(Scope::CloudPlatform.as_ref().to_string());
5125 }
5126
5127 #[allow(clippy::single_element_loop)]
5128 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5129 url = params.uri_replacement(url, param_name, find_this, true);
5130 }
5131 {
5132 let to_remove = ["name"];
5133 params.remove_params(&to_remove);
5134 }
5135
5136 let url = params.parse_with_url(&url);
5137
5138 let mut json_mime_type = mime::APPLICATION_JSON;
5139 let mut request_value_reader = {
5140 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5141 common::remove_json_null_values(&mut value);
5142 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5143 serde_json::to_writer(&mut dst, &value).unwrap();
5144 dst
5145 };
5146 let request_size = request_value_reader
5147 .seek(std::io::SeekFrom::End(0))
5148 .unwrap();
5149 request_value_reader
5150 .seek(std::io::SeekFrom::Start(0))
5151 .unwrap();
5152
5153 loop {
5154 let token = match self
5155 .hub
5156 .auth
5157 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5158 .await
5159 {
5160 Ok(token) => token,
5161 Err(e) => match dlg.token(e) {
5162 Ok(token) => token,
5163 Err(e) => {
5164 dlg.finished(false);
5165 return Err(common::Error::MissingToken(e));
5166 }
5167 },
5168 };
5169 request_value_reader
5170 .seek(std::io::SeekFrom::Start(0))
5171 .unwrap();
5172 let mut req_result = {
5173 let client = &self.hub.client;
5174 dlg.pre_request();
5175 let mut req_builder = hyper::Request::builder()
5176 .method(hyper::Method::POST)
5177 .uri(url.as_str())
5178 .header(USER_AGENT, self.hub._user_agent.clone());
5179
5180 if let Some(token) = token.as_ref() {
5181 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5182 }
5183
5184 let request = req_builder
5185 .header(CONTENT_TYPE, json_mime_type.to_string())
5186 .header(CONTENT_LENGTH, request_size as u64)
5187 .body(common::to_body(
5188 request_value_reader.get_ref().clone().into(),
5189 ));
5190
5191 client.request(request.unwrap()).await
5192 };
5193
5194 match req_result {
5195 Err(err) => {
5196 if let common::Retry::After(d) = dlg.http_error(&err) {
5197 sleep(d).await;
5198 continue;
5199 }
5200 dlg.finished(false);
5201 return Err(common::Error::HttpError(err));
5202 }
5203 Ok(res) => {
5204 let (mut parts, body) = res.into_parts();
5205 let mut body = common::Body::new(body);
5206 if !parts.status.is_success() {
5207 let bytes = common::to_bytes(body).await.unwrap_or_default();
5208 let error = serde_json::from_str(&common::to_string(&bytes));
5209 let response = common::to_response(parts, bytes.into());
5210
5211 if let common::Retry::After(d) =
5212 dlg.http_failure(&response, error.as_ref().ok())
5213 {
5214 sleep(d).await;
5215 continue;
5216 }
5217
5218 dlg.finished(false);
5219
5220 return Err(match error {
5221 Ok(value) => common::Error::BadRequest(value),
5222 _ => common::Error::Failure(response),
5223 });
5224 }
5225 let response = {
5226 let bytes = common::to_bytes(body).await.unwrap_or_default();
5227 let encoded = common::to_string(&bytes);
5228 match serde_json::from_str(&encoded) {
5229 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5230 Err(error) => {
5231 dlg.response_json_decode_error(&encoded, &error);
5232 return Err(common::Error::JsonDecodeError(
5233 encoded.to_string(),
5234 error,
5235 ));
5236 }
5237 }
5238 };
5239
5240 dlg.finished(true);
5241 return Ok(response);
5242 }
5243 }
5244 }
5245 }
5246
5247 ///
5248 /// Sets the *request* property to the given value.
5249 ///
5250 /// Even though the property as already been set when instantiating this call,
5251 /// we provide this method for API completeness.
5252 pub fn request(
5253 mut self,
5254 new_value: ResolveServiceRequest,
5255 ) -> ProjectLocationNamespaceServiceResolveCall<'a, C> {
5256 self._request = new_value;
5257 self
5258 }
5259 /// Required. The name of the service to resolve.
5260 ///
5261 /// Sets the *name* path property to the given value.
5262 ///
5263 /// Even though the property as already been set when instantiating this call,
5264 /// we provide this method for API completeness.
5265 pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceServiceResolveCall<'a, C> {
5266 self._name = new_value.to_string();
5267 self
5268 }
5269 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5270 /// while executing the actual API request.
5271 ///
5272 /// ````text
5273 /// It should be used to handle progress information, and to implement a certain level of resilience.
5274 /// ````
5275 ///
5276 /// Sets the *delegate* property to the given value.
5277 pub fn delegate(
5278 mut self,
5279 new_value: &'a mut dyn common::Delegate,
5280 ) -> ProjectLocationNamespaceServiceResolveCall<'a, C> {
5281 self._delegate = Some(new_value);
5282 self
5283 }
5284
5285 /// Set any additional parameter of the query string used in the request.
5286 /// It should be used to set parameters which are not yet available through their own
5287 /// setters.
5288 ///
5289 /// Please note that this method must not be used to set any of the known parameters
5290 /// which have their own setter method. If done anyway, the request will fail.
5291 ///
5292 /// # Additional Parameters
5293 ///
5294 /// * *$.xgafv* (query-string) - V1 error format.
5295 /// * *access_token* (query-string) - OAuth access token.
5296 /// * *alt* (query-string) - Data format for response.
5297 /// * *callback* (query-string) - JSONP
5298 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5299 /// * *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.
5300 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5301 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5302 /// * *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.
5303 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5304 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5305 pub fn param<T>(
5306 mut self,
5307 name: T,
5308 value: T,
5309 ) -> ProjectLocationNamespaceServiceResolveCall<'a, C>
5310 where
5311 T: AsRef<str>,
5312 {
5313 self._additional_params
5314 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5315 self
5316 }
5317
5318 /// Identifies the authorization scope for the method you are building.
5319 ///
5320 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5321 /// [`Scope::CloudPlatform`].
5322 ///
5323 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5324 /// tokens for more than one scope.
5325 ///
5326 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5327 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5328 /// sufficient, a read-write scope will do as well.
5329 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceServiceResolveCall<'a, C>
5330 where
5331 St: AsRef<str>,
5332 {
5333 self._scopes.insert(String::from(scope.as_ref()));
5334 self
5335 }
5336 /// Identifies the authorization scope(s) for the method you are building.
5337 ///
5338 /// See [`Self::add_scope()`] for details.
5339 pub fn add_scopes<I, St>(
5340 mut self,
5341 scopes: I,
5342 ) -> ProjectLocationNamespaceServiceResolveCall<'a, C>
5343 where
5344 I: IntoIterator<Item = St>,
5345 St: AsRef<str>,
5346 {
5347 self._scopes
5348 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5349 self
5350 }
5351
5352 /// Removes all scopes, and no default scope will be used either.
5353 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5354 /// for details).
5355 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceResolveCall<'a, C> {
5356 self._scopes.clear();
5357 self
5358 }
5359}
5360
5361/// Sets the IAM Policy for a resource
5362///
5363/// A builder for the *locations.namespaces.services.setIamPolicy* method supported by a *project* resource.
5364/// It is not used directly, but through a [`ProjectMethods`] instance.
5365///
5366/// # Example
5367///
5368/// Instantiate a resource method builder
5369///
5370/// ```test_harness,no_run
5371/// # extern crate hyper;
5372/// # extern crate hyper_rustls;
5373/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
5374/// use servicedirectory1_beta1::api::SetIamPolicyRequest;
5375/// # async fn dox() {
5376/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5377///
5378/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5379/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5380/// # .with_native_roots()
5381/// # .unwrap()
5382/// # .https_only()
5383/// # .enable_http2()
5384/// # .build();
5385///
5386/// # let executor = hyper_util::rt::TokioExecutor::new();
5387/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5388/// # secret,
5389/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5390/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5391/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5392/// # ),
5393/// # ).build().await.unwrap();
5394///
5395/// # let client = hyper_util::client::legacy::Client::builder(
5396/// # hyper_util::rt::TokioExecutor::new()
5397/// # )
5398/// # .build(
5399/// # hyper_rustls::HttpsConnectorBuilder::new()
5400/// # .with_native_roots()
5401/// # .unwrap()
5402/// # .https_or_http()
5403/// # .enable_http2()
5404/// # .build()
5405/// # );
5406/// # let mut hub = ServiceDirectory::new(client, auth);
5407/// // As the method needs a request, you would usually fill it with the desired information
5408/// // into the respective structure. Some of the parts shown here might not be applicable !
5409/// // Values shown here are possibly random and not representative !
5410/// let mut req = SetIamPolicyRequest::default();
5411///
5412/// // You can configure optional parameters by calling the respective setters at will, and
5413/// // execute the final call using `doit()`.
5414/// // Values shown here are possibly random and not representative !
5415/// let result = hub.projects().locations_namespaces_services_set_iam_policy(req, "resource")
5416/// .doit().await;
5417/// # }
5418/// ```
5419pub struct ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C>
5420where
5421 C: 'a,
5422{
5423 hub: &'a ServiceDirectory<C>,
5424 _request: SetIamPolicyRequest,
5425 _resource: String,
5426 _delegate: Option<&'a mut dyn common::Delegate>,
5427 _additional_params: HashMap<String, String>,
5428 _scopes: BTreeSet<String>,
5429}
5430
5431impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> {}
5432
5433impl<'a, C> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C>
5434where
5435 C: common::Connector,
5436{
5437 /// Perform the operation you have build so far.
5438 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5439 use std::borrow::Cow;
5440 use std::io::{Read, Seek};
5441
5442 use common::{url::Params, ToParts};
5443 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5444
5445 let mut dd = common::DefaultDelegate;
5446 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5447 dlg.begin(common::MethodInfo {
5448 id: "servicedirectory.projects.locations.namespaces.services.setIamPolicy",
5449 http_method: hyper::Method::POST,
5450 });
5451
5452 for &field in ["alt", "resource"].iter() {
5453 if self._additional_params.contains_key(field) {
5454 dlg.finished(false);
5455 return Err(common::Error::FieldClash(field));
5456 }
5457 }
5458
5459 let mut params = Params::with_capacity(4 + self._additional_params.len());
5460 params.push("resource", self._resource);
5461
5462 params.extend(self._additional_params.iter());
5463
5464 params.push("alt", "json");
5465 let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:setIamPolicy";
5466 if self._scopes.is_empty() {
5467 self._scopes
5468 .insert(Scope::CloudPlatform.as_ref().to_string());
5469 }
5470
5471 #[allow(clippy::single_element_loop)]
5472 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5473 url = params.uri_replacement(url, param_name, find_this, true);
5474 }
5475 {
5476 let to_remove = ["resource"];
5477 params.remove_params(&to_remove);
5478 }
5479
5480 let url = params.parse_with_url(&url);
5481
5482 let mut json_mime_type = mime::APPLICATION_JSON;
5483 let mut request_value_reader = {
5484 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5485 common::remove_json_null_values(&mut value);
5486 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5487 serde_json::to_writer(&mut dst, &value).unwrap();
5488 dst
5489 };
5490 let request_size = request_value_reader
5491 .seek(std::io::SeekFrom::End(0))
5492 .unwrap();
5493 request_value_reader
5494 .seek(std::io::SeekFrom::Start(0))
5495 .unwrap();
5496
5497 loop {
5498 let token = match self
5499 .hub
5500 .auth
5501 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5502 .await
5503 {
5504 Ok(token) => token,
5505 Err(e) => match dlg.token(e) {
5506 Ok(token) => token,
5507 Err(e) => {
5508 dlg.finished(false);
5509 return Err(common::Error::MissingToken(e));
5510 }
5511 },
5512 };
5513 request_value_reader
5514 .seek(std::io::SeekFrom::Start(0))
5515 .unwrap();
5516 let mut req_result = {
5517 let client = &self.hub.client;
5518 dlg.pre_request();
5519 let mut req_builder = hyper::Request::builder()
5520 .method(hyper::Method::POST)
5521 .uri(url.as_str())
5522 .header(USER_AGENT, self.hub._user_agent.clone());
5523
5524 if let Some(token) = token.as_ref() {
5525 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5526 }
5527
5528 let request = req_builder
5529 .header(CONTENT_TYPE, json_mime_type.to_string())
5530 .header(CONTENT_LENGTH, request_size as u64)
5531 .body(common::to_body(
5532 request_value_reader.get_ref().clone().into(),
5533 ));
5534
5535 client.request(request.unwrap()).await
5536 };
5537
5538 match req_result {
5539 Err(err) => {
5540 if let common::Retry::After(d) = dlg.http_error(&err) {
5541 sleep(d).await;
5542 continue;
5543 }
5544 dlg.finished(false);
5545 return Err(common::Error::HttpError(err));
5546 }
5547 Ok(res) => {
5548 let (mut parts, body) = res.into_parts();
5549 let mut body = common::Body::new(body);
5550 if !parts.status.is_success() {
5551 let bytes = common::to_bytes(body).await.unwrap_or_default();
5552 let error = serde_json::from_str(&common::to_string(&bytes));
5553 let response = common::to_response(parts, bytes.into());
5554
5555 if let common::Retry::After(d) =
5556 dlg.http_failure(&response, error.as_ref().ok())
5557 {
5558 sleep(d).await;
5559 continue;
5560 }
5561
5562 dlg.finished(false);
5563
5564 return Err(match error {
5565 Ok(value) => common::Error::BadRequest(value),
5566 _ => common::Error::Failure(response),
5567 });
5568 }
5569 let response = {
5570 let bytes = common::to_bytes(body).await.unwrap_or_default();
5571 let encoded = common::to_string(&bytes);
5572 match serde_json::from_str(&encoded) {
5573 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5574 Err(error) => {
5575 dlg.response_json_decode_error(&encoded, &error);
5576 return Err(common::Error::JsonDecodeError(
5577 encoded.to_string(),
5578 error,
5579 ));
5580 }
5581 }
5582 };
5583
5584 dlg.finished(true);
5585 return Ok(response);
5586 }
5587 }
5588 }
5589 }
5590
5591 ///
5592 /// Sets the *request* property to the given value.
5593 ///
5594 /// Even though the property as already been set when instantiating this call,
5595 /// we provide this method for API completeness.
5596 pub fn request(
5597 mut self,
5598 new_value: SetIamPolicyRequest,
5599 ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> {
5600 self._request = new_value;
5601 self
5602 }
5603 /// 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.
5604 ///
5605 /// Sets the *resource* path property to the given value.
5606 ///
5607 /// Even though the property as already been set when instantiating this call,
5608 /// we provide this method for API completeness.
5609 pub fn resource(
5610 mut self,
5611 new_value: &str,
5612 ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> {
5613 self._resource = new_value.to_string();
5614 self
5615 }
5616 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5617 /// while executing the actual API request.
5618 ///
5619 /// ````text
5620 /// It should be used to handle progress information, and to implement a certain level of resilience.
5621 /// ````
5622 ///
5623 /// Sets the *delegate* property to the given value.
5624 pub fn delegate(
5625 mut self,
5626 new_value: &'a mut dyn common::Delegate,
5627 ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> {
5628 self._delegate = Some(new_value);
5629 self
5630 }
5631
5632 /// Set any additional parameter of the query string used in the request.
5633 /// It should be used to set parameters which are not yet available through their own
5634 /// setters.
5635 ///
5636 /// Please note that this method must not be used to set any of the known parameters
5637 /// which have their own setter method. If done anyway, the request will fail.
5638 ///
5639 /// # Additional Parameters
5640 ///
5641 /// * *$.xgafv* (query-string) - V1 error format.
5642 /// * *access_token* (query-string) - OAuth access token.
5643 /// * *alt* (query-string) - Data format for response.
5644 /// * *callback* (query-string) - JSONP
5645 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5646 /// * *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.
5647 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5648 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5649 /// * *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.
5650 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5651 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5652 pub fn param<T>(
5653 mut self,
5654 name: T,
5655 value: T,
5656 ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C>
5657 where
5658 T: AsRef<str>,
5659 {
5660 self._additional_params
5661 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5662 self
5663 }
5664
5665 /// Identifies the authorization scope for the method you are building.
5666 ///
5667 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5668 /// [`Scope::CloudPlatform`].
5669 ///
5670 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5671 /// tokens for more than one scope.
5672 ///
5673 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5674 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5675 /// sufficient, a read-write scope will do as well.
5676 pub fn add_scope<St>(
5677 mut self,
5678 scope: St,
5679 ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C>
5680 where
5681 St: AsRef<str>,
5682 {
5683 self._scopes.insert(String::from(scope.as_ref()));
5684 self
5685 }
5686 /// Identifies the authorization scope(s) for the method you are building.
5687 ///
5688 /// See [`Self::add_scope()`] for details.
5689 pub fn add_scopes<I, St>(
5690 mut self,
5691 scopes: I,
5692 ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C>
5693 where
5694 I: IntoIterator<Item = St>,
5695 St: AsRef<str>,
5696 {
5697 self._scopes
5698 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5699 self
5700 }
5701
5702 /// Removes all scopes, and no default scope will be used either.
5703 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5704 /// for details).
5705 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> {
5706 self._scopes.clear();
5707 self
5708 }
5709}
5710
5711/// Tests IAM permissions for a resource (namespace, service or service workload only).
5712///
5713/// A builder for the *locations.namespaces.services.testIamPermissions* method supported by a *project* resource.
5714/// It is not used directly, but through a [`ProjectMethods`] instance.
5715///
5716/// # Example
5717///
5718/// Instantiate a resource method builder
5719///
5720/// ```test_harness,no_run
5721/// # extern crate hyper;
5722/// # extern crate hyper_rustls;
5723/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
5724/// use servicedirectory1_beta1::api::TestIamPermissionsRequest;
5725/// # async fn dox() {
5726/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5727///
5728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5729/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5730/// # .with_native_roots()
5731/// # .unwrap()
5732/// # .https_only()
5733/// # .enable_http2()
5734/// # .build();
5735///
5736/// # let executor = hyper_util::rt::TokioExecutor::new();
5737/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5738/// # secret,
5739/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5740/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5741/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5742/// # ),
5743/// # ).build().await.unwrap();
5744///
5745/// # let client = hyper_util::client::legacy::Client::builder(
5746/// # hyper_util::rt::TokioExecutor::new()
5747/// # )
5748/// # .build(
5749/// # hyper_rustls::HttpsConnectorBuilder::new()
5750/// # .with_native_roots()
5751/// # .unwrap()
5752/// # .https_or_http()
5753/// # .enable_http2()
5754/// # .build()
5755/// # );
5756/// # let mut hub = ServiceDirectory::new(client, auth);
5757/// // As the method needs a request, you would usually fill it with the desired information
5758/// // into the respective structure. Some of the parts shown here might not be applicable !
5759/// // Values shown here are possibly random and not representative !
5760/// let mut req = TestIamPermissionsRequest::default();
5761///
5762/// // You can configure optional parameters by calling the respective setters at will, and
5763/// // execute the final call using `doit()`.
5764/// // Values shown here are possibly random and not representative !
5765/// let result = hub.projects().locations_namespaces_services_test_iam_permissions(req, "resource")
5766/// .doit().await;
5767/// # }
5768/// ```
5769pub struct ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C>
5770where
5771 C: 'a,
5772{
5773 hub: &'a ServiceDirectory<C>,
5774 _request: TestIamPermissionsRequest,
5775 _resource: String,
5776 _delegate: Option<&'a mut dyn common::Delegate>,
5777 _additional_params: HashMap<String, String>,
5778 _scopes: BTreeSet<String>,
5779}
5780
5781impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> {}
5782
5783impl<'a, C> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C>
5784where
5785 C: common::Connector,
5786{
5787 /// Perform the operation you have build so far.
5788 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
5789 use std::borrow::Cow;
5790 use std::io::{Read, Seek};
5791
5792 use common::{url::Params, ToParts};
5793 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5794
5795 let mut dd = common::DefaultDelegate;
5796 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5797 dlg.begin(common::MethodInfo {
5798 id: "servicedirectory.projects.locations.namespaces.services.testIamPermissions",
5799 http_method: hyper::Method::POST,
5800 });
5801
5802 for &field in ["alt", "resource"].iter() {
5803 if self._additional_params.contains_key(field) {
5804 dlg.finished(false);
5805 return Err(common::Error::FieldClash(field));
5806 }
5807 }
5808
5809 let mut params = Params::with_capacity(4 + self._additional_params.len());
5810 params.push("resource", self._resource);
5811
5812 params.extend(self._additional_params.iter());
5813
5814 params.push("alt", "json");
5815 let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:testIamPermissions";
5816 if self._scopes.is_empty() {
5817 self._scopes
5818 .insert(Scope::CloudPlatform.as_ref().to_string());
5819 }
5820
5821 #[allow(clippy::single_element_loop)]
5822 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5823 url = params.uri_replacement(url, param_name, find_this, true);
5824 }
5825 {
5826 let to_remove = ["resource"];
5827 params.remove_params(&to_remove);
5828 }
5829
5830 let url = params.parse_with_url(&url);
5831
5832 let mut json_mime_type = mime::APPLICATION_JSON;
5833 let mut request_value_reader = {
5834 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5835 common::remove_json_null_values(&mut value);
5836 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5837 serde_json::to_writer(&mut dst, &value).unwrap();
5838 dst
5839 };
5840 let request_size = request_value_reader
5841 .seek(std::io::SeekFrom::End(0))
5842 .unwrap();
5843 request_value_reader
5844 .seek(std::io::SeekFrom::Start(0))
5845 .unwrap();
5846
5847 loop {
5848 let token = match self
5849 .hub
5850 .auth
5851 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5852 .await
5853 {
5854 Ok(token) => token,
5855 Err(e) => match dlg.token(e) {
5856 Ok(token) => token,
5857 Err(e) => {
5858 dlg.finished(false);
5859 return Err(common::Error::MissingToken(e));
5860 }
5861 },
5862 };
5863 request_value_reader
5864 .seek(std::io::SeekFrom::Start(0))
5865 .unwrap();
5866 let mut req_result = {
5867 let client = &self.hub.client;
5868 dlg.pre_request();
5869 let mut req_builder = hyper::Request::builder()
5870 .method(hyper::Method::POST)
5871 .uri(url.as_str())
5872 .header(USER_AGENT, self.hub._user_agent.clone());
5873
5874 if let Some(token) = token.as_ref() {
5875 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5876 }
5877
5878 let request = req_builder
5879 .header(CONTENT_TYPE, json_mime_type.to_string())
5880 .header(CONTENT_LENGTH, request_size as u64)
5881 .body(common::to_body(
5882 request_value_reader.get_ref().clone().into(),
5883 ));
5884
5885 client.request(request.unwrap()).await
5886 };
5887
5888 match req_result {
5889 Err(err) => {
5890 if let common::Retry::After(d) = dlg.http_error(&err) {
5891 sleep(d).await;
5892 continue;
5893 }
5894 dlg.finished(false);
5895 return Err(common::Error::HttpError(err));
5896 }
5897 Ok(res) => {
5898 let (mut parts, body) = res.into_parts();
5899 let mut body = common::Body::new(body);
5900 if !parts.status.is_success() {
5901 let bytes = common::to_bytes(body).await.unwrap_or_default();
5902 let error = serde_json::from_str(&common::to_string(&bytes));
5903 let response = common::to_response(parts, bytes.into());
5904
5905 if let common::Retry::After(d) =
5906 dlg.http_failure(&response, error.as_ref().ok())
5907 {
5908 sleep(d).await;
5909 continue;
5910 }
5911
5912 dlg.finished(false);
5913
5914 return Err(match error {
5915 Ok(value) => common::Error::BadRequest(value),
5916 _ => common::Error::Failure(response),
5917 });
5918 }
5919 let response = {
5920 let bytes = common::to_bytes(body).await.unwrap_or_default();
5921 let encoded = common::to_string(&bytes);
5922 match serde_json::from_str(&encoded) {
5923 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5924 Err(error) => {
5925 dlg.response_json_decode_error(&encoded, &error);
5926 return Err(common::Error::JsonDecodeError(
5927 encoded.to_string(),
5928 error,
5929 ));
5930 }
5931 }
5932 };
5933
5934 dlg.finished(true);
5935 return Ok(response);
5936 }
5937 }
5938 }
5939 }
5940
5941 ///
5942 /// Sets the *request* property to the given value.
5943 ///
5944 /// Even though the property as already been set when instantiating this call,
5945 /// we provide this method for API completeness.
5946 pub fn request(
5947 mut self,
5948 new_value: TestIamPermissionsRequest,
5949 ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> {
5950 self._request = new_value;
5951 self
5952 }
5953 /// 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.
5954 ///
5955 /// Sets the *resource* path property to the given value.
5956 ///
5957 /// Even though the property as already been set when instantiating this call,
5958 /// we provide this method for API completeness.
5959 pub fn resource(
5960 mut self,
5961 new_value: &str,
5962 ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> {
5963 self._resource = new_value.to_string();
5964 self
5965 }
5966 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5967 /// while executing the actual API request.
5968 ///
5969 /// ````text
5970 /// It should be used to handle progress information, and to implement a certain level of resilience.
5971 /// ````
5972 ///
5973 /// Sets the *delegate* property to the given value.
5974 pub fn delegate(
5975 mut self,
5976 new_value: &'a mut dyn common::Delegate,
5977 ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> {
5978 self._delegate = Some(new_value);
5979 self
5980 }
5981
5982 /// Set any additional parameter of the query string used in the request.
5983 /// It should be used to set parameters which are not yet available through their own
5984 /// setters.
5985 ///
5986 /// Please note that this method must not be used to set any of the known parameters
5987 /// which have their own setter method. If done anyway, the request will fail.
5988 ///
5989 /// # Additional Parameters
5990 ///
5991 /// * *$.xgafv* (query-string) - V1 error format.
5992 /// * *access_token* (query-string) - OAuth access token.
5993 /// * *alt* (query-string) - Data format for response.
5994 /// * *callback* (query-string) - JSONP
5995 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5996 /// * *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.
5997 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5998 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5999 /// * *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.
6000 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6001 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6002 pub fn param<T>(
6003 mut self,
6004 name: T,
6005 value: T,
6006 ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C>
6007 where
6008 T: AsRef<str>,
6009 {
6010 self._additional_params
6011 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6012 self
6013 }
6014
6015 /// Identifies the authorization scope for the method you are building.
6016 ///
6017 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6018 /// [`Scope::CloudPlatform`].
6019 ///
6020 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6021 /// tokens for more than one scope.
6022 ///
6023 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6024 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6025 /// sufficient, a read-write scope will do as well.
6026 pub fn add_scope<St>(
6027 mut self,
6028 scope: St,
6029 ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C>
6030 where
6031 St: AsRef<str>,
6032 {
6033 self._scopes.insert(String::from(scope.as_ref()));
6034 self
6035 }
6036 /// Identifies the authorization scope(s) for the method you are building.
6037 ///
6038 /// See [`Self::add_scope()`] for details.
6039 pub fn add_scopes<I, St>(
6040 mut self,
6041 scopes: I,
6042 ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C>
6043 where
6044 I: IntoIterator<Item = St>,
6045 St: AsRef<str>,
6046 {
6047 self._scopes
6048 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6049 self
6050 }
6051
6052 /// Removes all scopes, and no default scope will be used either.
6053 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6054 /// for details).
6055 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> {
6056 self._scopes.clear();
6057 self
6058 }
6059}
6060
6061/// Gets the IAM Policy for a resource
6062///
6063/// A builder for the *locations.namespaces.workloads.getIamPolicy* method supported by a *project* resource.
6064/// It is not used directly, but through a [`ProjectMethods`] instance.
6065///
6066/// # Example
6067///
6068/// Instantiate a resource method builder
6069///
6070/// ```test_harness,no_run
6071/// # extern crate hyper;
6072/// # extern crate hyper_rustls;
6073/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
6074/// use servicedirectory1_beta1::api::GetIamPolicyRequest;
6075/// # async fn dox() {
6076/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6077///
6078/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6079/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6080/// # .with_native_roots()
6081/// # .unwrap()
6082/// # .https_only()
6083/// # .enable_http2()
6084/// # .build();
6085///
6086/// # let executor = hyper_util::rt::TokioExecutor::new();
6087/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6088/// # secret,
6089/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6090/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6091/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6092/// # ),
6093/// # ).build().await.unwrap();
6094///
6095/// # let client = hyper_util::client::legacy::Client::builder(
6096/// # hyper_util::rt::TokioExecutor::new()
6097/// # )
6098/// # .build(
6099/// # hyper_rustls::HttpsConnectorBuilder::new()
6100/// # .with_native_roots()
6101/// # .unwrap()
6102/// # .https_or_http()
6103/// # .enable_http2()
6104/// # .build()
6105/// # );
6106/// # let mut hub = ServiceDirectory::new(client, auth);
6107/// // As the method needs a request, you would usually fill it with the desired information
6108/// // into the respective structure. Some of the parts shown here might not be applicable !
6109/// // Values shown here are possibly random and not representative !
6110/// let mut req = GetIamPolicyRequest::default();
6111///
6112/// // You can configure optional parameters by calling the respective setters at will, and
6113/// // execute the final call using `doit()`.
6114/// // Values shown here are possibly random and not representative !
6115/// let result = hub.projects().locations_namespaces_workloads_get_iam_policy(req, "resource")
6116/// .doit().await;
6117/// # }
6118/// ```
6119pub struct ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C>
6120where
6121 C: 'a,
6122{
6123 hub: &'a ServiceDirectory<C>,
6124 _request: GetIamPolicyRequest,
6125 _resource: String,
6126 _delegate: Option<&'a mut dyn common::Delegate>,
6127 _additional_params: HashMap<String, String>,
6128 _scopes: BTreeSet<String>,
6129}
6130
6131impl<'a, C> common::CallBuilder for ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C> {}
6132
6133impl<'a, C> ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C>
6134where
6135 C: common::Connector,
6136{
6137 /// Perform the operation you have build so far.
6138 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6139 use std::borrow::Cow;
6140 use std::io::{Read, Seek};
6141
6142 use common::{url::Params, ToParts};
6143 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6144
6145 let mut dd = common::DefaultDelegate;
6146 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6147 dlg.begin(common::MethodInfo {
6148 id: "servicedirectory.projects.locations.namespaces.workloads.getIamPolicy",
6149 http_method: hyper::Method::POST,
6150 });
6151
6152 for &field in ["alt", "resource"].iter() {
6153 if self._additional_params.contains_key(field) {
6154 dlg.finished(false);
6155 return Err(common::Error::FieldClash(field));
6156 }
6157 }
6158
6159 let mut params = Params::with_capacity(4 + self._additional_params.len());
6160 params.push("resource", self._resource);
6161
6162 params.extend(self._additional_params.iter());
6163
6164 params.push("alt", "json");
6165 let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:getIamPolicy";
6166 if self._scopes.is_empty() {
6167 self._scopes
6168 .insert(Scope::CloudPlatform.as_ref().to_string());
6169 }
6170
6171 #[allow(clippy::single_element_loop)]
6172 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6173 url = params.uri_replacement(url, param_name, find_this, true);
6174 }
6175 {
6176 let to_remove = ["resource"];
6177 params.remove_params(&to_remove);
6178 }
6179
6180 let url = params.parse_with_url(&url);
6181
6182 let mut json_mime_type = mime::APPLICATION_JSON;
6183 let mut request_value_reader = {
6184 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6185 common::remove_json_null_values(&mut value);
6186 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6187 serde_json::to_writer(&mut dst, &value).unwrap();
6188 dst
6189 };
6190 let request_size = request_value_reader
6191 .seek(std::io::SeekFrom::End(0))
6192 .unwrap();
6193 request_value_reader
6194 .seek(std::io::SeekFrom::Start(0))
6195 .unwrap();
6196
6197 loop {
6198 let token = match self
6199 .hub
6200 .auth
6201 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6202 .await
6203 {
6204 Ok(token) => token,
6205 Err(e) => match dlg.token(e) {
6206 Ok(token) => token,
6207 Err(e) => {
6208 dlg.finished(false);
6209 return Err(common::Error::MissingToken(e));
6210 }
6211 },
6212 };
6213 request_value_reader
6214 .seek(std::io::SeekFrom::Start(0))
6215 .unwrap();
6216 let mut req_result = {
6217 let client = &self.hub.client;
6218 dlg.pre_request();
6219 let mut req_builder = hyper::Request::builder()
6220 .method(hyper::Method::POST)
6221 .uri(url.as_str())
6222 .header(USER_AGENT, self.hub._user_agent.clone());
6223
6224 if let Some(token) = token.as_ref() {
6225 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6226 }
6227
6228 let request = req_builder
6229 .header(CONTENT_TYPE, json_mime_type.to_string())
6230 .header(CONTENT_LENGTH, request_size as u64)
6231 .body(common::to_body(
6232 request_value_reader.get_ref().clone().into(),
6233 ));
6234
6235 client.request(request.unwrap()).await
6236 };
6237
6238 match req_result {
6239 Err(err) => {
6240 if let common::Retry::After(d) = dlg.http_error(&err) {
6241 sleep(d).await;
6242 continue;
6243 }
6244 dlg.finished(false);
6245 return Err(common::Error::HttpError(err));
6246 }
6247 Ok(res) => {
6248 let (mut parts, body) = res.into_parts();
6249 let mut body = common::Body::new(body);
6250 if !parts.status.is_success() {
6251 let bytes = common::to_bytes(body).await.unwrap_or_default();
6252 let error = serde_json::from_str(&common::to_string(&bytes));
6253 let response = common::to_response(parts, bytes.into());
6254
6255 if let common::Retry::After(d) =
6256 dlg.http_failure(&response, error.as_ref().ok())
6257 {
6258 sleep(d).await;
6259 continue;
6260 }
6261
6262 dlg.finished(false);
6263
6264 return Err(match error {
6265 Ok(value) => common::Error::BadRequest(value),
6266 _ => common::Error::Failure(response),
6267 });
6268 }
6269 let response = {
6270 let bytes = common::to_bytes(body).await.unwrap_or_default();
6271 let encoded = common::to_string(&bytes);
6272 match serde_json::from_str(&encoded) {
6273 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6274 Err(error) => {
6275 dlg.response_json_decode_error(&encoded, &error);
6276 return Err(common::Error::JsonDecodeError(
6277 encoded.to_string(),
6278 error,
6279 ));
6280 }
6281 }
6282 };
6283
6284 dlg.finished(true);
6285 return Ok(response);
6286 }
6287 }
6288 }
6289 }
6290
6291 ///
6292 /// Sets the *request* property to the given value.
6293 ///
6294 /// Even though the property as already been set when instantiating this call,
6295 /// we provide this method for API completeness.
6296 pub fn request(
6297 mut self,
6298 new_value: GetIamPolicyRequest,
6299 ) -> ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C> {
6300 self._request = new_value;
6301 self
6302 }
6303 /// 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.
6304 ///
6305 /// Sets the *resource* path property to the given value.
6306 ///
6307 /// Even though the property as already been set when instantiating this call,
6308 /// we provide this method for API completeness.
6309 pub fn resource(
6310 mut self,
6311 new_value: &str,
6312 ) -> ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C> {
6313 self._resource = new_value.to_string();
6314 self
6315 }
6316 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6317 /// while executing the actual API request.
6318 ///
6319 /// ````text
6320 /// It should be used to handle progress information, and to implement a certain level of resilience.
6321 /// ````
6322 ///
6323 /// Sets the *delegate* property to the given value.
6324 pub fn delegate(
6325 mut self,
6326 new_value: &'a mut dyn common::Delegate,
6327 ) -> ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C> {
6328 self._delegate = Some(new_value);
6329 self
6330 }
6331
6332 /// Set any additional parameter of the query string used in the request.
6333 /// It should be used to set parameters which are not yet available through their own
6334 /// setters.
6335 ///
6336 /// Please note that this method must not be used to set any of the known parameters
6337 /// which have their own setter method. If done anyway, the request will fail.
6338 ///
6339 /// # Additional Parameters
6340 ///
6341 /// * *$.xgafv* (query-string) - V1 error format.
6342 /// * *access_token* (query-string) - OAuth access token.
6343 /// * *alt* (query-string) - Data format for response.
6344 /// * *callback* (query-string) - JSONP
6345 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6346 /// * *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.
6347 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6348 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6349 /// * *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.
6350 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6351 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6352 pub fn param<T>(
6353 mut self,
6354 name: T,
6355 value: T,
6356 ) -> ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C>
6357 where
6358 T: AsRef<str>,
6359 {
6360 self._additional_params
6361 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6362 self
6363 }
6364
6365 /// Identifies the authorization scope for the method you are building.
6366 ///
6367 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6368 /// [`Scope::CloudPlatform`].
6369 ///
6370 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6371 /// tokens for more than one scope.
6372 ///
6373 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6374 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6375 /// sufficient, a read-write scope will do as well.
6376 pub fn add_scope<St>(
6377 mut self,
6378 scope: St,
6379 ) -> ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C>
6380 where
6381 St: AsRef<str>,
6382 {
6383 self._scopes.insert(String::from(scope.as_ref()));
6384 self
6385 }
6386 /// Identifies the authorization scope(s) for the method you are building.
6387 ///
6388 /// See [`Self::add_scope()`] for details.
6389 pub fn add_scopes<I, St>(
6390 mut self,
6391 scopes: I,
6392 ) -> ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C>
6393 where
6394 I: IntoIterator<Item = St>,
6395 St: AsRef<str>,
6396 {
6397 self._scopes
6398 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6399 self
6400 }
6401
6402 /// Removes all scopes, and no default scope will be used either.
6403 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6404 /// for details).
6405 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceWorkloadGetIamPolicyCall<'a, C> {
6406 self._scopes.clear();
6407 self
6408 }
6409}
6410
6411/// Sets the IAM Policy for a resource
6412///
6413/// A builder for the *locations.namespaces.workloads.setIamPolicy* method supported by a *project* resource.
6414/// It is not used directly, but through a [`ProjectMethods`] instance.
6415///
6416/// # Example
6417///
6418/// Instantiate a resource method builder
6419///
6420/// ```test_harness,no_run
6421/// # extern crate hyper;
6422/// # extern crate hyper_rustls;
6423/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
6424/// use servicedirectory1_beta1::api::SetIamPolicyRequest;
6425/// # async fn dox() {
6426/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6427///
6428/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6429/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6430/// # .with_native_roots()
6431/// # .unwrap()
6432/// # .https_only()
6433/// # .enable_http2()
6434/// # .build();
6435///
6436/// # let executor = hyper_util::rt::TokioExecutor::new();
6437/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6438/// # secret,
6439/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6440/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6441/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6442/// # ),
6443/// # ).build().await.unwrap();
6444///
6445/// # let client = hyper_util::client::legacy::Client::builder(
6446/// # hyper_util::rt::TokioExecutor::new()
6447/// # )
6448/// # .build(
6449/// # hyper_rustls::HttpsConnectorBuilder::new()
6450/// # .with_native_roots()
6451/// # .unwrap()
6452/// # .https_or_http()
6453/// # .enable_http2()
6454/// # .build()
6455/// # );
6456/// # let mut hub = ServiceDirectory::new(client, auth);
6457/// // As the method needs a request, you would usually fill it with the desired information
6458/// // into the respective structure. Some of the parts shown here might not be applicable !
6459/// // Values shown here are possibly random and not representative !
6460/// let mut req = SetIamPolicyRequest::default();
6461///
6462/// // You can configure optional parameters by calling the respective setters at will, and
6463/// // execute the final call using `doit()`.
6464/// // Values shown here are possibly random and not representative !
6465/// let result = hub.projects().locations_namespaces_workloads_set_iam_policy(req, "resource")
6466/// .doit().await;
6467/// # }
6468/// ```
6469pub struct ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C>
6470where
6471 C: 'a,
6472{
6473 hub: &'a ServiceDirectory<C>,
6474 _request: SetIamPolicyRequest,
6475 _resource: String,
6476 _delegate: Option<&'a mut dyn common::Delegate>,
6477 _additional_params: HashMap<String, String>,
6478 _scopes: BTreeSet<String>,
6479}
6480
6481impl<'a, C> common::CallBuilder for ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C> {}
6482
6483impl<'a, C> ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C>
6484where
6485 C: common::Connector,
6486{
6487 /// Perform the operation you have build so far.
6488 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6489 use std::borrow::Cow;
6490 use std::io::{Read, Seek};
6491
6492 use common::{url::Params, ToParts};
6493 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6494
6495 let mut dd = common::DefaultDelegate;
6496 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6497 dlg.begin(common::MethodInfo {
6498 id: "servicedirectory.projects.locations.namespaces.workloads.setIamPolicy",
6499 http_method: hyper::Method::POST,
6500 });
6501
6502 for &field in ["alt", "resource"].iter() {
6503 if self._additional_params.contains_key(field) {
6504 dlg.finished(false);
6505 return Err(common::Error::FieldClash(field));
6506 }
6507 }
6508
6509 let mut params = Params::with_capacity(4 + self._additional_params.len());
6510 params.push("resource", self._resource);
6511
6512 params.extend(self._additional_params.iter());
6513
6514 params.push("alt", "json");
6515 let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:setIamPolicy";
6516 if self._scopes.is_empty() {
6517 self._scopes
6518 .insert(Scope::CloudPlatform.as_ref().to_string());
6519 }
6520
6521 #[allow(clippy::single_element_loop)]
6522 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6523 url = params.uri_replacement(url, param_name, find_this, true);
6524 }
6525 {
6526 let to_remove = ["resource"];
6527 params.remove_params(&to_remove);
6528 }
6529
6530 let url = params.parse_with_url(&url);
6531
6532 let mut json_mime_type = mime::APPLICATION_JSON;
6533 let mut request_value_reader = {
6534 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6535 common::remove_json_null_values(&mut value);
6536 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6537 serde_json::to_writer(&mut dst, &value).unwrap();
6538 dst
6539 };
6540 let request_size = request_value_reader
6541 .seek(std::io::SeekFrom::End(0))
6542 .unwrap();
6543 request_value_reader
6544 .seek(std::io::SeekFrom::Start(0))
6545 .unwrap();
6546
6547 loop {
6548 let token = match self
6549 .hub
6550 .auth
6551 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6552 .await
6553 {
6554 Ok(token) => token,
6555 Err(e) => match dlg.token(e) {
6556 Ok(token) => token,
6557 Err(e) => {
6558 dlg.finished(false);
6559 return Err(common::Error::MissingToken(e));
6560 }
6561 },
6562 };
6563 request_value_reader
6564 .seek(std::io::SeekFrom::Start(0))
6565 .unwrap();
6566 let mut req_result = {
6567 let client = &self.hub.client;
6568 dlg.pre_request();
6569 let mut req_builder = hyper::Request::builder()
6570 .method(hyper::Method::POST)
6571 .uri(url.as_str())
6572 .header(USER_AGENT, self.hub._user_agent.clone());
6573
6574 if let Some(token) = token.as_ref() {
6575 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6576 }
6577
6578 let request = req_builder
6579 .header(CONTENT_TYPE, json_mime_type.to_string())
6580 .header(CONTENT_LENGTH, request_size as u64)
6581 .body(common::to_body(
6582 request_value_reader.get_ref().clone().into(),
6583 ));
6584
6585 client.request(request.unwrap()).await
6586 };
6587
6588 match req_result {
6589 Err(err) => {
6590 if let common::Retry::After(d) = dlg.http_error(&err) {
6591 sleep(d).await;
6592 continue;
6593 }
6594 dlg.finished(false);
6595 return Err(common::Error::HttpError(err));
6596 }
6597 Ok(res) => {
6598 let (mut parts, body) = res.into_parts();
6599 let mut body = common::Body::new(body);
6600 if !parts.status.is_success() {
6601 let bytes = common::to_bytes(body).await.unwrap_or_default();
6602 let error = serde_json::from_str(&common::to_string(&bytes));
6603 let response = common::to_response(parts, bytes.into());
6604
6605 if let common::Retry::After(d) =
6606 dlg.http_failure(&response, error.as_ref().ok())
6607 {
6608 sleep(d).await;
6609 continue;
6610 }
6611
6612 dlg.finished(false);
6613
6614 return Err(match error {
6615 Ok(value) => common::Error::BadRequest(value),
6616 _ => common::Error::Failure(response),
6617 });
6618 }
6619 let response = {
6620 let bytes = common::to_bytes(body).await.unwrap_or_default();
6621 let encoded = common::to_string(&bytes);
6622 match serde_json::from_str(&encoded) {
6623 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6624 Err(error) => {
6625 dlg.response_json_decode_error(&encoded, &error);
6626 return Err(common::Error::JsonDecodeError(
6627 encoded.to_string(),
6628 error,
6629 ));
6630 }
6631 }
6632 };
6633
6634 dlg.finished(true);
6635 return Ok(response);
6636 }
6637 }
6638 }
6639 }
6640
6641 ///
6642 /// Sets the *request* property to the given value.
6643 ///
6644 /// Even though the property as already been set when instantiating this call,
6645 /// we provide this method for API completeness.
6646 pub fn request(
6647 mut self,
6648 new_value: SetIamPolicyRequest,
6649 ) -> ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C> {
6650 self._request = new_value;
6651 self
6652 }
6653 /// 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.
6654 ///
6655 /// Sets the *resource* path property to the given value.
6656 ///
6657 /// Even though the property as already been set when instantiating this call,
6658 /// we provide this method for API completeness.
6659 pub fn resource(
6660 mut self,
6661 new_value: &str,
6662 ) -> ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C> {
6663 self._resource = new_value.to_string();
6664 self
6665 }
6666 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6667 /// while executing the actual API request.
6668 ///
6669 /// ````text
6670 /// It should be used to handle progress information, and to implement a certain level of resilience.
6671 /// ````
6672 ///
6673 /// Sets the *delegate* property to the given value.
6674 pub fn delegate(
6675 mut self,
6676 new_value: &'a mut dyn common::Delegate,
6677 ) -> ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C> {
6678 self._delegate = Some(new_value);
6679 self
6680 }
6681
6682 /// Set any additional parameter of the query string used in the request.
6683 /// It should be used to set parameters which are not yet available through their own
6684 /// setters.
6685 ///
6686 /// Please note that this method must not be used to set any of the known parameters
6687 /// which have their own setter method. If done anyway, the request will fail.
6688 ///
6689 /// # Additional Parameters
6690 ///
6691 /// * *$.xgafv* (query-string) - V1 error format.
6692 /// * *access_token* (query-string) - OAuth access token.
6693 /// * *alt* (query-string) - Data format for response.
6694 /// * *callback* (query-string) - JSONP
6695 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6696 /// * *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.
6697 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6698 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6699 /// * *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.
6700 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6701 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6702 pub fn param<T>(
6703 mut self,
6704 name: T,
6705 value: T,
6706 ) -> ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C>
6707 where
6708 T: AsRef<str>,
6709 {
6710 self._additional_params
6711 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6712 self
6713 }
6714
6715 /// Identifies the authorization scope for the method you are building.
6716 ///
6717 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6718 /// [`Scope::CloudPlatform`].
6719 ///
6720 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6721 /// tokens for more than one scope.
6722 ///
6723 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6724 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6725 /// sufficient, a read-write scope will do as well.
6726 pub fn add_scope<St>(
6727 mut self,
6728 scope: St,
6729 ) -> ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C>
6730 where
6731 St: AsRef<str>,
6732 {
6733 self._scopes.insert(String::from(scope.as_ref()));
6734 self
6735 }
6736 /// Identifies the authorization scope(s) for the method you are building.
6737 ///
6738 /// See [`Self::add_scope()`] for details.
6739 pub fn add_scopes<I, St>(
6740 mut self,
6741 scopes: I,
6742 ) -> ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C>
6743 where
6744 I: IntoIterator<Item = St>,
6745 St: AsRef<str>,
6746 {
6747 self._scopes
6748 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6749 self
6750 }
6751
6752 /// Removes all scopes, and no default scope will be used either.
6753 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6754 /// for details).
6755 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceWorkloadSetIamPolicyCall<'a, C> {
6756 self._scopes.clear();
6757 self
6758 }
6759}
6760
6761/// Tests IAM permissions for a resource (namespace, service or service workload only).
6762///
6763/// A builder for the *locations.namespaces.workloads.testIamPermissions* method supported by a *project* resource.
6764/// It is not used directly, but through a [`ProjectMethods`] instance.
6765///
6766/// # Example
6767///
6768/// Instantiate a resource method builder
6769///
6770/// ```test_harness,no_run
6771/// # extern crate hyper;
6772/// # extern crate hyper_rustls;
6773/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
6774/// use servicedirectory1_beta1::api::TestIamPermissionsRequest;
6775/// # async fn dox() {
6776/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6777///
6778/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6779/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6780/// # .with_native_roots()
6781/// # .unwrap()
6782/// # .https_only()
6783/// # .enable_http2()
6784/// # .build();
6785///
6786/// # let executor = hyper_util::rt::TokioExecutor::new();
6787/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6788/// # secret,
6789/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6790/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6791/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6792/// # ),
6793/// # ).build().await.unwrap();
6794///
6795/// # let client = hyper_util::client::legacy::Client::builder(
6796/// # hyper_util::rt::TokioExecutor::new()
6797/// # )
6798/// # .build(
6799/// # hyper_rustls::HttpsConnectorBuilder::new()
6800/// # .with_native_roots()
6801/// # .unwrap()
6802/// # .https_or_http()
6803/// # .enable_http2()
6804/// # .build()
6805/// # );
6806/// # let mut hub = ServiceDirectory::new(client, auth);
6807/// // As the method needs a request, you would usually fill it with the desired information
6808/// // into the respective structure. Some of the parts shown here might not be applicable !
6809/// // Values shown here are possibly random and not representative !
6810/// let mut req = TestIamPermissionsRequest::default();
6811///
6812/// // You can configure optional parameters by calling the respective setters at will, and
6813/// // execute the final call using `doit()`.
6814/// // Values shown here are possibly random and not representative !
6815/// let result = hub.projects().locations_namespaces_workloads_test_iam_permissions(req, "resource")
6816/// .doit().await;
6817/// # }
6818/// ```
6819pub struct ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C>
6820where
6821 C: 'a,
6822{
6823 hub: &'a ServiceDirectory<C>,
6824 _request: TestIamPermissionsRequest,
6825 _resource: String,
6826 _delegate: Option<&'a mut dyn common::Delegate>,
6827 _additional_params: HashMap<String, String>,
6828 _scopes: BTreeSet<String>,
6829}
6830
6831impl<'a, C> common::CallBuilder for ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C> {}
6832
6833impl<'a, C> ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C>
6834where
6835 C: common::Connector,
6836{
6837 /// Perform the operation you have build so far.
6838 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
6839 use std::borrow::Cow;
6840 use std::io::{Read, Seek};
6841
6842 use common::{url::Params, ToParts};
6843 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6844
6845 let mut dd = common::DefaultDelegate;
6846 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6847 dlg.begin(common::MethodInfo {
6848 id: "servicedirectory.projects.locations.namespaces.workloads.testIamPermissions",
6849 http_method: hyper::Method::POST,
6850 });
6851
6852 for &field in ["alt", "resource"].iter() {
6853 if self._additional_params.contains_key(field) {
6854 dlg.finished(false);
6855 return Err(common::Error::FieldClash(field));
6856 }
6857 }
6858
6859 let mut params = Params::with_capacity(4 + self._additional_params.len());
6860 params.push("resource", self._resource);
6861
6862 params.extend(self._additional_params.iter());
6863
6864 params.push("alt", "json");
6865 let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:testIamPermissions";
6866 if self._scopes.is_empty() {
6867 self._scopes
6868 .insert(Scope::CloudPlatform.as_ref().to_string());
6869 }
6870
6871 #[allow(clippy::single_element_loop)]
6872 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6873 url = params.uri_replacement(url, param_name, find_this, true);
6874 }
6875 {
6876 let to_remove = ["resource"];
6877 params.remove_params(&to_remove);
6878 }
6879
6880 let url = params.parse_with_url(&url);
6881
6882 let mut json_mime_type = mime::APPLICATION_JSON;
6883 let mut request_value_reader = {
6884 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6885 common::remove_json_null_values(&mut value);
6886 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6887 serde_json::to_writer(&mut dst, &value).unwrap();
6888 dst
6889 };
6890 let request_size = request_value_reader
6891 .seek(std::io::SeekFrom::End(0))
6892 .unwrap();
6893 request_value_reader
6894 .seek(std::io::SeekFrom::Start(0))
6895 .unwrap();
6896
6897 loop {
6898 let token = match self
6899 .hub
6900 .auth
6901 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6902 .await
6903 {
6904 Ok(token) => token,
6905 Err(e) => match dlg.token(e) {
6906 Ok(token) => token,
6907 Err(e) => {
6908 dlg.finished(false);
6909 return Err(common::Error::MissingToken(e));
6910 }
6911 },
6912 };
6913 request_value_reader
6914 .seek(std::io::SeekFrom::Start(0))
6915 .unwrap();
6916 let mut req_result = {
6917 let client = &self.hub.client;
6918 dlg.pre_request();
6919 let mut req_builder = hyper::Request::builder()
6920 .method(hyper::Method::POST)
6921 .uri(url.as_str())
6922 .header(USER_AGENT, self.hub._user_agent.clone());
6923
6924 if let Some(token) = token.as_ref() {
6925 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6926 }
6927
6928 let request = req_builder
6929 .header(CONTENT_TYPE, json_mime_type.to_string())
6930 .header(CONTENT_LENGTH, request_size as u64)
6931 .body(common::to_body(
6932 request_value_reader.get_ref().clone().into(),
6933 ));
6934
6935 client.request(request.unwrap()).await
6936 };
6937
6938 match req_result {
6939 Err(err) => {
6940 if let common::Retry::After(d) = dlg.http_error(&err) {
6941 sleep(d).await;
6942 continue;
6943 }
6944 dlg.finished(false);
6945 return Err(common::Error::HttpError(err));
6946 }
6947 Ok(res) => {
6948 let (mut parts, body) = res.into_parts();
6949 let mut body = common::Body::new(body);
6950 if !parts.status.is_success() {
6951 let bytes = common::to_bytes(body).await.unwrap_or_default();
6952 let error = serde_json::from_str(&common::to_string(&bytes));
6953 let response = common::to_response(parts, bytes.into());
6954
6955 if let common::Retry::After(d) =
6956 dlg.http_failure(&response, error.as_ref().ok())
6957 {
6958 sleep(d).await;
6959 continue;
6960 }
6961
6962 dlg.finished(false);
6963
6964 return Err(match error {
6965 Ok(value) => common::Error::BadRequest(value),
6966 _ => common::Error::Failure(response),
6967 });
6968 }
6969 let response = {
6970 let bytes = common::to_bytes(body).await.unwrap_or_default();
6971 let encoded = common::to_string(&bytes);
6972 match serde_json::from_str(&encoded) {
6973 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6974 Err(error) => {
6975 dlg.response_json_decode_error(&encoded, &error);
6976 return Err(common::Error::JsonDecodeError(
6977 encoded.to_string(),
6978 error,
6979 ));
6980 }
6981 }
6982 };
6983
6984 dlg.finished(true);
6985 return Ok(response);
6986 }
6987 }
6988 }
6989 }
6990
6991 ///
6992 /// Sets the *request* property to the given value.
6993 ///
6994 /// Even though the property as already been set when instantiating this call,
6995 /// we provide this method for API completeness.
6996 pub fn request(
6997 mut self,
6998 new_value: TestIamPermissionsRequest,
6999 ) -> ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C> {
7000 self._request = new_value;
7001 self
7002 }
7003 /// 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.
7004 ///
7005 /// Sets the *resource* path property to the given value.
7006 ///
7007 /// Even though the property as already been set when instantiating this call,
7008 /// we provide this method for API completeness.
7009 pub fn resource(
7010 mut self,
7011 new_value: &str,
7012 ) -> ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C> {
7013 self._resource = new_value.to_string();
7014 self
7015 }
7016 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7017 /// while executing the actual API request.
7018 ///
7019 /// ````text
7020 /// It should be used to handle progress information, and to implement a certain level of resilience.
7021 /// ````
7022 ///
7023 /// Sets the *delegate* property to the given value.
7024 pub fn delegate(
7025 mut self,
7026 new_value: &'a mut dyn common::Delegate,
7027 ) -> ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C> {
7028 self._delegate = Some(new_value);
7029 self
7030 }
7031
7032 /// Set any additional parameter of the query string used in the request.
7033 /// It should be used to set parameters which are not yet available through their own
7034 /// setters.
7035 ///
7036 /// Please note that this method must not be used to set any of the known parameters
7037 /// which have their own setter method. If done anyway, the request will fail.
7038 ///
7039 /// # Additional Parameters
7040 ///
7041 /// * *$.xgafv* (query-string) - V1 error format.
7042 /// * *access_token* (query-string) - OAuth access token.
7043 /// * *alt* (query-string) - Data format for response.
7044 /// * *callback* (query-string) - JSONP
7045 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7046 /// * *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.
7047 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7048 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7049 /// * *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.
7050 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7051 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7052 pub fn param<T>(
7053 mut self,
7054 name: T,
7055 value: T,
7056 ) -> ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C>
7057 where
7058 T: AsRef<str>,
7059 {
7060 self._additional_params
7061 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7062 self
7063 }
7064
7065 /// Identifies the authorization scope for the method you are building.
7066 ///
7067 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7068 /// [`Scope::CloudPlatform`].
7069 ///
7070 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7071 /// tokens for more than one scope.
7072 ///
7073 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7074 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7075 /// sufficient, a read-write scope will do as well.
7076 pub fn add_scope<St>(
7077 mut self,
7078 scope: St,
7079 ) -> ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C>
7080 where
7081 St: AsRef<str>,
7082 {
7083 self._scopes.insert(String::from(scope.as_ref()));
7084 self
7085 }
7086 /// Identifies the authorization scope(s) for the method you are building.
7087 ///
7088 /// See [`Self::add_scope()`] for details.
7089 pub fn add_scopes<I, St>(
7090 mut self,
7091 scopes: I,
7092 ) -> ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C>
7093 where
7094 I: IntoIterator<Item = St>,
7095 St: AsRef<str>,
7096 {
7097 self._scopes
7098 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7099 self
7100 }
7101
7102 /// Removes all scopes, and no default scope will be used either.
7103 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7104 /// for details).
7105 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceWorkloadTestIamPermissionCall<'a, C> {
7106 self._scopes.clear();
7107 self
7108 }
7109}
7110
7111/// Creates a namespace, and returns the new namespace.
7112///
7113/// A builder for the *locations.namespaces.create* method supported by a *project* resource.
7114/// It is not used directly, but through a [`ProjectMethods`] instance.
7115///
7116/// # Example
7117///
7118/// Instantiate a resource method builder
7119///
7120/// ```test_harness,no_run
7121/// # extern crate hyper;
7122/// # extern crate hyper_rustls;
7123/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
7124/// use servicedirectory1_beta1::api::Namespace;
7125/// # async fn dox() {
7126/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7127///
7128/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7129/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7130/// # .with_native_roots()
7131/// # .unwrap()
7132/// # .https_only()
7133/// # .enable_http2()
7134/// # .build();
7135///
7136/// # let executor = hyper_util::rt::TokioExecutor::new();
7137/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7138/// # secret,
7139/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7140/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7141/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7142/// # ),
7143/// # ).build().await.unwrap();
7144///
7145/// # let client = hyper_util::client::legacy::Client::builder(
7146/// # hyper_util::rt::TokioExecutor::new()
7147/// # )
7148/// # .build(
7149/// # hyper_rustls::HttpsConnectorBuilder::new()
7150/// # .with_native_roots()
7151/// # .unwrap()
7152/// # .https_or_http()
7153/// # .enable_http2()
7154/// # .build()
7155/// # );
7156/// # let mut hub = ServiceDirectory::new(client, auth);
7157/// // As the method needs a request, you would usually fill it with the desired information
7158/// // into the respective structure. Some of the parts shown here might not be applicable !
7159/// // Values shown here are possibly random and not representative !
7160/// let mut req = Namespace::default();
7161///
7162/// // You can configure optional parameters by calling the respective setters at will, and
7163/// // execute the final call using `doit()`.
7164/// // Values shown here are possibly random and not representative !
7165/// let result = hub.projects().locations_namespaces_create(req, "parent")
7166/// .namespace_id("est")
7167/// .doit().await;
7168/// # }
7169/// ```
7170pub struct ProjectLocationNamespaceCreateCall<'a, C>
7171where
7172 C: 'a,
7173{
7174 hub: &'a ServiceDirectory<C>,
7175 _request: Namespace,
7176 _parent: String,
7177 _namespace_id: Option<String>,
7178 _delegate: Option<&'a mut dyn common::Delegate>,
7179 _additional_params: HashMap<String, String>,
7180 _scopes: BTreeSet<String>,
7181}
7182
7183impl<'a, C> common::CallBuilder for ProjectLocationNamespaceCreateCall<'a, C> {}
7184
7185impl<'a, C> ProjectLocationNamespaceCreateCall<'a, C>
7186where
7187 C: common::Connector,
7188{
7189 /// Perform the operation you have build so far.
7190 pub async fn doit(mut self) -> common::Result<(common::Response, Namespace)> {
7191 use std::borrow::Cow;
7192 use std::io::{Read, Seek};
7193
7194 use common::{url::Params, ToParts};
7195 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7196
7197 let mut dd = common::DefaultDelegate;
7198 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7199 dlg.begin(common::MethodInfo {
7200 id: "servicedirectory.projects.locations.namespaces.create",
7201 http_method: hyper::Method::POST,
7202 });
7203
7204 for &field in ["alt", "parent", "namespaceId"].iter() {
7205 if self._additional_params.contains_key(field) {
7206 dlg.finished(false);
7207 return Err(common::Error::FieldClash(field));
7208 }
7209 }
7210
7211 let mut params = Params::with_capacity(5 + self._additional_params.len());
7212 params.push("parent", self._parent);
7213 if let Some(value) = self._namespace_id.as_ref() {
7214 params.push("namespaceId", value);
7215 }
7216
7217 params.extend(self._additional_params.iter());
7218
7219 params.push("alt", "json");
7220 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/namespaces";
7221 if self._scopes.is_empty() {
7222 self._scopes
7223 .insert(Scope::CloudPlatform.as_ref().to_string());
7224 }
7225
7226 #[allow(clippy::single_element_loop)]
7227 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7228 url = params.uri_replacement(url, param_name, find_this, true);
7229 }
7230 {
7231 let to_remove = ["parent"];
7232 params.remove_params(&to_remove);
7233 }
7234
7235 let url = params.parse_with_url(&url);
7236
7237 let mut json_mime_type = mime::APPLICATION_JSON;
7238 let mut request_value_reader = {
7239 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7240 common::remove_json_null_values(&mut value);
7241 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7242 serde_json::to_writer(&mut dst, &value).unwrap();
7243 dst
7244 };
7245 let request_size = request_value_reader
7246 .seek(std::io::SeekFrom::End(0))
7247 .unwrap();
7248 request_value_reader
7249 .seek(std::io::SeekFrom::Start(0))
7250 .unwrap();
7251
7252 loop {
7253 let token = match self
7254 .hub
7255 .auth
7256 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7257 .await
7258 {
7259 Ok(token) => token,
7260 Err(e) => match dlg.token(e) {
7261 Ok(token) => token,
7262 Err(e) => {
7263 dlg.finished(false);
7264 return Err(common::Error::MissingToken(e));
7265 }
7266 },
7267 };
7268 request_value_reader
7269 .seek(std::io::SeekFrom::Start(0))
7270 .unwrap();
7271 let mut req_result = {
7272 let client = &self.hub.client;
7273 dlg.pre_request();
7274 let mut req_builder = hyper::Request::builder()
7275 .method(hyper::Method::POST)
7276 .uri(url.as_str())
7277 .header(USER_AGENT, self.hub._user_agent.clone());
7278
7279 if let Some(token) = token.as_ref() {
7280 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7281 }
7282
7283 let request = req_builder
7284 .header(CONTENT_TYPE, json_mime_type.to_string())
7285 .header(CONTENT_LENGTH, request_size as u64)
7286 .body(common::to_body(
7287 request_value_reader.get_ref().clone().into(),
7288 ));
7289
7290 client.request(request.unwrap()).await
7291 };
7292
7293 match req_result {
7294 Err(err) => {
7295 if let common::Retry::After(d) = dlg.http_error(&err) {
7296 sleep(d).await;
7297 continue;
7298 }
7299 dlg.finished(false);
7300 return Err(common::Error::HttpError(err));
7301 }
7302 Ok(res) => {
7303 let (mut parts, body) = res.into_parts();
7304 let mut body = common::Body::new(body);
7305 if !parts.status.is_success() {
7306 let bytes = common::to_bytes(body).await.unwrap_or_default();
7307 let error = serde_json::from_str(&common::to_string(&bytes));
7308 let response = common::to_response(parts, bytes.into());
7309
7310 if let common::Retry::After(d) =
7311 dlg.http_failure(&response, error.as_ref().ok())
7312 {
7313 sleep(d).await;
7314 continue;
7315 }
7316
7317 dlg.finished(false);
7318
7319 return Err(match error {
7320 Ok(value) => common::Error::BadRequest(value),
7321 _ => common::Error::Failure(response),
7322 });
7323 }
7324 let response = {
7325 let bytes = common::to_bytes(body).await.unwrap_or_default();
7326 let encoded = common::to_string(&bytes);
7327 match serde_json::from_str(&encoded) {
7328 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7329 Err(error) => {
7330 dlg.response_json_decode_error(&encoded, &error);
7331 return Err(common::Error::JsonDecodeError(
7332 encoded.to_string(),
7333 error,
7334 ));
7335 }
7336 }
7337 };
7338
7339 dlg.finished(true);
7340 return Ok(response);
7341 }
7342 }
7343 }
7344 }
7345
7346 ///
7347 /// Sets the *request* property to the given value.
7348 ///
7349 /// Even though the property as already been set when instantiating this call,
7350 /// we provide this method for API completeness.
7351 pub fn request(mut self, new_value: Namespace) -> ProjectLocationNamespaceCreateCall<'a, C> {
7352 self._request = new_value;
7353 self
7354 }
7355 /// Required. The resource name of the project and location the namespace will be created in.
7356 ///
7357 /// Sets the *parent* path property to the given value.
7358 ///
7359 /// Even though the property as already been set when instantiating this call,
7360 /// we provide this method for API completeness.
7361 pub fn parent(mut self, new_value: &str) -> ProjectLocationNamespaceCreateCall<'a, C> {
7362 self._parent = new_value.to_string();
7363 self
7364 }
7365 /// Required. The Resource ID must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
7366 ///
7367 /// Sets the *namespace id* query property to the given value.
7368 pub fn namespace_id(mut self, new_value: &str) -> ProjectLocationNamespaceCreateCall<'a, C> {
7369 self._namespace_id = Some(new_value.to_string());
7370 self
7371 }
7372 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7373 /// while executing the actual API request.
7374 ///
7375 /// ````text
7376 /// It should be used to handle progress information, and to implement a certain level of resilience.
7377 /// ````
7378 ///
7379 /// Sets the *delegate* property to the given value.
7380 pub fn delegate(
7381 mut self,
7382 new_value: &'a mut dyn common::Delegate,
7383 ) -> ProjectLocationNamespaceCreateCall<'a, C> {
7384 self._delegate = Some(new_value);
7385 self
7386 }
7387
7388 /// Set any additional parameter of the query string used in the request.
7389 /// It should be used to set parameters which are not yet available through their own
7390 /// setters.
7391 ///
7392 /// Please note that this method must not be used to set any of the known parameters
7393 /// which have their own setter method. If done anyway, the request will fail.
7394 ///
7395 /// # Additional Parameters
7396 ///
7397 /// * *$.xgafv* (query-string) - V1 error format.
7398 /// * *access_token* (query-string) - OAuth access token.
7399 /// * *alt* (query-string) - Data format for response.
7400 /// * *callback* (query-string) - JSONP
7401 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7402 /// * *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.
7403 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7404 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7405 /// * *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.
7406 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7407 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7408 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceCreateCall<'a, C>
7409 where
7410 T: AsRef<str>,
7411 {
7412 self._additional_params
7413 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7414 self
7415 }
7416
7417 /// Identifies the authorization scope for the method you are building.
7418 ///
7419 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7420 /// [`Scope::CloudPlatform`].
7421 ///
7422 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7423 /// tokens for more than one scope.
7424 ///
7425 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7426 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7427 /// sufficient, a read-write scope will do as well.
7428 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceCreateCall<'a, C>
7429 where
7430 St: AsRef<str>,
7431 {
7432 self._scopes.insert(String::from(scope.as_ref()));
7433 self
7434 }
7435 /// Identifies the authorization scope(s) for the method you are building.
7436 ///
7437 /// See [`Self::add_scope()`] for details.
7438 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespaceCreateCall<'a, C>
7439 where
7440 I: IntoIterator<Item = St>,
7441 St: AsRef<str>,
7442 {
7443 self._scopes
7444 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7445 self
7446 }
7447
7448 /// Removes all scopes, and no default scope will be used either.
7449 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7450 /// for details).
7451 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceCreateCall<'a, C> {
7452 self._scopes.clear();
7453 self
7454 }
7455}
7456
7457/// Deletes a namespace. This also deletes all services and endpoints in the namespace.
7458///
7459/// A builder for the *locations.namespaces.delete* method supported by a *project* resource.
7460/// It is not used directly, but through a [`ProjectMethods`] instance.
7461///
7462/// # Example
7463///
7464/// Instantiate a resource method builder
7465///
7466/// ```test_harness,no_run
7467/// # extern crate hyper;
7468/// # extern crate hyper_rustls;
7469/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
7470/// # async fn dox() {
7471/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7472///
7473/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7474/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7475/// # .with_native_roots()
7476/// # .unwrap()
7477/// # .https_only()
7478/// # .enable_http2()
7479/// # .build();
7480///
7481/// # let executor = hyper_util::rt::TokioExecutor::new();
7482/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7483/// # secret,
7484/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7485/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7486/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7487/// # ),
7488/// # ).build().await.unwrap();
7489///
7490/// # let client = hyper_util::client::legacy::Client::builder(
7491/// # hyper_util::rt::TokioExecutor::new()
7492/// # )
7493/// # .build(
7494/// # hyper_rustls::HttpsConnectorBuilder::new()
7495/// # .with_native_roots()
7496/// # .unwrap()
7497/// # .https_or_http()
7498/// # .enable_http2()
7499/// # .build()
7500/// # );
7501/// # let mut hub = ServiceDirectory::new(client, auth);
7502/// // You can configure optional parameters by calling the respective setters at will, and
7503/// // execute the final call using `doit()`.
7504/// // Values shown here are possibly random and not representative !
7505/// let result = hub.projects().locations_namespaces_delete("name")
7506/// .doit().await;
7507/// # }
7508/// ```
7509pub struct ProjectLocationNamespaceDeleteCall<'a, C>
7510where
7511 C: 'a,
7512{
7513 hub: &'a ServiceDirectory<C>,
7514 _name: String,
7515 _delegate: Option<&'a mut dyn common::Delegate>,
7516 _additional_params: HashMap<String, String>,
7517 _scopes: BTreeSet<String>,
7518}
7519
7520impl<'a, C> common::CallBuilder for ProjectLocationNamespaceDeleteCall<'a, C> {}
7521
7522impl<'a, C> ProjectLocationNamespaceDeleteCall<'a, C>
7523where
7524 C: common::Connector,
7525{
7526 /// Perform the operation you have build so far.
7527 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7528 use std::borrow::Cow;
7529 use std::io::{Read, Seek};
7530
7531 use common::{url::Params, ToParts};
7532 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7533
7534 let mut dd = common::DefaultDelegate;
7535 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7536 dlg.begin(common::MethodInfo {
7537 id: "servicedirectory.projects.locations.namespaces.delete",
7538 http_method: hyper::Method::DELETE,
7539 });
7540
7541 for &field in ["alt", "name"].iter() {
7542 if self._additional_params.contains_key(field) {
7543 dlg.finished(false);
7544 return Err(common::Error::FieldClash(field));
7545 }
7546 }
7547
7548 let mut params = Params::with_capacity(3 + self._additional_params.len());
7549 params.push("name", self._name);
7550
7551 params.extend(self._additional_params.iter());
7552
7553 params.push("alt", "json");
7554 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
7555 if self._scopes.is_empty() {
7556 self._scopes
7557 .insert(Scope::CloudPlatform.as_ref().to_string());
7558 }
7559
7560 #[allow(clippy::single_element_loop)]
7561 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7562 url = params.uri_replacement(url, param_name, find_this, true);
7563 }
7564 {
7565 let to_remove = ["name"];
7566 params.remove_params(&to_remove);
7567 }
7568
7569 let url = params.parse_with_url(&url);
7570
7571 loop {
7572 let token = match self
7573 .hub
7574 .auth
7575 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7576 .await
7577 {
7578 Ok(token) => token,
7579 Err(e) => match dlg.token(e) {
7580 Ok(token) => token,
7581 Err(e) => {
7582 dlg.finished(false);
7583 return Err(common::Error::MissingToken(e));
7584 }
7585 },
7586 };
7587 let mut req_result = {
7588 let client = &self.hub.client;
7589 dlg.pre_request();
7590 let mut req_builder = hyper::Request::builder()
7591 .method(hyper::Method::DELETE)
7592 .uri(url.as_str())
7593 .header(USER_AGENT, self.hub._user_agent.clone());
7594
7595 if let Some(token) = token.as_ref() {
7596 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7597 }
7598
7599 let request = req_builder
7600 .header(CONTENT_LENGTH, 0_u64)
7601 .body(common::to_body::<String>(None));
7602
7603 client.request(request.unwrap()).await
7604 };
7605
7606 match req_result {
7607 Err(err) => {
7608 if let common::Retry::After(d) = dlg.http_error(&err) {
7609 sleep(d).await;
7610 continue;
7611 }
7612 dlg.finished(false);
7613 return Err(common::Error::HttpError(err));
7614 }
7615 Ok(res) => {
7616 let (mut parts, body) = res.into_parts();
7617 let mut body = common::Body::new(body);
7618 if !parts.status.is_success() {
7619 let bytes = common::to_bytes(body).await.unwrap_or_default();
7620 let error = serde_json::from_str(&common::to_string(&bytes));
7621 let response = common::to_response(parts, bytes.into());
7622
7623 if let common::Retry::After(d) =
7624 dlg.http_failure(&response, error.as_ref().ok())
7625 {
7626 sleep(d).await;
7627 continue;
7628 }
7629
7630 dlg.finished(false);
7631
7632 return Err(match error {
7633 Ok(value) => common::Error::BadRequest(value),
7634 _ => common::Error::Failure(response),
7635 });
7636 }
7637 let response = {
7638 let bytes = common::to_bytes(body).await.unwrap_or_default();
7639 let encoded = common::to_string(&bytes);
7640 match serde_json::from_str(&encoded) {
7641 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7642 Err(error) => {
7643 dlg.response_json_decode_error(&encoded, &error);
7644 return Err(common::Error::JsonDecodeError(
7645 encoded.to_string(),
7646 error,
7647 ));
7648 }
7649 }
7650 };
7651
7652 dlg.finished(true);
7653 return Ok(response);
7654 }
7655 }
7656 }
7657 }
7658
7659 /// Required. The name of the namespace to delete.
7660 ///
7661 /// Sets the *name* path property to the given value.
7662 ///
7663 /// Even though the property as already been set when instantiating this call,
7664 /// we provide this method for API completeness.
7665 pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceDeleteCall<'a, C> {
7666 self._name = new_value.to_string();
7667 self
7668 }
7669 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7670 /// while executing the actual API request.
7671 ///
7672 /// ````text
7673 /// It should be used to handle progress information, and to implement a certain level of resilience.
7674 /// ````
7675 ///
7676 /// Sets the *delegate* property to the given value.
7677 pub fn delegate(
7678 mut self,
7679 new_value: &'a mut dyn common::Delegate,
7680 ) -> ProjectLocationNamespaceDeleteCall<'a, C> {
7681 self._delegate = Some(new_value);
7682 self
7683 }
7684
7685 /// Set any additional parameter of the query string used in the request.
7686 /// It should be used to set parameters which are not yet available through their own
7687 /// setters.
7688 ///
7689 /// Please note that this method must not be used to set any of the known parameters
7690 /// which have their own setter method. If done anyway, the request will fail.
7691 ///
7692 /// # Additional Parameters
7693 ///
7694 /// * *$.xgafv* (query-string) - V1 error format.
7695 /// * *access_token* (query-string) - OAuth access token.
7696 /// * *alt* (query-string) - Data format for response.
7697 /// * *callback* (query-string) - JSONP
7698 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7699 /// * *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.
7700 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7701 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7702 /// * *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.
7703 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7704 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7705 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceDeleteCall<'a, C>
7706 where
7707 T: AsRef<str>,
7708 {
7709 self._additional_params
7710 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7711 self
7712 }
7713
7714 /// Identifies the authorization scope for the method you are building.
7715 ///
7716 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7717 /// [`Scope::CloudPlatform`].
7718 ///
7719 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7720 /// tokens for more than one scope.
7721 ///
7722 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7723 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7724 /// sufficient, a read-write scope will do as well.
7725 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceDeleteCall<'a, C>
7726 where
7727 St: AsRef<str>,
7728 {
7729 self._scopes.insert(String::from(scope.as_ref()));
7730 self
7731 }
7732 /// Identifies the authorization scope(s) for the method you are building.
7733 ///
7734 /// See [`Self::add_scope()`] for details.
7735 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespaceDeleteCall<'a, C>
7736 where
7737 I: IntoIterator<Item = St>,
7738 St: AsRef<str>,
7739 {
7740 self._scopes
7741 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7742 self
7743 }
7744
7745 /// Removes all scopes, and no default scope will be used either.
7746 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7747 /// for details).
7748 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceDeleteCall<'a, C> {
7749 self._scopes.clear();
7750 self
7751 }
7752}
7753
7754/// Gets a namespace.
7755///
7756/// A builder for the *locations.namespaces.get* method supported by a *project* resource.
7757/// It is not used directly, but through a [`ProjectMethods`] instance.
7758///
7759/// # Example
7760///
7761/// Instantiate a resource method builder
7762///
7763/// ```test_harness,no_run
7764/// # extern crate hyper;
7765/// # extern crate hyper_rustls;
7766/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
7767/// # async fn dox() {
7768/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7769///
7770/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7771/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7772/// # .with_native_roots()
7773/// # .unwrap()
7774/// # .https_only()
7775/// # .enable_http2()
7776/// # .build();
7777///
7778/// # let executor = hyper_util::rt::TokioExecutor::new();
7779/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7780/// # secret,
7781/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7782/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7783/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7784/// # ),
7785/// # ).build().await.unwrap();
7786///
7787/// # let client = hyper_util::client::legacy::Client::builder(
7788/// # hyper_util::rt::TokioExecutor::new()
7789/// # )
7790/// # .build(
7791/// # hyper_rustls::HttpsConnectorBuilder::new()
7792/// # .with_native_roots()
7793/// # .unwrap()
7794/// # .https_or_http()
7795/// # .enable_http2()
7796/// # .build()
7797/// # );
7798/// # let mut hub = ServiceDirectory::new(client, auth);
7799/// // You can configure optional parameters by calling the respective setters at will, and
7800/// // execute the final call using `doit()`.
7801/// // Values shown here are possibly random and not representative !
7802/// let result = hub.projects().locations_namespaces_get("name")
7803/// .doit().await;
7804/// # }
7805/// ```
7806pub struct ProjectLocationNamespaceGetCall<'a, C>
7807where
7808 C: 'a,
7809{
7810 hub: &'a ServiceDirectory<C>,
7811 _name: String,
7812 _delegate: Option<&'a mut dyn common::Delegate>,
7813 _additional_params: HashMap<String, String>,
7814 _scopes: BTreeSet<String>,
7815}
7816
7817impl<'a, C> common::CallBuilder for ProjectLocationNamespaceGetCall<'a, C> {}
7818
7819impl<'a, C> ProjectLocationNamespaceGetCall<'a, C>
7820where
7821 C: common::Connector,
7822{
7823 /// Perform the operation you have build so far.
7824 pub async fn doit(mut self) -> common::Result<(common::Response, Namespace)> {
7825 use std::borrow::Cow;
7826 use std::io::{Read, Seek};
7827
7828 use common::{url::Params, ToParts};
7829 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7830
7831 let mut dd = common::DefaultDelegate;
7832 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7833 dlg.begin(common::MethodInfo {
7834 id: "servicedirectory.projects.locations.namespaces.get",
7835 http_method: hyper::Method::GET,
7836 });
7837
7838 for &field in ["alt", "name"].iter() {
7839 if self._additional_params.contains_key(field) {
7840 dlg.finished(false);
7841 return Err(common::Error::FieldClash(field));
7842 }
7843 }
7844
7845 let mut params = Params::with_capacity(3 + self._additional_params.len());
7846 params.push("name", self._name);
7847
7848 params.extend(self._additional_params.iter());
7849
7850 params.push("alt", "json");
7851 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
7852 if self._scopes.is_empty() {
7853 self._scopes
7854 .insert(Scope::CloudPlatform.as_ref().to_string());
7855 }
7856
7857 #[allow(clippy::single_element_loop)]
7858 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7859 url = params.uri_replacement(url, param_name, find_this, true);
7860 }
7861 {
7862 let to_remove = ["name"];
7863 params.remove_params(&to_remove);
7864 }
7865
7866 let url = params.parse_with_url(&url);
7867
7868 loop {
7869 let token = match self
7870 .hub
7871 .auth
7872 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7873 .await
7874 {
7875 Ok(token) => token,
7876 Err(e) => match dlg.token(e) {
7877 Ok(token) => token,
7878 Err(e) => {
7879 dlg.finished(false);
7880 return Err(common::Error::MissingToken(e));
7881 }
7882 },
7883 };
7884 let mut req_result = {
7885 let client = &self.hub.client;
7886 dlg.pre_request();
7887 let mut req_builder = hyper::Request::builder()
7888 .method(hyper::Method::GET)
7889 .uri(url.as_str())
7890 .header(USER_AGENT, self.hub._user_agent.clone());
7891
7892 if let Some(token) = token.as_ref() {
7893 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7894 }
7895
7896 let request = req_builder
7897 .header(CONTENT_LENGTH, 0_u64)
7898 .body(common::to_body::<String>(None));
7899
7900 client.request(request.unwrap()).await
7901 };
7902
7903 match req_result {
7904 Err(err) => {
7905 if let common::Retry::After(d) = dlg.http_error(&err) {
7906 sleep(d).await;
7907 continue;
7908 }
7909 dlg.finished(false);
7910 return Err(common::Error::HttpError(err));
7911 }
7912 Ok(res) => {
7913 let (mut parts, body) = res.into_parts();
7914 let mut body = common::Body::new(body);
7915 if !parts.status.is_success() {
7916 let bytes = common::to_bytes(body).await.unwrap_or_default();
7917 let error = serde_json::from_str(&common::to_string(&bytes));
7918 let response = common::to_response(parts, bytes.into());
7919
7920 if let common::Retry::After(d) =
7921 dlg.http_failure(&response, error.as_ref().ok())
7922 {
7923 sleep(d).await;
7924 continue;
7925 }
7926
7927 dlg.finished(false);
7928
7929 return Err(match error {
7930 Ok(value) => common::Error::BadRequest(value),
7931 _ => common::Error::Failure(response),
7932 });
7933 }
7934 let response = {
7935 let bytes = common::to_bytes(body).await.unwrap_or_default();
7936 let encoded = common::to_string(&bytes);
7937 match serde_json::from_str(&encoded) {
7938 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7939 Err(error) => {
7940 dlg.response_json_decode_error(&encoded, &error);
7941 return Err(common::Error::JsonDecodeError(
7942 encoded.to_string(),
7943 error,
7944 ));
7945 }
7946 }
7947 };
7948
7949 dlg.finished(true);
7950 return Ok(response);
7951 }
7952 }
7953 }
7954 }
7955
7956 /// Required. The name of the namespace to retrieve.
7957 ///
7958 /// Sets the *name* path property to the given value.
7959 ///
7960 /// Even though the property as already been set when instantiating this call,
7961 /// we provide this method for API completeness.
7962 pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceGetCall<'a, C> {
7963 self._name = new_value.to_string();
7964 self
7965 }
7966 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7967 /// while executing the actual API request.
7968 ///
7969 /// ````text
7970 /// It should be used to handle progress information, and to implement a certain level of resilience.
7971 /// ````
7972 ///
7973 /// Sets the *delegate* property to the given value.
7974 pub fn delegate(
7975 mut self,
7976 new_value: &'a mut dyn common::Delegate,
7977 ) -> ProjectLocationNamespaceGetCall<'a, C> {
7978 self._delegate = Some(new_value);
7979 self
7980 }
7981
7982 /// Set any additional parameter of the query string used in the request.
7983 /// It should be used to set parameters which are not yet available through their own
7984 /// setters.
7985 ///
7986 /// Please note that this method must not be used to set any of the known parameters
7987 /// which have their own setter method. If done anyway, the request will fail.
7988 ///
7989 /// # Additional Parameters
7990 ///
7991 /// * *$.xgafv* (query-string) - V1 error format.
7992 /// * *access_token* (query-string) - OAuth access token.
7993 /// * *alt* (query-string) - Data format for response.
7994 /// * *callback* (query-string) - JSONP
7995 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7996 /// * *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.
7997 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7998 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7999 /// * *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.
8000 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8001 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8002 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceGetCall<'a, C>
8003 where
8004 T: AsRef<str>,
8005 {
8006 self._additional_params
8007 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8008 self
8009 }
8010
8011 /// Identifies the authorization scope for the method you are building.
8012 ///
8013 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8014 /// [`Scope::CloudPlatform`].
8015 ///
8016 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8017 /// tokens for more than one scope.
8018 ///
8019 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8020 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8021 /// sufficient, a read-write scope will do as well.
8022 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceGetCall<'a, C>
8023 where
8024 St: AsRef<str>,
8025 {
8026 self._scopes.insert(String::from(scope.as_ref()));
8027 self
8028 }
8029 /// Identifies the authorization scope(s) for the method you are building.
8030 ///
8031 /// See [`Self::add_scope()`] for details.
8032 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespaceGetCall<'a, C>
8033 where
8034 I: IntoIterator<Item = St>,
8035 St: AsRef<str>,
8036 {
8037 self._scopes
8038 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8039 self
8040 }
8041
8042 /// Removes all scopes, and no default scope will be used either.
8043 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8044 /// for details).
8045 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceGetCall<'a, C> {
8046 self._scopes.clear();
8047 self
8048 }
8049}
8050
8051/// Gets the IAM Policy for a resource
8052///
8053/// A builder for the *locations.namespaces.getIamPolicy* method supported by a *project* resource.
8054/// It is not used directly, but through a [`ProjectMethods`] instance.
8055///
8056/// # Example
8057///
8058/// Instantiate a resource method builder
8059///
8060/// ```test_harness,no_run
8061/// # extern crate hyper;
8062/// # extern crate hyper_rustls;
8063/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
8064/// use servicedirectory1_beta1::api::GetIamPolicyRequest;
8065/// # async fn dox() {
8066/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8067///
8068/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8069/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8070/// # .with_native_roots()
8071/// # .unwrap()
8072/// # .https_only()
8073/// # .enable_http2()
8074/// # .build();
8075///
8076/// # let executor = hyper_util::rt::TokioExecutor::new();
8077/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8078/// # secret,
8079/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8080/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8081/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8082/// # ),
8083/// # ).build().await.unwrap();
8084///
8085/// # let client = hyper_util::client::legacy::Client::builder(
8086/// # hyper_util::rt::TokioExecutor::new()
8087/// # )
8088/// # .build(
8089/// # hyper_rustls::HttpsConnectorBuilder::new()
8090/// # .with_native_roots()
8091/// # .unwrap()
8092/// # .https_or_http()
8093/// # .enable_http2()
8094/// # .build()
8095/// # );
8096/// # let mut hub = ServiceDirectory::new(client, auth);
8097/// // As the method needs a request, you would usually fill it with the desired information
8098/// // into the respective structure. Some of the parts shown here might not be applicable !
8099/// // Values shown here are possibly random and not representative !
8100/// let mut req = GetIamPolicyRequest::default();
8101///
8102/// // You can configure optional parameters by calling the respective setters at will, and
8103/// // execute the final call using `doit()`.
8104/// // Values shown here are possibly random and not representative !
8105/// let result = hub.projects().locations_namespaces_get_iam_policy(req, "resource")
8106/// .doit().await;
8107/// # }
8108/// ```
8109pub struct ProjectLocationNamespaceGetIamPolicyCall<'a, C>
8110where
8111 C: 'a,
8112{
8113 hub: &'a ServiceDirectory<C>,
8114 _request: GetIamPolicyRequest,
8115 _resource: String,
8116 _delegate: Option<&'a mut dyn common::Delegate>,
8117 _additional_params: HashMap<String, String>,
8118 _scopes: BTreeSet<String>,
8119}
8120
8121impl<'a, C> common::CallBuilder for ProjectLocationNamespaceGetIamPolicyCall<'a, C> {}
8122
8123impl<'a, C> ProjectLocationNamespaceGetIamPolicyCall<'a, C>
8124where
8125 C: common::Connector,
8126{
8127 /// Perform the operation you have build so far.
8128 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8129 use std::borrow::Cow;
8130 use std::io::{Read, Seek};
8131
8132 use common::{url::Params, ToParts};
8133 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8134
8135 let mut dd = common::DefaultDelegate;
8136 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8137 dlg.begin(common::MethodInfo {
8138 id: "servicedirectory.projects.locations.namespaces.getIamPolicy",
8139 http_method: hyper::Method::POST,
8140 });
8141
8142 for &field in ["alt", "resource"].iter() {
8143 if self._additional_params.contains_key(field) {
8144 dlg.finished(false);
8145 return Err(common::Error::FieldClash(field));
8146 }
8147 }
8148
8149 let mut params = Params::with_capacity(4 + self._additional_params.len());
8150 params.push("resource", self._resource);
8151
8152 params.extend(self._additional_params.iter());
8153
8154 params.push("alt", "json");
8155 let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:getIamPolicy";
8156 if self._scopes.is_empty() {
8157 self._scopes
8158 .insert(Scope::CloudPlatform.as_ref().to_string());
8159 }
8160
8161 #[allow(clippy::single_element_loop)]
8162 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8163 url = params.uri_replacement(url, param_name, find_this, true);
8164 }
8165 {
8166 let to_remove = ["resource"];
8167 params.remove_params(&to_remove);
8168 }
8169
8170 let url = params.parse_with_url(&url);
8171
8172 let mut json_mime_type = mime::APPLICATION_JSON;
8173 let mut request_value_reader = {
8174 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8175 common::remove_json_null_values(&mut value);
8176 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8177 serde_json::to_writer(&mut dst, &value).unwrap();
8178 dst
8179 };
8180 let request_size = request_value_reader
8181 .seek(std::io::SeekFrom::End(0))
8182 .unwrap();
8183 request_value_reader
8184 .seek(std::io::SeekFrom::Start(0))
8185 .unwrap();
8186
8187 loop {
8188 let token = match self
8189 .hub
8190 .auth
8191 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8192 .await
8193 {
8194 Ok(token) => token,
8195 Err(e) => match dlg.token(e) {
8196 Ok(token) => token,
8197 Err(e) => {
8198 dlg.finished(false);
8199 return Err(common::Error::MissingToken(e));
8200 }
8201 },
8202 };
8203 request_value_reader
8204 .seek(std::io::SeekFrom::Start(0))
8205 .unwrap();
8206 let mut req_result = {
8207 let client = &self.hub.client;
8208 dlg.pre_request();
8209 let mut req_builder = hyper::Request::builder()
8210 .method(hyper::Method::POST)
8211 .uri(url.as_str())
8212 .header(USER_AGENT, self.hub._user_agent.clone());
8213
8214 if let Some(token) = token.as_ref() {
8215 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8216 }
8217
8218 let request = req_builder
8219 .header(CONTENT_TYPE, json_mime_type.to_string())
8220 .header(CONTENT_LENGTH, request_size as u64)
8221 .body(common::to_body(
8222 request_value_reader.get_ref().clone().into(),
8223 ));
8224
8225 client.request(request.unwrap()).await
8226 };
8227
8228 match req_result {
8229 Err(err) => {
8230 if let common::Retry::After(d) = dlg.http_error(&err) {
8231 sleep(d).await;
8232 continue;
8233 }
8234 dlg.finished(false);
8235 return Err(common::Error::HttpError(err));
8236 }
8237 Ok(res) => {
8238 let (mut parts, body) = res.into_parts();
8239 let mut body = common::Body::new(body);
8240 if !parts.status.is_success() {
8241 let bytes = common::to_bytes(body).await.unwrap_or_default();
8242 let error = serde_json::from_str(&common::to_string(&bytes));
8243 let response = common::to_response(parts, bytes.into());
8244
8245 if let common::Retry::After(d) =
8246 dlg.http_failure(&response, error.as_ref().ok())
8247 {
8248 sleep(d).await;
8249 continue;
8250 }
8251
8252 dlg.finished(false);
8253
8254 return Err(match error {
8255 Ok(value) => common::Error::BadRequest(value),
8256 _ => common::Error::Failure(response),
8257 });
8258 }
8259 let response = {
8260 let bytes = common::to_bytes(body).await.unwrap_or_default();
8261 let encoded = common::to_string(&bytes);
8262 match serde_json::from_str(&encoded) {
8263 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8264 Err(error) => {
8265 dlg.response_json_decode_error(&encoded, &error);
8266 return Err(common::Error::JsonDecodeError(
8267 encoded.to_string(),
8268 error,
8269 ));
8270 }
8271 }
8272 };
8273
8274 dlg.finished(true);
8275 return Ok(response);
8276 }
8277 }
8278 }
8279 }
8280
8281 ///
8282 /// Sets the *request* property to the given value.
8283 ///
8284 /// Even though the property as already been set when instantiating this call,
8285 /// we provide this method for API completeness.
8286 pub fn request(
8287 mut self,
8288 new_value: GetIamPolicyRequest,
8289 ) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> {
8290 self._request = new_value;
8291 self
8292 }
8293 /// 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.
8294 ///
8295 /// Sets the *resource* path property to the given value.
8296 ///
8297 /// Even though the property as already been set when instantiating this call,
8298 /// we provide this method for API completeness.
8299 pub fn resource(mut self, new_value: &str) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> {
8300 self._resource = new_value.to_string();
8301 self
8302 }
8303 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8304 /// while executing the actual API request.
8305 ///
8306 /// ````text
8307 /// It should be used to handle progress information, and to implement a certain level of resilience.
8308 /// ````
8309 ///
8310 /// Sets the *delegate* property to the given value.
8311 pub fn delegate(
8312 mut self,
8313 new_value: &'a mut dyn common::Delegate,
8314 ) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> {
8315 self._delegate = Some(new_value);
8316 self
8317 }
8318
8319 /// Set any additional parameter of the query string used in the request.
8320 /// It should be used to set parameters which are not yet available through their own
8321 /// setters.
8322 ///
8323 /// Please note that this method must not be used to set any of the known parameters
8324 /// which have their own setter method. If done anyway, the request will fail.
8325 ///
8326 /// # Additional Parameters
8327 ///
8328 /// * *$.xgafv* (query-string) - V1 error format.
8329 /// * *access_token* (query-string) - OAuth access token.
8330 /// * *alt* (query-string) - Data format for response.
8331 /// * *callback* (query-string) - JSONP
8332 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8333 /// * *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.
8334 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8335 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8336 /// * *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.
8337 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8338 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8339 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C>
8340 where
8341 T: AsRef<str>,
8342 {
8343 self._additional_params
8344 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8345 self
8346 }
8347
8348 /// Identifies the authorization scope for the method you are building.
8349 ///
8350 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8351 /// [`Scope::CloudPlatform`].
8352 ///
8353 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8354 /// tokens for more than one scope.
8355 ///
8356 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8357 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8358 /// sufficient, a read-write scope will do as well.
8359 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C>
8360 where
8361 St: AsRef<str>,
8362 {
8363 self._scopes.insert(String::from(scope.as_ref()));
8364 self
8365 }
8366 /// Identifies the authorization scope(s) for the method you are building.
8367 ///
8368 /// See [`Self::add_scope()`] for details.
8369 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C>
8370 where
8371 I: IntoIterator<Item = St>,
8372 St: AsRef<str>,
8373 {
8374 self._scopes
8375 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8376 self
8377 }
8378
8379 /// Removes all scopes, and no default scope will be used either.
8380 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8381 /// for details).
8382 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> {
8383 self._scopes.clear();
8384 self
8385 }
8386}
8387
8388/// Lists all namespaces.
8389///
8390/// A builder for the *locations.namespaces.list* method supported by a *project* resource.
8391/// It is not used directly, but through a [`ProjectMethods`] instance.
8392///
8393/// # Example
8394///
8395/// Instantiate a resource method builder
8396///
8397/// ```test_harness,no_run
8398/// # extern crate hyper;
8399/// # extern crate hyper_rustls;
8400/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
8401/// # async fn dox() {
8402/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8403///
8404/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8405/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8406/// # .with_native_roots()
8407/// # .unwrap()
8408/// # .https_only()
8409/// # .enable_http2()
8410/// # .build();
8411///
8412/// # let executor = hyper_util::rt::TokioExecutor::new();
8413/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8414/// # secret,
8415/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8416/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8417/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8418/// # ),
8419/// # ).build().await.unwrap();
8420///
8421/// # let client = hyper_util::client::legacy::Client::builder(
8422/// # hyper_util::rt::TokioExecutor::new()
8423/// # )
8424/// # .build(
8425/// # hyper_rustls::HttpsConnectorBuilder::new()
8426/// # .with_native_roots()
8427/// # .unwrap()
8428/// # .https_or_http()
8429/// # .enable_http2()
8430/// # .build()
8431/// # );
8432/// # let mut hub = ServiceDirectory::new(client, auth);
8433/// // You can configure optional parameters by calling the respective setters at will, and
8434/// // execute the final call using `doit()`.
8435/// // Values shown here are possibly random and not representative !
8436/// let result = hub.projects().locations_namespaces_list("parent")
8437/// .page_token("eos")
8438/// .page_size(-86)
8439/// .order_by("sed")
8440/// .filter("duo")
8441/// .doit().await;
8442/// # }
8443/// ```
8444pub struct ProjectLocationNamespaceListCall<'a, C>
8445where
8446 C: 'a,
8447{
8448 hub: &'a ServiceDirectory<C>,
8449 _parent: String,
8450 _page_token: Option<String>,
8451 _page_size: Option<i32>,
8452 _order_by: Option<String>,
8453 _filter: Option<String>,
8454 _delegate: Option<&'a mut dyn common::Delegate>,
8455 _additional_params: HashMap<String, String>,
8456 _scopes: BTreeSet<String>,
8457}
8458
8459impl<'a, C> common::CallBuilder for ProjectLocationNamespaceListCall<'a, C> {}
8460
8461impl<'a, C> ProjectLocationNamespaceListCall<'a, C>
8462where
8463 C: common::Connector,
8464{
8465 /// Perform the operation you have build so far.
8466 pub async fn doit(mut self) -> common::Result<(common::Response, ListNamespacesResponse)> {
8467 use std::borrow::Cow;
8468 use std::io::{Read, Seek};
8469
8470 use common::{url::Params, ToParts};
8471 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8472
8473 let mut dd = common::DefaultDelegate;
8474 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8475 dlg.begin(common::MethodInfo {
8476 id: "servicedirectory.projects.locations.namespaces.list",
8477 http_method: hyper::Method::GET,
8478 });
8479
8480 for &field in [
8481 "alt",
8482 "parent",
8483 "pageToken",
8484 "pageSize",
8485 "orderBy",
8486 "filter",
8487 ]
8488 .iter()
8489 {
8490 if self._additional_params.contains_key(field) {
8491 dlg.finished(false);
8492 return Err(common::Error::FieldClash(field));
8493 }
8494 }
8495
8496 let mut params = Params::with_capacity(7 + self._additional_params.len());
8497 params.push("parent", self._parent);
8498 if let Some(value) = self._page_token.as_ref() {
8499 params.push("pageToken", value);
8500 }
8501 if let Some(value) = self._page_size.as_ref() {
8502 params.push("pageSize", value.to_string());
8503 }
8504 if let Some(value) = self._order_by.as_ref() {
8505 params.push("orderBy", value);
8506 }
8507 if let Some(value) = self._filter.as_ref() {
8508 params.push("filter", value);
8509 }
8510
8511 params.extend(self._additional_params.iter());
8512
8513 params.push("alt", "json");
8514 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/namespaces";
8515 if self._scopes.is_empty() {
8516 self._scopes
8517 .insert(Scope::CloudPlatform.as_ref().to_string());
8518 }
8519
8520 #[allow(clippy::single_element_loop)]
8521 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8522 url = params.uri_replacement(url, param_name, find_this, true);
8523 }
8524 {
8525 let to_remove = ["parent"];
8526 params.remove_params(&to_remove);
8527 }
8528
8529 let url = params.parse_with_url(&url);
8530
8531 loop {
8532 let token = match self
8533 .hub
8534 .auth
8535 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8536 .await
8537 {
8538 Ok(token) => token,
8539 Err(e) => match dlg.token(e) {
8540 Ok(token) => token,
8541 Err(e) => {
8542 dlg.finished(false);
8543 return Err(common::Error::MissingToken(e));
8544 }
8545 },
8546 };
8547 let mut req_result = {
8548 let client = &self.hub.client;
8549 dlg.pre_request();
8550 let mut req_builder = hyper::Request::builder()
8551 .method(hyper::Method::GET)
8552 .uri(url.as_str())
8553 .header(USER_AGENT, self.hub._user_agent.clone());
8554
8555 if let Some(token) = token.as_ref() {
8556 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8557 }
8558
8559 let request = req_builder
8560 .header(CONTENT_LENGTH, 0_u64)
8561 .body(common::to_body::<String>(None));
8562
8563 client.request(request.unwrap()).await
8564 };
8565
8566 match req_result {
8567 Err(err) => {
8568 if let common::Retry::After(d) = dlg.http_error(&err) {
8569 sleep(d).await;
8570 continue;
8571 }
8572 dlg.finished(false);
8573 return Err(common::Error::HttpError(err));
8574 }
8575 Ok(res) => {
8576 let (mut parts, body) = res.into_parts();
8577 let mut body = common::Body::new(body);
8578 if !parts.status.is_success() {
8579 let bytes = common::to_bytes(body).await.unwrap_or_default();
8580 let error = serde_json::from_str(&common::to_string(&bytes));
8581 let response = common::to_response(parts, bytes.into());
8582
8583 if let common::Retry::After(d) =
8584 dlg.http_failure(&response, error.as_ref().ok())
8585 {
8586 sleep(d).await;
8587 continue;
8588 }
8589
8590 dlg.finished(false);
8591
8592 return Err(match error {
8593 Ok(value) => common::Error::BadRequest(value),
8594 _ => common::Error::Failure(response),
8595 });
8596 }
8597 let response = {
8598 let bytes = common::to_bytes(body).await.unwrap_or_default();
8599 let encoded = common::to_string(&bytes);
8600 match serde_json::from_str(&encoded) {
8601 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8602 Err(error) => {
8603 dlg.response_json_decode_error(&encoded, &error);
8604 return Err(common::Error::JsonDecodeError(
8605 encoded.to_string(),
8606 error,
8607 ));
8608 }
8609 }
8610 };
8611
8612 dlg.finished(true);
8613 return Ok(response);
8614 }
8615 }
8616 }
8617 }
8618
8619 /// Required. The resource name of the project and location whose namespaces you'd like to list.
8620 ///
8621 /// Sets the *parent* path property to the given value.
8622 ///
8623 /// Even though the property as already been set when instantiating this call,
8624 /// we provide this method for API completeness.
8625 pub fn parent(mut self, new_value: &str) -> ProjectLocationNamespaceListCall<'a, C> {
8626 self._parent = new_value.to_string();
8627 self
8628 }
8629 /// Optional. The next_page_token value returned from a previous List request, if any.
8630 ///
8631 /// Sets the *page token* query property to the given value.
8632 pub fn page_token(mut self, new_value: &str) -> ProjectLocationNamespaceListCall<'a, C> {
8633 self._page_token = Some(new_value.to_string());
8634 self
8635 }
8636 /// Optional. The maximum number of items to return. The default value is 100.
8637 ///
8638 /// Sets the *page size* query property to the given value.
8639 pub fn page_size(mut self, new_value: i32) -> ProjectLocationNamespaceListCall<'a, C> {
8640 self._page_size = Some(new_value);
8641 self
8642 }
8643 /// Optional. The order to list results by. General `order_by` string syntax: ` () (,)` * `` allows value: `name` * `` ascending or descending order by ``. If this is left blank, `asc` is used Note that an empty `order_by` string results in default order, which is order by `name` in ascending order.
8644 ///
8645 /// Sets the *order by* query property to the given value.
8646 pub fn order_by(mut self, new_value: &str) -> ProjectLocationNamespaceListCall<'a, C> {
8647 self._order_by = Some(new_value.to_string());
8648 self
8649 }
8650 /// Optional. The filter to list results by. General `filter` string syntax: ` ()` * `` can be `name`, `labels.` for map field, or `attributes.` for attributes field * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` means `HAS`, and is roughly the same as `=` * `` must be the same data type as field * `` can be `AND`, `OR`, `NOT` Examples of valid filters: * `labels.owner` returns namespaces that have a label with the key `owner`, this is the same as `labels:owner` * `labels.owner=sd` returns namespaces that have key/value `owner=sd` * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` returns namespaces that have name that is alphabetically later than the string, so "namespace-e" is returned but "namespace-a" is not * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have `owner` in label key but value is not `sd` AND have key/value `foo=bar` * `doesnotexist.foo=bar` returns an empty list. Note that namespace doesn't have a field called "doesnotexist". Since the filter does not match any namespaces, it returns no results * `attributes.managed_registration=true` returns namespaces that are managed by a GCP product or service For more information about filtering, see [API Filtering](https://aip.dev/160).
8651 ///
8652 /// Sets the *filter* query property to the given value.
8653 pub fn filter(mut self, new_value: &str) -> ProjectLocationNamespaceListCall<'a, C> {
8654 self._filter = Some(new_value.to_string());
8655 self
8656 }
8657 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8658 /// while executing the actual API request.
8659 ///
8660 /// ````text
8661 /// It should be used to handle progress information, and to implement a certain level of resilience.
8662 /// ````
8663 ///
8664 /// Sets the *delegate* property to the given value.
8665 pub fn delegate(
8666 mut self,
8667 new_value: &'a mut dyn common::Delegate,
8668 ) -> ProjectLocationNamespaceListCall<'a, C> {
8669 self._delegate = Some(new_value);
8670 self
8671 }
8672
8673 /// Set any additional parameter of the query string used in the request.
8674 /// It should be used to set parameters which are not yet available through their own
8675 /// setters.
8676 ///
8677 /// Please note that this method must not be used to set any of the known parameters
8678 /// which have their own setter method. If done anyway, the request will fail.
8679 ///
8680 /// # Additional Parameters
8681 ///
8682 /// * *$.xgafv* (query-string) - V1 error format.
8683 /// * *access_token* (query-string) - OAuth access token.
8684 /// * *alt* (query-string) - Data format for response.
8685 /// * *callback* (query-string) - JSONP
8686 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8687 /// * *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.
8688 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8689 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8690 /// * *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.
8691 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8692 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8693 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceListCall<'a, C>
8694 where
8695 T: AsRef<str>,
8696 {
8697 self._additional_params
8698 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8699 self
8700 }
8701
8702 /// Identifies the authorization scope for the method you are building.
8703 ///
8704 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8705 /// [`Scope::CloudPlatform`].
8706 ///
8707 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8708 /// tokens for more than one scope.
8709 ///
8710 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8711 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8712 /// sufficient, a read-write scope will do as well.
8713 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceListCall<'a, C>
8714 where
8715 St: AsRef<str>,
8716 {
8717 self._scopes.insert(String::from(scope.as_ref()));
8718 self
8719 }
8720 /// Identifies the authorization scope(s) for the method you are building.
8721 ///
8722 /// See [`Self::add_scope()`] for details.
8723 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespaceListCall<'a, C>
8724 where
8725 I: IntoIterator<Item = St>,
8726 St: AsRef<str>,
8727 {
8728 self._scopes
8729 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8730 self
8731 }
8732
8733 /// Removes all scopes, and no default scope will be used either.
8734 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8735 /// for details).
8736 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceListCall<'a, C> {
8737 self._scopes.clear();
8738 self
8739 }
8740}
8741
8742/// Updates a namespace.
8743///
8744/// A builder for the *locations.namespaces.patch* method supported by a *project* resource.
8745/// It is not used directly, but through a [`ProjectMethods`] instance.
8746///
8747/// # Example
8748///
8749/// Instantiate a resource method builder
8750///
8751/// ```test_harness,no_run
8752/// # extern crate hyper;
8753/// # extern crate hyper_rustls;
8754/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
8755/// use servicedirectory1_beta1::api::Namespace;
8756/// # async fn dox() {
8757/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8758///
8759/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8760/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8761/// # .with_native_roots()
8762/// # .unwrap()
8763/// # .https_only()
8764/// # .enable_http2()
8765/// # .build();
8766///
8767/// # let executor = hyper_util::rt::TokioExecutor::new();
8768/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8769/// # secret,
8770/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8771/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8772/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8773/// # ),
8774/// # ).build().await.unwrap();
8775///
8776/// # let client = hyper_util::client::legacy::Client::builder(
8777/// # hyper_util::rt::TokioExecutor::new()
8778/// # )
8779/// # .build(
8780/// # hyper_rustls::HttpsConnectorBuilder::new()
8781/// # .with_native_roots()
8782/// # .unwrap()
8783/// # .https_or_http()
8784/// # .enable_http2()
8785/// # .build()
8786/// # );
8787/// # let mut hub = ServiceDirectory::new(client, auth);
8788/// // As the method needs a request, you would usually fill it with the desired information
8789/// // into the respective structure. Some of the parts shown here might not be applicable !
8790/// // Values shown here are possibly random and not representative !
8791/// let mut req = Namespace::default();
8792///
8793/// // You can configure optional parameters by calling the respective setters at will, and
8794/// // execute the final call using `doit()`.
8795/// // Values shown here are possibly random and not representative !
8796/// let result = hub.projects().locations_namespaces_patch(req, "name")
8797/// .update_mask(FieldMask::new::<&str>(&[]))
8798/// .doit().await;
8799/// # }
8800/// ```
8801pub struct ProjectLocationNamespacePatchCall<'a, C>
8802where
8803 C: 'a,
8804{
8805 hub: &'a ServiceDirectory<C>,
8806 _request: Namespace,
8807 _name: String,
8808 _update_mask: Option<common::FieldMask>,
8809 _delegate: Option<&'a mut dyn common::Delegate>,
8810 _additional_params: HashMap<String, String>,
8811 _scopes: BTreeSet<String>,
8812}
8813
8814impl<'a, C> common::CallBuilder for ProjectLocationNamespacePatchCall<'a, C> {}
8815
8816impl<'a, C> ProjectLocationNamespacePatchCall<'a, C>
8817where
8818 C: common::Connector,
8819{
8820 /// Perform the operation you have build so far.
8821 pub async fn doit(mut self) -> common::Result<(common::Response, Namespace)> {
8822 use std::borrow::Cow;
8823 use std::io::{Read, Seek};
8824
8825 use common::{url::Params, ToParts};
8826 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8827
8828 let mut dd = common::DefaultDelegate;
8829 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8830 dlg.begin(common::MethodInfo {
8831 id: "servicedirectory.projects.locations.namespaces.patch",
8832 http_method: hyper::Method::PATCH,
8833 });
8834
8835 for &field in ["alt", "name", "updateMask"].iter() {
8836 if self._additional_params.contains_key(field) {
8837 dlg.finished(false);
8838 return Err(common::Error::FieldClash(field));
8839 }
8840 }
8841
8842 let mut params = Params::with_capacity(5 + self._additional_params.len());
8843 params.push("name", self._name);
8844 if let Some(value) = self._update_mask.as_ref() {
8845 params.push("updateMask", value.to_string());
8846 }
8847
8848 params.extend(self._additional_params.iter());
8849
8850 params.push("alt", "json");
8851 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
8852 if self._scopes.is_empty() {
8853 self._scopes
8854 .insert(Scope::CloudPlatform.as_ref().to_string());
8855 }
8856
8857 #[allow(clippy::single_element_loop)]
8858 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8859 url = params.uri_replacement(url, param_name, find_this, true);
8860 }
8861 {
8862 let to_remove = ["name"];
8863 params.remove_params(&to_remove);
8864 }
8865
8866 let url = params.parse_with_url(&url);
8867
8868 let mut json_mime_type = mime::APPLICATION_JSON;
8869 let mut request_value_reader = {
8870 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8871 common::remove_json_null_values(&mut value);
8872 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8873 serde_json::to_writer(&mut dst, &value).unwrap();
8874 dst
8875 };
8876 let request_size = request_value_reader
8877 .seek(std::io::SeekFrom::End(0))
8878 .unwrap();
8879 request_value_reader
8880 .seek(std::io::SeekFrom::Start(0))
8881 .unwrap();
8882
8883 loop {
8884 let token = match self
8885 .hub
8886 .auth
8887 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8888 .await
8889 {
8890 Ok(token) => token,
8891 Err(e) => match dlg.token(e) {
8892 Ok(token) => token,
8893 Err(e) => {
8894 dlg.finished(false);
8895 return Err(common::Error::MissingToken(e));
8896 }
8897 },
8898 };
8899 request_value_reader
8900 .seek(std::io::SeekFrom::Start(0))
8901 .unwrap();
8902 let mut req_result = {
8903 let client = &self.hub.client;
8904 dlg.pre_request();
8905 let mut req_builder = hyper::Request::builder()
8906 .method(hyper::Method::PATCH)
8907 .uri(url.as_str())
8908 .header(USER_AGENT, self.hub._user_agent.clone());
8909
8910 if let Some(token) = token.as_ref() {
8911 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8912 }
8913
8914 let request = req_builder
8915 .header(CONTENT_TYPE, json_mime_type.to_string())
8916 .header(CONTENT_LENGTH, request_size as u64)
8917 .body(common::to_body(
8918 request_value_reader.get_ref().clone().into(),
8919 ));
8920
8921 client.request(request.unwrap()).await
8922 };
8923
8924 match req_result {
8925 Err(err) => {
8926 if let common::Retry::After(d) = dlg.http_error(&err) {
8927 sleep(d).await;
8928 continue;
8929 }
8930 dlg.finished(false);
8931 return Err(common::Error::HttpError(err));
8932 }
8933 Ok(res) => {
8934 let (mut parts, body) = res.into_parts();
8935 let mut body = common::Body::new(body);
8936 if !parts.status.is_success() {
8937 let bytes = common::to_bytes(body).await.unwrap_or_default();
8938 let error = serde_json::from_str(&common::to_string(&bytes));
8939 let response = common::to_response(parts, bytes.into());
8940
8941 if let common::Retry::After(d) =
8942 dlg.http_failure(&response, error.as_ref().ok())
8943 {
8944 sleep(d).await;
8945 continue;
8946 }
8947
8948 dlg.finished(false);
8949
8950 return Err(match error {
8951 Ok(value) => common::Error::BadRequest(value),
8952 _ => common::Error::Failure(response),
8953 });
8954 }
8955 let response = {
8956 let bytes = common::to_bytes(body).await.unwrap_or_default();
8957 let encoded = common::to_string(&bytes);
8958 match serde_json::from_str(&encoded) {
8959 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8960 Err(error) => {
8961 dlg.response_json_decode_error(&encoded, &error);
8962 return Err(common::Error::JsonDecodeError(
8963 encoded.to_string(),
8964 error,
8965 ));
8966 }
8967 }
8968 };
8969
8970 dlg.finished(true);
8971 return Ok(response);
8972 }
8973 }
8974 }
8975 }
8976
8977 ///
8978 /// Sets the *request* property to the given value.
8979 ///
8980 /// Even though the property as already been set when instantiating this call,
8981 /// we provide this method for API completeness.
8982 pub fn request(mut self, new_value: Namespace) -> ProjectLocationNamespacePatchCall<'a, C> {
8983 self._request = new_value;
8984 self
8985 }
8986 /// Immutable. The resource name for the namespace in the format `projects/*/locations/*/namespaces/*`.
8987 ///
8988 /// Sets the *name* path property to the given value.
8989 ///
8990 /// Even though the property as already been set when instantiating this call,
8991 /// we provide this method for API completeness.
8992 pub fn name(mut self, new_value: &str) -> ProjectLocationNamespacePatchCall<'a, C> {
8993 self._name = new_value.to_string();
8994 self
8995 }
8996 /// Required. List of fields to be updated in this request.
8997 ///
8998 /// Sets the *update mask* query property to the given value.
8999 pub fn update_mask(
9000 mut self,
9001 new_value: common::FieldMask,
9002 ) -> ProjectLocationNamespacePatchCall<'a, C> {
9003 self._update_mask = Some(new_value);
9004 self
9005 }
9006 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9007 /// while executing the actual API request.
9008 ///
9009 /// ````text
9010 /// It should be used to handle progress information, and to implement a certain level of resilience.
9011 /// ````
9012 ///
9013 /// Sets the *delegate* property to the given value.
9014 pub fn delegate(
9015 mut self,
9016 new_value: &'a mut dyn common::Delegate,
9017 ) -> ProjectLocationNamespacePatchCall<'a, C> {
9018 self._delegate = Some(new_value);
9019 self
9020 }
9021
9022 /// Set any additional parameter of the query string used in the request.
9023 /// It should be used to set parameters which are not yet available through their own
9024 /// setters.
9025 ///
9026 /// Please note that this method must not be used to set any of the known parameters
9027 /// which have their own setter method. If done anyway, the request will fail.
9028 ///
9029 /// # Additional Parameters
9030 ///
9031 /// * *$.xgafv* (query-string) - V1 error format.
9032 /// * *access_token* (query-string) - OAuth access token.
9033 /// * *alt* (query-string) - Data format for response.
9034 /// * *callback* (query-string) - JSONP
9035 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9036 /// * *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.
9037 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9038 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9039 /// * *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.
9040 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9041 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9042 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespacePatchCall<'a, C>
9043 where
9044 T: AsRef<str>,
9045 {
9046 self._additional_params
9047 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9048 self
9049 }
9050
9051 /// Identifies the authorization scope for the method you are building.
9052 ///
9053 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9054 /// [`Scope::CloudPlatform`].
9055 ///
9056 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9057 /// tokens for more than one scope.
9058 ///
9059 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9060 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9061 /// sufficient, a read-write scope will do as well.
9062 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespacePatchCall<'a, C>
9063 where
9064 St: AsRef<str>,
9065 {
9066 self._scopes.insert(String::from(scope.as_ref()));
9067 self
9068 }
9069 /// Identifies the authorization scope(s) for the method you are building.
9070 ///
9071 /// See [`Self::add_scope()`] for details.
9072 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespacePatchCall<'a, C>
9073 where
9074 I: IntoIterator<Item = St>,
9075 St: AsRef<str>,
9076 {
9077 self._scopes
9078 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9079 self
9080 }
9081
9082 /// Removes all scopes, and no default scope will be used either.
9083 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9084 /// for details).
9085 pub fn clear_scopes(mut self) -> ProjectLocationNamespacePatchCall<'a, C> {
9086 self._scopes.clear();
9087 self
9088 }
9089}
9090
9091/// Sets the IAM Policy for a resource
9092///
9093/// A builder for the *locations.namespaces.setIamPolicy* method supported by a *project* resource.
9094/// It is not used directly, but through a [`ProjectMethods`] instance.
9095///
9096/// # Example
9097///
9098/// Instantiate a resource method builder
9099///
9100/// ```test_harness,no_run
9101/// # extern crate hyper;
9102/// # extern crate hyper_rustls;
9103/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
9104/// use servicedirectory1_beta1::api::SetIamPolicyRequest;
9105/// # async fn dox() {
9106/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9107///
9108/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9109/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9110/// # .with_native_roots()
9111/// # .unwrap()
9112/// # .https_only()
9113/// # .enable_http2()
9114/// # .build();
9115///
9116/// # let executor = hyper_util::rt::TokioExecutor::new();
9117/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9118/// # secret,
9119/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9120/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9121/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9122/// # ),
9123/// # ).build().await.unwrap();
9124///
9125/// # let client = hyper_util::client::legacy::Client::builder(
9126/// # hyper_util::rt::TokioExecutor::new()
9127/// # )
9128/// # .build(
9129/// # hyper_rustls::HttpsConnectorBuilder::new()
9130/// # .with_native_roots()
9131/// # .unwrap()
9132/// # .https_or_http()
9133/// # .enable_http2()
9134/// # .build()
9135/// # );
9136/// # let mut hub = ServiceDirectory::new(client, auth);
9137/// // As the method needs a request, you would usually fill it with the desired information
9138/// // into the respective structure. Some of the parts shown here might not be applicable !
9139/// // Values shown here are possibly random and not representative !
9140/// let mut req = SetIamPolicyRequest::default();
9141///
9142/// // You can configure optional parameters by calling the respective setters at will, and
9143/// // execute the final call using `doit()`.
9144/// // Values shown here are possibly random and not representative !
9145/// let result = hub.projects().locations_namespaces_set_iam_policy(req, "resource")
9146/// .doit().await;
9147/// # }
9148/// ```
9149pub struct ProjectLocationNamespaceSetIamPolicyCall<'a, C>
9150where
9151 C: 'a,
9152{
9153 hub: &'a ServiceDirectory<C>,
9154 _request: SetIamPolicyRequest,
9155 _resource: String,
9156 _delegate: Option<&'a mut dyn common::Delegate>,
9157 _additional_params: HashMap<String, String>,
9158 _scopes: BTreeSet<String>,
9159}
9160
9161impl<'a, C> common::CallBuilder for ProjectLocationNamespaceSetIamPolicyCall<'a, C> {}
9162
9163impl<'a, C> ProjectLocationNamespaceSetIamPolicyCall<'a, C>
9164where
9165 C: common::Connector,
9166{
9167 /// Perform the operation you have build so far.
9168 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9169 use std::borrow::Cow;
9170 use std::io::{Read, Seek};
9171
9172 use common::{url::Params, ToParts};
9173 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9174
9175 let mut dd = common::DefaultDelegate;
9176 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9177 dlg.begin(common::MethodInfo {
9178 id: "servicedirectory.projects.locations.namespaces.setIamPolicy",
9179 http_method: hyper::Method::POST,
9180 });
9181
9182 for &field in ["alt", "resource"].iter() {
9183 if self._additional_params.contains_key(field) {
9184 dlg.finished(false);
9185 return Err(common::Error::FieldClash(field));
9186 }
9187 }
9188
9189 let mut params = Params::with_capacity(4 + self._additional_params.len());
9190 params.push("resource", self._resource);
9191
9192 params.extend(self._additional_params.iter());
9193
9194 params.push("alt", "json");
9195 let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:setIamPolicy";
9196 if self._scopes.is_empty() {
9197 self._scopes
9198 .insert(Scope::CloudPlatform.as_ref().to_string());
9199 }
9200
9201 #[allow(clippy::single_element_loop)]
9202 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9203 url = params.uri_replacement(url, param_name, find_this, true);
9204 }
9205 {
9206 let to_remove = ["resource"];
9207 params.remove_params(&to_remove);
9208 }
9209
9210 let url = params.parse_with_url(&url);
9211
9212 let mut json_mime_type = mime::APPLICATION_JSON;
9213 let mut request_value_reader = {
9214 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9215 common::remove_json_null_values(&mut value);
9216 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9217 serde_json::to_writer(&mut dst, &value).unwrap();
9218 dst
9219 };
9220 let request_size = request_value_reader
9221 .seek(std::io::SeekFrom::End(0))
9222 .unwrap();
9223 request_value_reader
9224 .seek(std::io::SeekFrom::Start(0))
9225 .unwrap();
9226
9227 loop {
9228 let token = match self
9229 .hub
9230 .auth
9231 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9232 .await
9233 {
9234 Ok(token) => token,
9235 Err(e) => match dlg.token(e) {
9236 Ok(token) => token,
9237 Err(e) => {
9238 dlg.finished(false);
9239 return Err(common::Error::MissingToken(e));
9240 }
9241 },
9242 };
9243 request_value_reader
9244 .seek(std::io::SeekFrom::Start(0))
9245 .unwrap();
9246 let mut req_result = {
9247 let client = &self.hub.client;
9248 dlg.pre_request();
9249 let mut req_builder = hyper::Request::builder()
9250 .method(hyper::Method::POST)
9251 .uri(url.as_str())
9252 .header(USER_AGENT, self.hub._user_agent.clone());
9253
9254 if let Some(token) = token.as_ref() {
9255 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9256 }
9257
9258 let request = req_builder
9259 .header(CONTENT_TYPE, json_mime_type.to_string())
9260 .header(CONTENT_LENGTH, request_size as u64)
9261 .body(common::to_body(
9262 request_value_reader.get_ref().clone().into(),
9263 ));
9264
9265 client.request(request.unwrap()).await
9266 };
9267
9268 match req_result {
9269 Err(err) => {
9270 if let common::Retry::After(d) = dlg.http_error(&err) {
9271 sleep(d).await;
9272 continue;
9273 }
9274 dlg.finished(false);
9275 return Err(common::Error::HttpError(err));
9276 }
9277 Ok(res) => {
9278 let (mut parts, body) = res.into_parts();
9279 let mut body = common::Body::new(body);
9280 if !parts.status.is_success() {
9281 let bytes = common::to_bytes(body).await.unwrap_or_default();
9282 let error = serde_json::from_str(&common::to_string(&bytes));
9283 let response = common::to_response(parts, bytes.into());
9284
9285 if let common::Retry::After(d) =
9286 dlg.http_failure(&response, error.as_ref().ok())
9287 {
9288 sleep(d).await;
9289 continue;
9290 }
9291
9292 dlg.finished(false);
9293
9294 return Err(match error {
9295 Ok(value) => common::Error::BadRequest(value),
9296 _ => common::Error::Failure(response),
9297 });
9298 }
9299 let response = {
9300 let bytes = common::to_bytes(body).await.unwrap_or_default();
9301 let encoded = common::to_string(&bytes);
9302 match serde_json::from_str(&encoded) {
9303 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9304 Err(error) => {
9305 dlg.response_json_decode_error(&encoded, &error);
9306 return Err(common::Error::JsonDecodeError(
9307 encoded.to_string(),
9308 error,
9309 ));
9310 }
9311 }
9312 };
9313
9314 dlg.finished(true);
9315 return Ok(response);
9316 }
9317 }
9318 }
9319 }
9320
9321 ///
9322 /// Sets the *request* property to the given value.
9323 ///
9324 /// Even though the property as already been set when instantiating this call,
9325 /// we provide this method for API completeness.
9326 pub fn request(
9327 mut self,
9328 new_value: SetIamPolicyRequest,
9329 ) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> {
9330 self._request = new_value;
9331 self
9332 }
9333 /// 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.
9334 ///
9335 /// Sets the *resource* path property to the given value.
9336 ///
9337 /// Even though the property as already been set when instantiating this call,
9338 /// we provide this method for API completeness.
9339 pub fn resource(mut self, new_value: &str) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> {
9340 self._resource = new_value.to_string();
9341 self
9342 }
9343 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9344 /// while executing the actual API request.
9345 ///
9346 /// ````text
9347 /// It should be used to handle progress information, and to implement a certain level of resilience.
9348 /// ````
9349 ///
9350 /// Sets the *delegate* property to the given value.
9351 pub fn delegate(
9352 mut self,
9353 new_value: &'a mut dyn common::Delegate,
9354 ) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> {
9355 self._delegate = Some(new_value);
9356 self
9357 }
9358
9359 /// Set any additional parameter of the query string used in the request.
9360 /// It should be used to set parameters which are not yet available through their own
9361 /// setters.
9362 ///
9363 /// Please note that this method must not be used to set any of the known parameters
9364 /// which have their own setter method. If done anyway, the request will fail.
9365 ///
9366 /// # Additional Parameters
9367 ///
9368 /// * *$.xgafv* (query-string) - V1 error format.
9369 /// * *access_token* (query-string) - OAuth access token.
9370 /// * *alt* (query-string) - Data format for response.
9371 /// * *callback* (query-string) - JSONP
9372 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9373 /// * *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.
9374 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9375 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9376 /// * *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.
9377 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9378 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9379 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C>
9380 where
9381 T: AsRef<str>,
9382 {
9383 self._additional_params
9384 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9385 self
9386 }
9387
9388 /// Identifies the authorization scope for the method you are building.
9389 ///
9390 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9391 /// [`Scope::CloudPlatform`].
9392 ///
9393 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9394 /// tokens for more than one scope.
9395 ///
9396 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9397 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9398 /// sufficient, a read-write scope will do as well.
9399 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C>
9400 where
9401 St: AsRef<str>,
9402 {
9403 self._scopes.insert(String::from(scope.as_ref()));
9404 self
9405 }
9406 /// Identifies the authorization scope(s) for the method you are building.
9407 ///
9408 /// See [`Self::add_scope()`] for details.
9409 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C>
9410 where
9411 I: IntoIterator<Item = St>,
9412 St: AsRef<str>,
9413 {
9414 self._scopes
9415 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9416 self
9417 }
9418
9419 /// Removes all scopes, and no default scope will be used either.
9420 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9421 /// for details).
9422 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> {
9423 self._scopes.clear();
9424 self
9425 }
9426}
9427
9428/// Tests IAM permissions for a resource (namespace, service or service workload only).
9429///
9430/// A builder for the *locations.namespaces.testIamPermissions* method supported by a *project* resource.
9431/// It is not used directly, but through a [`ProjectMethods`] instance.
9432///
9433/// # Example
9434///
9435/// Instantiate a resource method builder
9436///
9437/// ```test_harness,no_run
9438/// # extern crate hyper;
9439/// # extern crate hyper_rustls;
9440/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
9441/// use servicedirectory1_beta1::api::TestIamPermissionsRequest;
9442/// # async fn dox() {
9443/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9444///
9445/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9446/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9447/// # .with_native_roots()
9448/// # .unwrap()
9449/// # .https_only()
9450/// # .enable_http2()
9451/// # .build();
9452///
9453/// # let executor = hyper_util::rt::TokioExecutor::new();
9454/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9455/// # secret,
9456/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9457/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9458/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9459/// # ),
9460/// # ).build().await.unwrap();
9461///
9462/// # let client = hyper_util::client::legacy::Client::builder(
9463/// # hyper_util::rt::TokioExecutor::new()
9464/// # )
9465/// # .build(
9466/// # hyper_rustls::HttpsConnectorBuilder::new()
9467/// # .with_native_roots()
9468/// # .unwrap()
9469/// # .https_or_http()
9470/// # .enable_http2()
9471/// # .build()
9472/// # );
9473/// # let mut hub = ServiceDirectory::new(client, auth);
9474/// // As the method needs a request, you would usually fill it with the desired information
9475/// // into the respective structure. Some of the parts shown here might not be applicable !
9476/// // Values shown here are possibly random and not representative !
9477/// let mut req = TestIamPermissionsRequest::default();
9478///
9479/// // You can configure optional parameters by calling the respective setters at will, and
9480/// // execute the final call using `doit()`.
9481/// // Values shown here are possibly random and not representative !
9482/// let result = hub.projects().locations_namespaces_test_iam_permissions(req, "resource")
9483/// .doit().await;
9484/// # }
9485/// ```
9486pub struct ProjectLocationNamespaceTestIamPermissionCall<'a, C>
9487where
9488 C: 'a,
9489{
9490 hub: &'a ServiceDirectory<C>,
9491 _request: TestIamPermissionsRequest,
9492 _resource: String,
9493 _delegate: Option<&'a mut dyn common::Delegate>,
9494 _additional_params: HashMap<String, String>,
9495 _scopes: BTreeSet<String>,
9496}
9497
9498impl<'a, C> common::CallBuilder for ProjectLocationNamespaceTestIamPermissionCall<'a, C> {}
9499
9500impl<'a, C> ProjectLocationNamespaceTestIamPermissionCall<'a, C>
9501where
9502 C: common::Connector,
9503{
9504 /// Perform the operation you have build so far.
9505 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
9506 use std::borrow::Cow;
9507 use std::io::{Read, Seek};
9508
9509 use common::{url::Params, ToParts};
9510 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9511
9512 let mut dd = common::DefaultDelegate;
9513 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9514 dlg.begin(common::MethodInfo {
9515 id: "servicedirectory.projects.locations.namespaces.testIamPermissions",
9516 http_method: hyper::Method::POST,
9517 });
9518
9519 for &field in ["alt", "resource"].iter() {
9520 if self._additional_params.contains_key(field) {
9521 dlg.finished(false);
9522 return Err(common::Error::FieldClash(field));
9523 }
9524 }
9525
9526 let mut params = Params::with_capacity(4 + self._additional_params.len());
9527 params.push("resource", self._resource);
9528
9529 params.extend(self._additional_params.iter());
9530
9531 params.push("alt", "json");
9532 let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:testIamPermissions";
9533 if self._scopes.is_empty() {
9534 self._scopes
9535 .insert(Scope::CloudPlatform.as_ref().to_string());
9536 }
9537
9538 #[allow(clippy::single_element_loop)]
9539 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9540 url = params.uri_replacement(url, param_name, find_this, true);
9541 }
9542 {
9543 let to_remove = ["resource"];
9544 params.remove_params(&to_remove);
9545 }
9546
9547 let url = params.parse_with_url(&url);
9548
9549 let mut json_mime_type = mime::APPLICATION_JSON;
9550 let mut request_value_reader = {
9551 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9552 common::remove_json_null_values(&mut value);
9553 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9554 serde_json::to_writer(&mut dst, &value).unwrap();
9555 dst
9556 };
9557 let request_size = request_value_reader
9558 .seek(std::io::SeekFrom::End(0))
9559 .unwrap();
9560 request_value_reader
9561 .seek(std::io::SeekFrom::Start(0))
9562 .unwrap();
9563
9564 loop {
9565 let token = match self
9566 .hub
9567 .auth
9568 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9569 .await
9570 {
9571 Ok(token) => token,
9572 Err(e) => match dlg.token(e) {
9573 Ok(token) => token,
9574 Err(e) => {
9575 dlg.finished(false);
9576 return Err(common::Error::MissingToken(e));
9577 }
9578 },
9579 };
9580 request_value_reader
9581 .seek(std::io::SeekFrom::Start(0))
9582 .unwrap();
9583 let mut req_result = {
9584 let client = &self.hub.client;
9585 dlg.pre_request();
9586 let mut req_builder = hyper::Request::builder()
9587 .method(hyper::Method::POST)
9588 .uri(url.as_str())
9589 .header(USER_AGENT, self.hub._user_agent.clone());
9590
9591 if let Some(token) = token.as_ref() {
9592 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9593 }
9594
9595 let request = req_builder
9596 .header(CONTENT_TYPE, json_mime_type.to_string())
9597 .header(CONTENT_LENGTH, request_size as u64)
9598 .body(common::to_body(
9599 request_value_reader.get_ref().clone().into(),
9600 ));
9601
9602 client.request(request.unwrap()).await
9603 };
9604
9605 match req_result {
9606 Err(err) => {
9607 if let common::Retry::After(d) = dlg.http_error(&err) {
9608 sleep(d).await;
9609 continue;
9610 }
9611 dlg.finished(false);
9612 return Err(common::Error::HttpError(err));
9613 }
9614 Ok(res) => {
9615 let (mut parts, body) = res.into_parts();
9616 let mut body = common::Body::new(body);
9617 if !parts.status.is_success() {
9618 let bytes = common::to_bytes(body).await.unwrap_or_default();
9619 let error = serde_json::from_str(&common::to_string(&bytes));
9620 let response = common::to_response(parts, bytes.into());
9621
9622 if let common::Retry::After(d) =
9623 dlg.http_failure(&response, error.as_ref().ok())
9624 {
9625 sleep(d).await;
9626 continue;
9627 }
9628
9629 dlg.finished(false);
9630
9631 return Err(match error {
9632 Ok(value) => common::Error::BadRequest(value),
9633 _ => common::Error::Failure(response),
9634 });
9635 }
9636 let response = {
9637 let bytes = common::to_bytes(body).await.unwrap_or_default();
9638 let encoded = common::to_string(&bytes);
9639 match serde_json::from_str(&encoded) {
9640 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9641 Err(error) => {
9642 dlg.response_json_decode_error(&encoded, &error);
9643 return Err(common::Error::JsonDecodeError(
9644 encoded.to_string(),
9645 error,
9646 ));
9647 }
9648 }
9649 };
9650
9651 dlg.finished(true);
9652 return Ok(response);
9653 }
9654 }
9655 }
9656 }
9657
9658 ///
9659 /// Sets the *request* property to the given value.
9660 ///
9661 /// Even though the property as already been set when instantiating this call,
9662 /// we provide this method for API completeness.
9663 pub fn request(
9664 mut self,
9665 new_value: TestIamPermissionsRequest,
9666 ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> {
9667 self._request = new_value;
9668 self
9669 }
9670 /// 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.
9671 ///
9672 /// Sets the *resource* path property to the given value.
9673 ///
9674 /// Even though the property as already been set when instantiating this call,
9675 /// we provide this method for API completeness.
9676 pub fn resource(
9677 mut self,
9678 new_value: &str,
9679 ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> {
9680 self._resource = new_value.to_string();
9681 self
9682 }
9683 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9684 /// while executing the actual API request.
9685 ///
9686 /// ````text
9687 /// It should be used to handle progress information, and to implement a certain level of resilience.
9688 /// ````
9689 ///
9690 /// Sets the *delegate* property to the given value.
9691 pub fn delegate(
9692 mut self,
9693 new_value: &'a mut dyn common::Delegate,
9694 ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> {
9695 self._delegate = Some(new_value);
9696 self
9697 }
9698
9699 /// Set any additional parameter of the query string used in the request.
9700 /// It should be used to set parameters which are not yet available through their own
9701 /// setters.
9702 ///
9703 /// Please note that this method must not be used to set any of the known parameters
9704 /// which have their own setter method. If done anyway, the request will fail.
9705 ///
9706 /// # Additional Parameters
9707 ///
9708 /// * *$.xgafv* (query-string) - V1 error format.
9709 /// * *access_token* (query-string) - OAuth access token.
9710 /// * *alt* (query-string) - Data format for response.
9711 /// * *callback* (query-string) - JSONP
9712 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9713 /// * *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.
9714 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9715 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9716 /// * *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.
9717 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9718 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9719 pub fn param<T>(
9720 mut self,
9721 name: T,
9722 value: T,
9723 ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C>
9724 where
9725 T: AsRef<str>,
9726 {
9727 self._additional_params
9728 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9729 self
9730 }
9731
9732 /// Identifies the authorization scope for the method you are building.
9733 ///
9734 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9735 /// [`Scope::CloudPlatform`].
9736 ///
9737 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9738 /// tokens for more than one scope.
9739 ///
9740 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9741 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9742 /// sufficient, a read-write scope will do as well.
9743 pub fn add_scope<St>(
9744 mut self,
9745 scope: St,
9746 ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C>
9747 where
9748 St: AsRef<str>,
9749 {
9750 self._scopes.insert(String::from(scope.as_ref()));
9751 self
9752 }
9753 /// Identifies the authorization scope(s) for the method you are building.
9754 ///
9755 /// See [`Self::add_scope()`] for details.
9756 pub fn add_scopes<I, St>(
9757 mut self,
9758 scopes: I,
9759 ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C>
9760 where
9761 I: IntoIterator<Item = St>,
9762 St: AsRef<str>,
9763 {
9764 self._scopes
9765 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9766 self
9767 }
9768
9769 /// Removes all scopes, and no default scope will be used either.
9770 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9771 /// for details).
9772 pub fn clear_scopes(mut self) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> {
9773 self._scopes.clear();
9774 self
9775 }
9776}
9777
9778/// Gets information about a location.
9779///
9780/// A builder for the *locations.get* method supported by a *project* resource.
9781/// It is not used directly, but through a [`ProjectMethods`] instance.
9782///
9783/// # Example
9784///
9785/// Instantiate a resource method builder
9786///
9787/// ```test_harness,no_run
9788/// # extern crate hyper;
9789/// # extern crate hyper_rustls;
9790/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
9791/// # async fn dox() {
9792/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9793///
9794/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9795/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9796/// # .with_native_roots()
9797/// # .unwrap()
9798/// # .https_only()
9799/// # .enable_http2()
9800/// # .build();
9801///
9802/// # let executor = hyper_util::rt::TokioExecutor::new();
9803/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9804/// # secret,
9805/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9806/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9807/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9808/// # ),
9809/// # ).build().await.unwrap();
9810///
9811/// # let client = hyper_util::client::legacy::Client::builder(
9812/// # hyper_util::rt::TokioExecutor::new()
9813/// # )
9814/// # .build(
9815/// # hyper_rustls::HttpsConnectorBuilder::new()
9816/// # .with_native_roots()
9817/// # .unwrap()
9818/// # .https_or_http()
9819/// # .enable_http2()
9820/// # .build()
9821/// # );
9822/// # let mut hub = ServiceDirectory::new(client, auth);
9823/// // You can configure optional parameters by calling the respective setters at will, and
9824/// // execute the final call using `doit()`.
9825/// // Values shown here are possibly random and not representative !
9826/// let result = hub.projects().locations_get("name")
9827/// .doit().await;
9828/// # }
9829/// ```
9830pub struct ProjectLocationGetCall<'a, C>
9831where
9832 C: 'a,
9833{
9834 hub: &'a ServiceDirectory<C>,
9835 _name: String,
9836 _delegate: Option<&'a mut dyn common::Delegate>,
9837 _additional_params: HashMap<String, String>,
9838 _scopes: BTreeSet<String>,
9839}
9840
9841impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
9842
9843impl<'a, C> ProjectLocationGetCall<'a, C>
9844where
9845 C: common::Connector,
9846{
9847 /// Perform the operation you have build so far.
9848 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
9849 use std::borrow::Cow;
9850 use std::io::{Read, Seek};
9851
9852 use common::{url::Params, ToParts};
9853 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9854
9855 let mut dd = common::DefaultDelegate;
9856 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9857 dlg.begin(common::MethodInfo {
9858 id: "servicedirectory.projects.locations.get",
9859 http_method: hyper::Method::GET,
9860 });
9861
9862 for &field in ["alt", "name"].iter() {
9863 if self._additional_params.contains_key(field) {
9864 dlg.finished(false);
9865 return Err(common::Error::FieldClash(field));
9866 }
9867 }
9868
9869 let mut params = Params::with_capacity(3 + self._additional_params.len());
9870 params.push("name", self._name);
9871
9872 params.extend(self._additional_params.iter());
9873
9874 params.push("alt", "json");
9875 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
9876 if self._scopes.is_empty() {
9877 self._scopes
9878 .insert(Scope::CloudPlatform.as_ref().to_string());
9879 }
9880
9881 #[allow(clippy::single_element_loop)]
9882 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9883 url = params.uri_replacement(url, param_name, find_this, true);
9884 }
9885 {
9886 let to_remove = ["name"];
9887 params.remove_params(&to_remove);
9888 }
9889
9890 let url = params.parse_with_url(&url);
9891
9892 loop {
9893 let token = match self
9894 .hub
9895 .auth
9896 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9897 .await
9898 {
9899 Ok(token) => token,
9900 Err(e) => match dlg.token(e) {
9901 Ok(token) => token,
9902 Err(e) => {
9903 dlg.finished(false);
9904 return Err(common::Error::MissingToken(e));
9905 }
9906 },
9907 };
9908 let mut req_result = {
9909 let client = &self.hub.client;
9910 dlg.pre_request();
9911 let mut req_builder = hyper::Request::builder()
9912 .method(hyper::Method::GET)
9913 .uri(url.as_str())
9914 .header(USER_AGENT, self.hub._user_agent.clone());
9915
9916 if let Some(token) = token.as_ref() {
9917 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9918 }
9919
9920 let request = req_builder
9921 .header(CONTENT_LENGTH, 0_u64)
9922 .body(common::to_body::<String>(None));
9923
9924 client.request(request.unwrap()).await
9925 };
9926
9927 match req_result {
9928 Err(err) => {
9929 if let common::Retry::After(d) = dlg.http_error(&err) {
9930 sleep(d).await;
9931 continue;
9932 }
9933 dlg.finished(false);
9934 return Err(common::Error::HttpError(err));
9935 }
9936 Ok(res) => {
9937 let (mut parts, body) = res.into_parts();
9938 let mut body = common::Body::new(body);
9939 if !parts.status.is_success() {
9940 let bytes = common::to_bytes(body).await.unwrap_or_default();
9941 let error = serde_json::from_str(&common::to_string(&bytes));
9942 let response = common::to_response(parts, bytes.into());
9943
9944 if let common::Retry::After(d) =
9945 dlg.http_failure(&response, error.as_ref().ok())
9946 {
9947 sleep(d).await;
9948 continue;
9949 }
9950
9951 dlg.finished(false);
9952
9953 return Err(match error {
9954 Ok(value) => common::Error::BadRequest(value),
9955 _ => common::Error::Failure(response),
9956 });
9957 }
9958 let response = {
9959 let bytes = common::to_bytes(body).await.unwrap_or_default();
9960 let encoded = common::to_string(&bytes);
9961 match serde_json::from_str(&encoded) {
9962 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9963 Err(error) => {
9964 dlg.response_json_decode_error(&encoded, &error);
9965 return Err(common::Error::JsonDecodeError(
9966 encoded.to_string(),
9967 error,
9968 ));
9969 }
9970 }
9971 };
9972
9973 dlg.finished(true);
9974 return Ok(response);
9975 }
9976 }
9977 }
9978 }
9979
9980 /// Resource name for the location.
9981 ///
9982 /// Sets the *name* path property to the given value.
9983 ///
9984 /// Even though the property as already been set when instantiating this call,
9985 /// we provide this method for API completeness.
9986 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
9987 self._name = new_value.to_string();
9988 self
9989 }
9990 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9991 /// while executing the actual API request.
9992 ///
9993 /// ````text
9994 /// It should be used to handle progress information, and to implement a certain level of resilience.
9995 /// ````
9996 ///
9997 /// Sets the *delegate* property to the given value.
9998 pub fn delegate(
9999 mut self,
10000 new_value: &'a mut dyn common::Delegate,
10001 ) -> ProjectLocationGetCall<'a, C> {
10002 self._delegate = Some(new_value);
10003 self
10004 }
10005
10006 /// Set any additional parameter of the query string used in the request.
10007 /// It should be used to set parameters which are not yet available through their own
10008 /// setters.
10009 ///
10010 /// Please note that this method must not be used to set any of the known parameters
10011 /// which have their own setter method. If done anyway, the request will fail.
10012 ///
10013 /// # Additional Parameters
10014 ///
10015 /// * *$.xgafv* (query-string) - V1 error format.
10016 /// * *access_token* (query-string) - OAuth access token.
10017 /// * *alt* (query-string) - Data format for response.
10018 /// * *callback* (query-string) - JSONP
10019 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10020 /// * *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.
10021 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10022 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10023 /// * *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.
10024 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10025 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10026 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
10027 where
10028 T: AsRef<str>,
10029 {
10030 self._additional_params
10031 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10032 self
10033 }
10034
10035 /// Identifies the authorization scope for the method you are building.
10036 ///
10037 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10038 /// [`Scope::CloudPlatform`].
10039 ///
10040 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10041 /// tokens for more than one scope.
10042 ///
10043 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10044 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10045 /// sufficient, a read-write scope will do as well.
10046 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
10047 where
10048 St: AsRef<str>,
10049 {
10050 self._scopes.insert(String::from(scope.as_ref()));
10051 self
10052 }
10053 /// Identifies the authorization scope(s) for the method you are building.
10054 ///
10055 /// See [`Self::add_scope()`] for details.
10056 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
10057 where
10058 I: IntoIterator<Item = St>,
10059 St: AsRef<str>,
10060 {
10061 self._scopes
10062 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10063 self
10064 }
10065
10066 /// Removes all scopes, and no default scope will be used either.
10067 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10068 /// for details).
10069 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
10070 self._scopes.clear();
10071 self
10072 }
10073}
10074
10075/// Lists information about the supported locations for this service.
10076///
10077/// A builder for the *locations.list* method supported by a *project* resource.
10078/// It is not used directly, but through a [`ProjectMethods`] instance.
10079///
10080/// # Example
10081///
10082/// Instantiate a resource method builder
10083///
10084/// ```test_harness,no_run
10085/// # extern crate hyper;
10086/// # extern crate hyper_rustls;
10087/// # extern crate google_servicedirectory1_beta1 as servicedirectory1_beta1;
10088/// # async fn dox() {
10089/// # use servicedirectory1_beta1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10090///
10091/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10092/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10093/// # .with_native_roots()
10094/// # .unwrap()
10095/// # .https_only()
10096/// # .enable_http2()
10097/// # .build();
10098///
10099/// # let executor = hyper_util::rt::TokioExecutor::new();
10100/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10101/// # secret,
10102/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10103/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10104/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10105/// # ),
10106/// # ).build().await.unwrap();
10107///
10108/// # let client = hyper_util::client::legacy::Client::builder(
10109/// # hyper_util::rt::TokioExecutor::new()
10110/// # )
10111/// # .build(
10112/// # hyper_rustls::HttpsConnectorBuilder::new()
10113/// # .with_native_roots()
10114/// # .unwrap()
10115/// # .https_or_http()
10116/// # .enable_http2()
10117/// # .build()
10118/// # );
10119/// # let mut hub = ServiceDirectory::new(client, auth);
10120/// // You can configure optional parameters by calling the respective setters at will, and
10121/// // execute the final call using `doit()`.
10122/// // Values shown here are possibly random and not representative !
10123/// let result = hub.projects().locations_list("name")
10124/// .page_token("sed")
10125/// .page_size(-24)
10126/// .filter("et")
10127/// .add_extra_location_types("vero")
10128/// .doit().await;
10129/// # }
10130/// ```
10131pub struct ProjectLocationListCall<'a, C>
10132where
10133 C: 'a,
10134{
10135 hub: &'a ServiceDirectory<C>,
10136 _name: String,
10137 _page_token: Option<String>,
10138 _page_size: Option<i32>,
10139 _filter: Option<String>,
10140 _extra_location_types: Vec<String>,
10141 _delegate: Option<&'a mut dyn common::Delegate>,
10142 _additional_params: HashMap<String, String>,
10143 _scopes: BTreeSet<String>,
10144}
10145
10146impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
10147
10148impl<'a, C> ProjectLocationListCall<'a, C>
10149where
10150 C: common::Connector,
10151{
10152 /// Perform the operation you have build so far.
10153 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
10154 use std::borrow::Cow;
10155 use std::io::{Read, Seek};
10156
10157 use common::{url::Params, ToParts};
10158 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10159
10160 let mut dd = common::DefaultDelegate;
10161 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10162 dlg.begin(common::MethodInfo {
10163 id: "servicedirectory.projects.locations.list",
10164 http_method: hyper::Method::GET,
10165 });
10166
10167 for &field in [
10168 "alt",
10169 "name",
10170 "pageToken",
10171 "pageSize",
10172 "filter",
10173 "extraLocationTypes",
10174 ]
10175 .iter()
10176 {
10177 if self._additional_params.contains_key(field) {
10178 dlg.finished(false);
10179 return Err(common::Error::FieldClash(field));
10180 }
10181 }
10182
10183 let mut params = Params::with_capacity(7 + self._additional_params.len());
10184 params.push("name", self._name);
10185 if let Some(value) = self._page_token.as_ref() {
10186 params.push("pageToken", value);
10187 }
10188 if let Some(value) = self._page_size.as_ref() {
10189 params.push("pageSize", value.to_string());
10190 }
10191 if let Some(value) = self._filter.as_ref() {
10192 params.push("filter", value);
10193 }
10194 if !self._extra_location_types.is_empty() {
10195 for f in self._extra_location_types.iter() {
10196 params.push("extraLocationTypes", f);
10197 }
10198 }
10199
10200 params.extend(self._additional_params.iter());
10201
10202 params.push("alt", "json");
10203 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/locations";
10204 if self._scopes.is_empty() {
10205 self._scopes
10206 .insert(Scope::CloudPlatform.as_ref().to_string());
10207 }
10208
10209 #[allow(clippy::single_element_loop)]
10210 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10211 url = params.uri_replacement(url, param_name, find_this, true);
10212 }
10213 {
10214 let to_remove = ["name"];
10215 params.remove_params(&to_remove);
10216 }
10217
10218 let url = params.parse_with_url(&url);
10219
10220 loop {
10221 let token = match self
10222 .hub
10223 .auth
10224 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10225 .await
10226 {
10227 Ok(token) => token,
10228 Err(e) => match dlg.token(e) {
10229 Ok(token) => token,
10230 Err(e) => {
10231 dlg.finished(false);
10232 return Err(common::Error::MissingToken(e));
10233 }
10234 },
10235 };
10236 let mut req_result = {
10237 let client = &self.hub.client;
10238 dlg.pre_request();
10239 let mut req_builder = hyper::Request::builder()
10240 .method(hyper::Method::GET)
10241 .uri(url.as_str())
10242 .header(USER_AGENT, self.hub._user_agent.clone());
10243
10244 if let Some(token) = token.as_ref() {
10245 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10246 }
10247
10248 let request = req_builder
10249 .header(CONTENT_LENGTH, 0_u64)
10250 .body(common::to_body::<String>(None));
10251
10252 client.request(request.unwrap()).await
10253 };
10254
10255 match req_result {
10256 Err(err) => {
10257 if let common::Retry::After(d) = dlg.http_error(&err) {
10258 sleep(d).await;
10259 continue;
10260 }
10261 dlg.finished(false);
10262 return Err(common::Error::HttpError(err));
10263 }
10264 Ok(res) => {
10265 let (mut parts, body) = res.into_parts();
10266 let mut body = common::Body::new(body);
10267 if !parts.status.is_success() {
10268 let bytes = common::to_bytes(body).await.unwrap_or_default();
10269 let error = serde_json::from_str(&common::to_string(&bytes));
10270 let response = common::to_response(parts, bytes.into());
10271
10272 if let common::Retry::After(d) =
10273 dlg.http_failure(&response, error.as_ref().ok())
10274 {
10275 sleep(d).await;
10276 continue;
10277 }
10278
10279 dlg.finished(false);
10280
10281 return Err(match error {
10282 Ok(value) => common::Error::BadRequest(value),
10283 _ => common::Error::Failure(response),
10284 });
10285 }
10286 let response = {
10287 let bytes = common::to_bytes(body).await.unwrap_or_default();
10288 let encoded = common::to_string(&bytes);
10289 match serde_json::from_str(&encoded) {
10290 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10291 Err(error) => {
10292 dlg.response_json_decode_error(&encoded, &error);
10293 return Err(common::Error::JsonDecodeError(
10294 encoded.to_string(),
10295 error,
10296 ));
10297 }
10298 }
10299 };
10300
10301 dlg.finished(true);
10302 return Ok(response);
10303 }
10304 }
10305 }
10306 }
10307
10308 /// The resource that owns the locations collection, if applicable.
10309 ///
10310 /// Sets the *name* path property to the given value.
10311 ///
10312 /// Even though the property as already been set when instantiating this call,
10313 /// we provide this method for API completeness.
10314 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10315 self._name = new_value.to_string();
10316 self
10317 }
10318 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
10319 ///
10320 /// Sets the *page token* query property to the given value.
10321 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10322 self._page_token = Some(new_value.to_string());
10323 self
10324 }
10325 /// The maximum number of results to return. If not set, the service selects a default.
10326 ///
10327 /// Sets the *page size* query property to the given value.
10328 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
10329 self._page_size = Some(new_value);
10330 self
10331 }
10332 /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
10333 ///
10334 /// Sets the *filter* query property to the given value.
10335 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10336 self._filter = Some(new_value.to_string());
10337 self
10338 }
10339 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
10340 ///
10341 /// Append the given value to the *extra location types* query property.
10342 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10343 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10344 self._extra_location_types.push(new_value.to_string());
10345 self
10346 }
10347 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10348 /// while executing the actual API request.
10349 ///
10350 /// ````text
10351 /// It should be used to handle progress information, and to implement a certain level of resilience.
10352 /// ````
10353 ///
10354 /// Sets the *delegate* property to the given value.
10355 pub fn delegate(
10356 mut self,
10357 new_value: &'a mut dyn common::Delegate,
10358 ) -> ProjectLocationListCall<'a, C> {
10359 self._delegate = Some(new_value);
10360 self
10361 }
10362
10363 /// Set any additional parameter of the query string used in the request.
10364 /// It should be used to set parameters which are not yet available through their own
10365 /// setters.
10366 ///
10367 /// Please note that this method must not be used to set any of the known parameters
10368 /// which have their own setter method. If done anyway, the request will fail.
10369 ///
10370 /// # Additional Parameters
10371 ///
10372 /// * *$.xgafv* (query-string) - V1 error format.
10373 /// * *access_token* (query-string) - OAuth access token.
10374 /// * *alt* (query-string) - Data format for response.
10375 /// * *callback* (query-string) - JSONP
10376 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10377 /// * *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.
10378 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10379 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10380 /// * *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.
10381 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10382 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10383 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
10384 where
10385 T: AsRef<str>,
10386 {
10387 self._additional_params
10388 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10389 self
10390 }
10391
10392 /// Identifies the authorization scope for the method you are building.
10393 ///
10394 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10395 /// [`Scope::CloudPlatform`].
10396 ///
10397 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10398 /// tokens for more than one scope.
10399 ///
10400 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10401 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10402 /// sufficient, a read-write scope will do as well.
10403 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
10404 where
10405 St: AsRef<str>,
10406 {
10407 self._scopes.insert(String::from(scope.as_ref()));
10408 self
10409 }
10410 /// Identifies the authorization scope(s) for the method you are building.
10411 ///
10412 /// See [`Self::add_scope()`] for details.
10413 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
10414 where
10415 I: IntoIterator<Item = St>,
10416 St: AsRef<str>,
10417 {
10418 self._scopes
10419 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10420 self
10421 }
10422
10423 /// Removes all scopes, and no default scope will be used either.
10424 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10425 /// for details).
10426 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
10427 self._scopes.clear();
10428 self
10429 }
10430}