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