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