#![allow(clippy::ptr_arg)] use std::collections::{BTreeSet, HashMap}; use tokio::time::sleep; // ############## // UTILITIES ### // ############ /// Identifies the an OAuth2 authorization scope. /// A scope is needed when requesting an /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)] pub enum Scope { /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account. CloudPlatform, } impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", } } } #[allow(clippy::derivable_impls)] impl Default for Scope { fn default() -> Scope { Scope::CloudPlatform } } // ######## // HUB ### // ###### /// Central instance to access all ServiceDirectory related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::GetIamPolicyRequest; /// use servicedirectory1::{Result, Error}; /// # async fn dox() { /// use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. /// let secret: yup_oauth2::ApplicationSecret = Default::default(); /// // Instantiate the authenticator. It will choose a suitable authentication flow for you, /// // unless you replace `None` with the desired Flow. /// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about /// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and /// // retrieve them from storage. /// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// secret, /// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// /// let client = hyper_util::client::legacy::Client::builder( /// hyper_util::rt::TokioExecutor::new() /// ) /// .build( /// hyper_rustls::HttpsConnectorBuilder::new() /// .with_native_roots() /// .unwrap() /// .https_or_http() /// .enable_http1() /// .build() /// ); /// let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GetIamPolicyRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_get_iam_policy(req, "resource") /// .doit().await; /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits /// Error::HttpError(_) /// |Error::Io(_) /// |Error::MissingAPIKey /// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) /// |Error::BadRequest(_) /// |Error::FieldClash(_) /// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } /// # } /// ``` #[derive(Clone)] pub struct ServiceDirectory { pub client: common::Client, pub auth: Box, _user_agent: String, _base_url: String, _root_url: String, } impl common::Hub for ServiceDirectory {} impl<'a, C> ServiceDirectory { pub fn new( client: common::Client, auth: A, ) -> ServiceDirectory { ServiceDirectory { client, auth: Box::new(auth), _user_agent: "google-api-rust-client/6.0.0".to_string(), _base_url: "https://servicedirectory.googleapis.com/".to_string(), _root_url: "https://servicedirectory.googleapis.com/".to_string(), } } pub fn projects(&'a self) -> ProjectMethods<'a, C> { ProjectMethods { hub: self } } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/6.0.0`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { std::mem::replace(&mut self._user_agent, agent_name) } /// Set the base url to use in all requests to the server. /// It defaults to `https://servicedirectory.googleapis.com/`. /// /// Returns the previously set base url. pub fn base_url(&mut self, new_base_url: String) -> String { std::mem::replace(&mut self._base_url, new_base_url) } /// Set the root url to use in all requests to the server. /// It defaults to `https://servicedirectory.googleapis.com/`. /// /// Returns the previously set root url. pub fn root_url(&mut self, new_root_url: String) -> String { std::mem::replace(&mut self._root_url, new_root_url) } } // ############ // SCHEMAS ### // ########## /// Associates `members`, or principals, with a `role`. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Binding { /// 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). pub condition: Option, /// 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`. pub members: Option>, /// 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). pub role: Option, } impl common::Part for Binding {} /// 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); } /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services endpoints delete projects](ProjectLocationNamespaceServiceEndpointDeleteCall) (response) /// * [locations namespaces services delete projects](ProjectLocationNamespaceServiceDeleteCall) (response) /// * [locations namespaces delete projects](ProjectLocationNamespaceDeleteCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Empty { _never_set: Option, } impl common::ResponseResult for Empty {} /// An individual endpoint that provides a service. The service must already exist to create an endpoint. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services endpoints create projects](ProjectLocationNamespaceServiceEndpointCreateCall) (request|response) /// * [locations namespaces services endpoints get projects](ProjectLocationNamespaceServiceEndpointGetCall) (response) /// * [locations namespaces services endpoints patch projects](ProjectLocationNamespaceServiceEndpointPatchCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Endpoint { /// 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. pub address: Option, /// 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. pub annotations: Option>, /// Immutable. The resource name for the endpoint in the format `projects/*/locations/*/namespaces/*/services/*/endpoints/*`. pub name: Option, /// 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. pub network: Option, /// Optional. Service Directory rejects values outside of `[0, 65535]`. pub port: Option, /// Output only. The globally unique identifier of the endpoint in the UUID4 format. pub uid: Option, } impl common::RequestValue for Endpoint {} impl common::ResponseResult for Endpoint {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Expr { /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI. pub description: Option, /// Textual representation of an expression in Common Expression Language syntax. pub expression: Option, /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file. pub location: Option, /// 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. pub title: Option, } impl common::Part for Expr {} /// Request message for `GetIamPolicy` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services get iam policy projects](ProjectLocationNamespaceServiceGetIamPolicyCall) (request) /// * [locations namespaces get iam policy projects](ProjectLocationNamespaceGetIamPolicyCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GetIamPolicyRequest { /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`. pub options: Option, } impl common::RequestValue for GetIamPolicyRequest {} /// Encapsulates settings provided to GetIamPolicy. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GetPolicyOptions { /// 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). #[serde(rename = "requestedPolicyVersion")] pub requested_policy_version: Option, } impl common::Part for GetPolicyOptions {} /// The response message for RegistrationService.ListEndpoints. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services endpoints list projects](ProjectLocationNamespaceServiceEndpointListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListEndpointsResponse { /// The list of endpoints. pub endpoints: Option>, /// Token to retrieve the next page of results, or empty if there are no more results in the list. #[serde(rename = "nextPageToken")] pub next_page_token: Option, } impl common::ResponseResult for ListEndpointsResponse {} /// The response message for Locations.ListLocations. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations list projects](ProjectLocationListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListLocationsResponse { /// A list of locations that matches the specified filter in the request. pub locations: Option>, /// The standard List next-page token. #[serde(rename = "nextPageToken")] pub next_page_token: Option, } impl common::ResponseResult for ListLocationsResponse {} /// The response message for RegistrationService.ListNamespaces. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces list projects](ProjectLocationNamespaceListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListNamespacesResponse { /// The list of namespaces. pub namespaces: Option>, /// Token to retrieve the next page of results, or empty if there are no more results in the list. #[serde(rename = "nextPageToken")] pub next_page_token: Option, } impl common::ResponseResult for ListNamespacesResponse {} /// The response message for RegistrationService.ListServices. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services list projects](ProjectLocationNamespaceServiceListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListServicesResponse { /// Token to retrieve the next page of results, or empty if there are no more results in the list. #[serde(rename = "nextPageToken")] pub next_page_token: Option, /// The list of services. pub services: Option>, } impl common::ResponseResult for ListServicesResponse {} /// A resource that represents a Google Cloud location. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations get projects](ProjectLocationGetCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Location { /// The friendly name for this location, typically a nearby city name. For example, "Tokyo". #[serde(rename = "displayName")] pub display_name: Option, /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"} pub labels: Option>, /// The canonical id for this location. For example: `"us-east1"`. #[serde(rename = "locationId")] pub location_id: Option, /// Service-specific metadata. For example the available capacity at the given location. pub metadata: Option>, /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"` pub name: Option, } impl common::ResponseResult for Location {} /// A container for services. Namespaces allow administrators to group services together and define permissions for a collection of services. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces create projects](ProjectLocationNamespaceCreateCall) (request|response) /// * [locations namespaces get projects](ProjectLocationNamespaceGetCall) (response) /// * [locations namespaces patch projects](ProjectLocationNamespacePatchCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Namespace { /// 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. pub labels: Option>, /// Immutable. The resource name for the namespace in the format `projects/*/locations/*/namespaces/*`. pub name: Option, /// Output only. The globally unique identifier of the namespace in the UUID4 format. pub uid: Option, } impl common::RequestValue for Namespace {} impl common::ResponseResult for Namespace {} /// 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/). /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services get iam policy projects](ProjectLocationNamespaceServiceGetIamPolicyCall) (response) /// * [locations namespaces services set iam policy projects](ProjectLocationNamespaceServiceSetIamPolicyCall) (response) /// * [locations namespaces get iam policy projects](ProjectLocationNamespaceGetIamPolicyCall) (response) /// * [locations namespaces set iam policy projects](ProjectLocationNamespaceSetIamPolicyCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Policy { /// 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`. pub bindings: Option>, /// `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. #[serde_as(as = "Option")] pub etag: Option>, /// 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). pub version: Option, } impl common::ResponseResult for Policy {} /// The request message for LookupService.ResolveService. Looks up a service by its name, returns the service and its endpoints. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services resolve projects](ProjectLocationNamespaceServiceResolveCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ResolveServiceRequest { /// 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). #[serde(rename = "endpointFilter")] pub endpoint_filter: Option, /// 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. #[serde(rename = "maxEndpoints")] pub max_endpoints: Option, } impl common::RequestValue for ResolveServiceRequest {} /// The response message for LookupService.ResolveService. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services resolve projects](ProjectLocationNamespaceServiceResolveCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ResolveServiceResponse { /// no description provided pub service: Option, } impl common::ResponseResult for ResolveServiceResponse {} /// An individual service. A service contains a name and optional metadata. A service must exist before endpoints can be added to it. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services create projects](ProjectLocationNamespaceServiceCreateCall) (request|response) /// * [locations namespaces services get projects](ProjectLocationNamespaceServiceGetCall) (response) /// * [locations namespaces services patch projects](ProjectLocationNamespaceServicePatchCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Service { /// 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. pub annotations: Option>, /// Output only. Endpoints associated with this service. Returned on LookupService.ResolveService. Control plane clients should use RegistrationService.ListEndpoints. pub endpoints: Option>, /// Immutable. The resource name for the service in the format `projects/*/locations/*/namespaces/*/services/*`. pub name: Option, /// Output only. The globally unique identifier of the service in the UUID4 format. pub uid: Option, } impl common::RequestValue for Service {} impl common::ResponseResult for Service {} /// Request message for `SetIamPolicy` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services set iam policy projects](ProjectLocationNamespaceServiceSetIamPolicyCall) (request) /// * [locations namespaces set iam policy projects](ProjectLocationNamespaceSetIamPolicyCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct SetIamPolicyRequest { /// 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. pub policy: Option, } impl common::RequestValue for SetIamPolicyRequest {} /// Request message for `TestIamPermissions` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services test iam permissions projects](ProjectLocationNamespaceServiceTestIamPermissionCall) (request) /// * [locations namespaces test iam permissions projects](ProjectLocationNamespaceTestIamPermissionCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct TestIamPermissionsRequest { /// 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). pub permissions: Option>, } impl common::RequestValue for TestIamPermissionsRequest {} /// Response message for `TestIamPermissions` method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [locations namespaces services test iam permissions projects](ProjectLocationNamespaceServiceTestIamPermissionCall) (response) /// * [locations namespaces test iam permissions projects](ProjectLocationNamespaceTestIamPermissionCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct TestIamPermissionsResponse { /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed. pub permissions: Option>, } impl common::ResponseResult for TestIamPermissionsResponse {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *project* resources. /// It is not used directly, but through the [`ServiceDirectory`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_servicedirectory1 as servicedirectory1; /// /// # async fn dox() { /// use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// let secret: yup_oauth2::ApplicationSecret = Default::default(); /// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// secret, /// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// /// let client = hyper_util::client::legacy::Client::builder( /// hyper_util::rt::TokioExecutor::new() /// ) /// .build( /// hyper_rustls::HttpsConnectorBuilder::new() /// .with_native_roots() /// .unwrap() /// .https_or_http() /// .enable_http1() /// .build() /// ); /// let mut hub = ServiceDirectory::new(client, auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // 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(...)` /// // to build up your call. /// let rb = hub.projects(); /// # } /// ``` pub struct ProjectMethods<'a, C> where C: 'a, { hub: &'a ServiceDirectory, } impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {} impl<'a, C> ProjectMethods<'a, C> { /// Create a builder to help you perform the following task: /// /// Creates an endpoint, and returns the new endpoint. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Required. The resource name of the service that this endpoint provides. pub fn locations_namespaces_services_endpoints_create( &self, request: Endpoint, parent: &str, ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> { ProjectLocationNamespaceServiceEndpointCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _endpoint_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes an endpoint. /// /// # Arguments /// /// * `name` - Required. The name of the endpoint to delete. pub fn locations_namespaces_services_endpoints_delete( &self, name: &str, ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> { ProjectLocationNamespaceServiceEndpointDeleteCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets an endpoint. /// /// # Arguments /// /// * `name` - Required. The name of the endpoint to get. pub fn locations_namespaces_services_endpoints_get( &self, name: &str, ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> { ProjectLocationNamespaceServiceEndpointGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all endpoints. /// /// # Arguments /// /// * `parent` - Required. The resource name of the service whose endpoints you'd like to list. pub fn locations_namespaces_services_endpoints_list( &self, parent: &str, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> { ProjectLocationNamespaceServiceEndpointListCall { hub: self.hub, _parent: parent.to_string(), _page_token: Default::default(), _page_size: Default::default(), _order_by: Default::default(), _filter: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an endpoint. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Immutable. The resource name for the endpoint in the format `projects/*/locations/*/namespaces/*/services/*/endpoints/*`. pub fn locations_namespaces_services_endpoints_patch( &self, request: Endpoint, name: &str, ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> { ProjectLocationNamespaceServiceEndpointPatchCall { hub: self.hub, _request: request, _name: name.to_string(), _update_mask: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a service, and returns the new service. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Required. The resource name of the namespace this service will belong to. pub fn locations_namespaces_services_create( &self, request: Service, parent: &str, ) -> ProjectLocationNamespaceServiceCreateCall<'a, C> { ProjectLocationNamespaceServiceCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _service_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a service. This also deletes all endpoints associated with the service. /// /// # Arguments /// /// * `name` - Required. The name of the service to delete. pub fn locations_namespaces_services_delete( &self, name: &str, ) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> { ProjectLocationNamespaceServiceDeleteCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a service. /// /// # Arguments /// /// * `name` - Required. The name of the service to get. pub fn locations_namespaces_services_get( &self, name: &str, ) -> ProjectLocationNamespaceServiceGetCall<'a, C> { ProjectLocationNamespaceServiceGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets the IAM Policy for a resource (namespace or service only). /// /// # Arguments /// /// * `request` - No description provided. /// * `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. pub fn locations_namespaces_services_get_iam_policy( &self, request: GetIamPolicyRequest, resource: &str, ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> { ProjectLocationNamespaceServiceGetIamPolicyCall { hub: self.hub, _request: request, _resource: resource.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all services belonging to a namespace. /// /// # Arguments /// /// * `parent` - Required. The resource name of the namespace whose services you'd like to list. pub fn locations_namespaces_services_list( &self, parent: &str, ) -> ProjectLocationNamespaceServiceListCall<'a, C> { ProjectLocationNamespaceServiceListCall { hub: self.hub, _parent: parent.to_string(), _page_token: Default::default(), _page_size: Default::default(), _order_by: Default::default(), _filter: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a service. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Immutable. The resource name for the service in the format `projects/*/locations/*/namespaces/*/services/*`. pub fn locations_namespaces_services_patch( &self, request: Service, name: &str, ) -> ProjectLocationNamespaceServicePatchCall<'a, C> { ProjectLocationNamespaceServicePatchCall { hub: self.hub, _request: request, _name: name.to_string(), _update_mask: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Returns a service and its associated endpoints. Resolving a service is not considered an active developer method. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The name of the service to resolve. pub fn locations_namespaces_services_resolve( &self, request: ResolveServiceRequest, name: &str, ) -> ProjectLocationNamespaceServiceResolveCall<'a, C> { ProjectLocationNamespaceServiceResolveCall { hub: self.hub, _request: request, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Sets the IAM Policy for a resource (namespace or service only). /// /// # Arguments /// /// * `request` - No description provided. /// * `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. pub fn locations_namespaces_services_set_iam_policy( &self, request: SetIamPolicyRequest, resource: &str, ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> { ProjectLocationNamespaceServiceSetIamPolicyCall { hub: self.hub, _request: request, _resource: resource.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Tests IAM permissions for a resource (namespace or service only). /// /// # Arguments /// /// * `request` - No description provided. /// * `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. pub fn locations_namespaces_services_test_iam_permissions( &self, request: TestIamPermissionsRequest, resource: &str, ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> { ProjectLocationNamespaceServiceTestIamPermissionCall { hub: self.hub, _request: request, _resource: resource.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a namespace, and returns the new namespace. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Required. The resource name of the project and location the namespace will be created in. pub fn locations_namespaces_create( &self, request: Namespace, parent: &str, ) -> ProjectLocationNamespaceCreateCall<'a, C> { ProjectLocationNamespaceCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _namespace_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a namespace. This also deletes all services and endpoints in the namespace. /// /// # Arguments /// /// * `name` - Required. The name of the namespace to delete. pub fn locations_namespaces_delete( &self, name: &str, ) -> ProjectLocationNamespaceDeleteCall<'a, C> { ProjectLocationNamespaceDeleteCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a namespace. /// /// # Arguments /// /// * `name` - Required. The name of the namespace to retrieve. pub fn locations_namespaces_get(&self, name: &str) -> ProjectLocationNamespaceGetCall<'a, C> { ProjectLocationNamespaceGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets the IAM Policy for a resource (namespace or service only). /// /// # Arguments /// /// * `request` - No description provided. /// * `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. pub fn locations_namespaces_get_iam_policy( &self, request: GetIamPolicyRequest, resource: &str, ) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> { ProjectLocationNamespaceGetIamPolicyCall { hub: self.hub, _request: request, _resource: resource.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all namespaces. /// /// # Arguments /// /// * `parent` - Required. The resource name of the project and location whose namespaces you'd like to list. pub fn locations_namespaces_list( &self, parent: &str, ) -> ProjectLocationNamespaceListCall<'a, C> { ProjectLocationNamespaceListCall { hub: self.hub, _parent: parent.to_string(), _page_token: Default::default(), _page_size: Default::default(), _order_by: Default::default(), _filter: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a namespace. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Immutable. The resource name for the namespace in the format `projects/*/locations/*/namespaces/*`. pub fn locations_namespaces_patch( &self, request: Namespace, name: &str, ) -> ProjectLocationNamespacePatchCall<'a, C> { ProjectLocationNamespacePatchCall { hub: self.hub, _request: request, _name: name.to_string(), _update_mask: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Sets the IAM Policy for a resource (namespace or service only). /// /// # Arguments /// /// * `request` - No description provided. /// * `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. pub fn locations_namespaces_set_iam_policy( &self, request: SetIamPolicyRequest, resource: &str, ) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> { ProjectLocationNamespaceSetIamPolicyCall { hub: self.hub, _request: request, _resource: resource.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Tests IAM permissions for a resource (namespace or service only). /// /// # Arguments /// /// * `request` - No description provided. /// * `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. pub fn locations_namespaces_test_iam_permissions( &self, request: TestIamPermissionsRequest, resource: &str, ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> { ProjectLocationNamespaceTestIamPermissionCall { hub: self.hub, _request: request, _resource: resource.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets information about a location. /// /// # Arguments /// /// * `name` - Resource name for the location. pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> { ProjectLocationGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists information about the supported locations for this service. /// /// # Arguments /// /// * `name` - The resource that owns the locations collection, if applicable. pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> { ProjectLocationListCall { hub: self.hub, _name: name.to_string(), _page_token: Default::default(), _page_size: Default::default(), _filter: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Creates an endpoint, and returns the new endpoint. /// /// A builder for the *locations.namespaces.services.endpoints.create* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::Endpoint; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Endpoint::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_endpoints_create(req, "parent") /// .endpoint_id("voluptua.") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: Endpoint, _parent: String, _endpoint_id: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Endpoint)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.endpoints.create", http_method: hyper::Method::POST, }); for &field in ["alt", "parent", "endpointId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._endpoint_id.as_ref() { params.push("endpointId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/endpoints"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: Endpoint, ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> { self._request = new_value; self } /// Required. The resource name of the service that this endpoint provides. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> { self._parent = new_value.to_string(); self } /// 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. /// /// Sets the *endpoint id* query property to the given value. pub fn endpoint_id( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> { self._endpoint_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope( mut self, scope: St, ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes an endpoint. /// /// A builder for the *locations.namespaces.services.endpoints.delete* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_endpoints_delete("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.endpoints.delete", http_method: hyper::Method::DELETE, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The name of the endpoint to delete. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope( mut self, scope: St, ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets an endpoint. /// /// A builder for the *locations.namespaces.services.endpoints.get* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_endpoints_get("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceEndpointGetCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointGetCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Endpoint)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.endpoints.get", http_method: hyper::Method::GET, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The name of the endpoint to get. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope( mut self, scope: St, ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointGetCall<'a, C> { self._scopes.clear(); self } } /// Lists all endpoints. /// /// A builder for the *locations.namespaces.services.endpoints.list* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_endpoints_list("parent") /// .page_token("amet.") /// .page_size(-59) /// .order_by("amet.") /// .filter("duo") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceEndpointListCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _parent: String, _page_token: Option, _page_size: Option, _order_by: Option, _filter: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointListCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceEndpointListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListEndpointsResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.endpoints.list", http_method: hyper::Method::GET, }); for &field in [ "alt", "parent", "pageToken", "pageSize", "orderBy", "filter", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._page_size.as_ref() { params.push("pageSize", value.to_string()); } if let Some(value) = self._order_by.as_ref() { params.push("orderBy", value); } if let Some(value) = self._filter.as_ref() { params.push("filter", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/endpoints"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The resource name of the service whose endpoints you'd like to list. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> { self._parent = new_value.to_string(); self } /// Optional. The next_page_token value returned from a previous List request, if any. /// /// Sets the *page token* query property to the given value. pub fn page_token( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// Optional. The maximum number of items to return. /// /// Sets the *page size* query property to the given value. pub fn page_size( mut self, new_value: i32, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> { self._page_size = Some(new_value); self } /// 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. /// /// Sets the *order by* query property to the given value. pub fn order_by( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> { self._order_by = Some(new_value.to_string()); self } /// 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). /// /// Sets the *filter* query property to the given value. pub fn filter( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> { self._filter = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope( mut self, scope: St, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointListCall<'a, C> { self._scopes.clear(); self } } /// Updates an endpoint. /// /// A builder for the *locations.namespaces.services.endpoints.patch* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::Endpoint; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Endpoint::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_endpoints_patch(req, "name") /// .update_mask(FieldMask::new::<&str>(&[])) /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: Endpoint, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Endpoint)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.endpoints.patch", http_method: hyper::Method::PATCH, }); for &field in ["alt", "name", "updateMask"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("name", self._name); if let Some(value) = self._update_mask.as_ref() { params.push("updateMask", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: Endpoint, ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> { self._request = new_value; self } /// Immutable. The resource name for the endpoint in the format `projects/*/locations/*/namespaces/*/services/*/endpoints/*`. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> { self._name = new_value.to_string(); self } /// Required. List of fields to be updated in this request. /// /// Sets the *update mask* query property to the given value. pub fn update_mask( mut self, new_value: common::FieldMask, ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> { self._update_mask = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope( mut self, scope: St, ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceEndpointPatchCall<'a, C> { self._scopes.clear(); self } } /// Creates a service, and returns the new service. /// /// A builder for the *locations.namespaces.services.create* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::Service; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Service::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_create(req, "parent") /// .service_id("Lorem") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceCreateCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: Service, _parent: String, _service_id: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceCreateCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Service)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.create", http_method: hyper::Method::POST, }); for &field in ["alt", "parent", "serviceId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._service_id.as_ref() { params.push("serviceId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/services"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: Service, ) -> ProjectLocationNamespaceServiceCreateCall<'a, C> { self._request = new_value; self } /// Required. The resource name of the namespace this service will belong to. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> ProjectLocationNamespaceServiceCreateCall<'a, C> { self._parent = new_value.to_string(); self } /// 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. /// /// Sets the *service id* query property to the given value. pub fn service_id( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceCreateCall<'a, C> { self._service_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceCreateCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceServiceCreateCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceServiceCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a service. This also deletes all endpoints associated with the service. /// /// A builder for the *locations.namespaces.services.delete* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_delete("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceDeleteCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceDeleteCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.delete", http_method: hyper::Method::DELETE, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The name of the service to delete. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a service. /// /// A builder for the *locations.namespaces.services.get* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_get("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceGetCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceGetCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Service)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.get", http_method: hyper::Method::GET, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The name of the service to get. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceServiceGetCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceGetCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceServiceGetCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceServiceGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespaceServiceGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceGetCall<'a, C> { self._scopes.clear(); self } } /// Gets the IAM Policy for a resource (namespace or service only). /// /// A builder for the *locations.namespaces.services.getIamPolicy* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::GetIamPolicyRequest; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GetIamPolicyRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_get_iam_policy(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: GetIamPolicyRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.getIamPolicy", http_method: hyper::Method::POST, }); for &field in ["alt", "resource"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("resource", self._resource); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+resource}", "resource")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["resource"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: GetIamPolicyRequest, ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> { self._request = new_value; self } /// 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. /// /// Sets the *resource* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> { self._resource = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope( mut self, scope: St, ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceGetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Lists all services belonging to a namespace. /// /// A builder for the *locations.namespaces.services.list* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_list("parent") /// .page_token("ipsum") /// .page_size(-88) /// .order_by("amet") /// .filter("duo") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceListCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _parent: String, _page_token: Option, _page_size: Option, _order_by: Option, _filter: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceListCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListServicesResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.list", http_method: hyper::Method::GET, }); for &field in [ "alt", "parent", "pageToken", "pageSize", "orderBy", "filter", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._page_size.as_ref() { params.push("pageSize", value.to_string()); } if let Some(value) = self._order_by.as_ref() { params.push("orderBy", value); } if let Some(value) = self._filter.as_ref() { params.push("filter", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/services"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The resource name of the namespace whose services you'd like to list. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> ProjectLocationNamespaceServiceListCall<'a, C> { self._parent = new_value.to_string(); self } /// Optional. The next_page_token value returned from a previous List request, if any. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ProjectLocationNamespaceServiceListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// Optional. The maximum number of items to return. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ProjectLocationNamespaceServiceListCall<'a, C> { self._page_size = Some(new_value); self } /// 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. /// /// Sets the *order by* query property to the given value. pub fn order_by(mut self, new_value: &str) -> ProjectLocationNamespaceServiceListCall<'a, C> { self._order_by = Some(new_value.to_string()); self } /// 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). /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> ProjectLocationNamespaceServiceListCall<'a, C> { self._filter = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceListCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceServiceListCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceServiceListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespaceServiceListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceListCall<'a, C> { self._scopes.clear(); self } } /// Updates a service. /// /// A builder for the *locations.namespaces.services.patch* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::Service; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Service::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_patch(req, "name") /// .update_mask(FieldMask::new::<&str>(&[])) /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServicePatchCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: Service, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServicePatchCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServicePatchCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Service)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.patch", http_method: hyper::Method::PATCH, }); for &field in ["alt", "name", "updateMask"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("name", self._name); if let Some(value) = self._update_mask.as_ref() { params.push("updateMask", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: Service, ) -> ProjectLocationNamespaceServicePatchCall<'a, C> { self._request = new_value; self } /// Immutable. The resource name for the service in the format `projects/*/locations/*/namespaces/*/services/*`. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceServicePatchCall<'a, C> { self._name = new_value.to_string(); self } /// Required. List of fields to be updated in this request. /// /// Sets the *update mask* query property to the given value. pub fn update_mask( mut self, new_value: common::FieldMask, ) -> ProjectLocationNamespaceServicePatchCall<'a, C> { self._update_mask = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServicePatchCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceServicePatchCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceServicePatchCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespaceServicePatchCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServicePatchCall<'a, C> { self._scopes.clear(); self } } /// Returns a service and its associated endpoints. Resolving a service is not considered an active developer method. /// /// A builder for the *locations.namespaces.services.resolve* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::ResolveServiceRequest; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ResolveServiceRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_resolve(req, "name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceResolveCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: ResolveServiceRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceResolveCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceResolveCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ResolveServiceResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.resolve", http_method: hyper::Method::POST, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}:resolve"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: ResolveServiceRequest, ) -> ProjectLocationNamespaceServiceResolveCall<'a, C> { self._request = new_value; self } /// Required. The name of the service to resolve. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceServiceResolveCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceResolveCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceServiceResolveCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceServiceResolveCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceResolveCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceResolveCall<'a, C> { self._scopes.clear(); self } } /// Sets the IAM Policy for a resource (namespace or service only). /// /// A builder for the *locations.namespaces.services.setIamPolicy* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::SetIamPolicyRequest; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = SetIamPolicyRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_set_iam_policy(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: SetIamPolicyRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.setIamPolicy", http_method: hyper::Method::POST, }); for &field in ["alt", "resource"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("resource", self._resource); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+resource}", "resource")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["resource"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: SetIamPolicyRequest, ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> { self._request = new_value; self } /// 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. /// /// Sets the *resource* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> { self._resource = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope( mut self, scope: St, ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceSetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Tests IAM permissions for a resource (namespace or service only). /// /// A builder for the *locations.namespaces.services.testIamPermissions* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::TestIamPermissionsRequest; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = TestIamPermissionsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_services_test_iam_permissions(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: TestIamPermissionsRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.services.testIamPermissions", http_method: hyper::Method::POST, }); for &field in ["alt", "resource"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("resource", self._resource); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+resource}", "resource")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["resource"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: TestIamPermissionsRequest, ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> { self._request = new_value; self } /// 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. /// /// Sets the *resource* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource( mut self, new_value: &str, ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> { self._resource = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope( mut self, scope: St, ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceServiceTestIamPermissionCall<'a, C> { self._scopes.clear(); self } } /// Creates a namespace, and returns the new namespace. /// /// A builder for the *locations.namespaces.create* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::Namespace; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Namespace::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_create(req, "parent") /// .namespace_id("est") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceCreateCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: Namespace, _parent: String, _namespace_id: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceCreateCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Namespace)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.create", http_method: hyper::Method::POST, }); for &field in ["alt", "parent", "namespaceId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._namespace_id.as_ref() { params.push("namespaceId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/namespaces"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Namespace) -> ProjectLocationNamespaceCreateCall<'a, C> { self._request = new_value; self } /// Required. The resource name of the project and location the namespace will be created in. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> ProjectLocationNamespaceCreateCall<'a, C> { self._parent = new_value.to_string(); self } /// 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. /// /// Sets the *namespace id* query property to the given value. pub fn namespace_id(mut self, new_value: &str) -> ProjectLocationNamespaceCreateCall<'a, C> { self._namespace_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceCreateCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceCreateCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespaceCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a namespace. This also deletes all services and endpoints in the namespace. /// /// A builder for the *locations.namespaces.delete* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_delete("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceDeleteCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceDeleteCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.delete", http_method: hyper::Method::DELETE, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::DELETE) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The name of the namespace to delete. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceDeleteCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceDeleteCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceDeleteCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespaceDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a namespace. /// /// A builder for the *locations.namespaces.get* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_get("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceGetCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceGetCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Namespace)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.get", http_method: hyper::Method::GET, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The name of the namespace to retrieve. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationNamespaceGetCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceGetCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceGetCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespaceGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceGetCall<'a, C> { self._scopes.clear(); self } } /// Gets the IAM Policy for a resource (namespace or service only). /// /// A builder for the *locations.namespaces.getIamPolicy* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::GetIamPolicyRequest; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GetIamPolicyRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_get_iam_policy(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceGetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: GetIamPolicyRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceGetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceGetIamPolicyCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.getIamPolicy", http_method: hyper::Method::POST, }); for &field in ["alt", "resource"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("resource", self._resource); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+resource}", "resource")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["resource"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: GetIamPolicyRequest, ) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> { self._request = new_value; self } /// 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. /// /// Sets the *resource* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource(mut self, new_value: &str) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> { self._resource = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceGetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Lists all namespaces. /// /// A builder for the *locations.namespaces.list* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_list("parent") /// .page_token("ea") /// .page_size(-99) /// .order_by("Lorem") /// .filter("eos") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceListCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _parent: String, _page_token: Option, _page_size: Option, _order_by: Option, _filter: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceListCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListNamespacesResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.list", http_method: hyper::Method::GET, }); for &field in [ "alt", "parent", "pageToken", "pageSize", "orderBy", "filter", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._page_size.as_ref() { params.push("pageSize", value.to_string()); } if let Some(value) = self._order_by.as_ref() { params.push("orderBy", value); } if let Some(value) = self._filter.as_ref() { params.push("filter", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/namespaces"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The resource name of the project and location whose namespaces you'd like to list. /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> ProjectLocationNamespaceListCall<'a, C> { self._parent = new_value.to_string(); self } /// Optional. The next_page_token value returned from a previous List request, if any. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ProjectLocationNamespaceListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// Optional. The maximum number of items to return. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ProjectLocationNamespaceListCall<'a, C> { self._page_size = Some(new_value); self } /// 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. /// /// Sets the *order by* query property to the given value. pub fn order_by(mut self, new_value: &str) -> ProjectLocationNamespaceListCall<'a, C> { self._order_by = Some(new_value.to_string()); self } /// 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). /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> ProjectLocationNamespaceListCall<'a, C> { self._filter = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceListCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceListCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespaceListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceListCall<'a, C> { self._scopes.clear(); self } } /// Updates a namespace. /// /// A builder for the *locations.namespaces.patch* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::Namespace; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Namespace::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_patch(req, "name") /// .update_mask(FieldMask::new::<&str>(&[])) /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespacePatchCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: Namespace, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespacePatchCall<'a, C> {} impl<'a, C> ProjectLocationNamespacePatchCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Namespace)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.patch", http_method: hyper::Method::PATCH, }); for &field in ["alt", "name", "updateMask"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("name", self._name); if let Some(value) = self._update_mask.as_ref() { params.push("updateMask", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::PATCH) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Namespace) -> ProjectLocationNamespacePatchCall<'a, C> { self._request = new_value; self } /// Immutable. The resource name for the namespace in the format `projects/*/locations/*/namespaces/*`. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationNamespacePatchCall<'a, C> { self._name = new_value.to_string(); self } /// Required. List of fields to be updated in this request. /// /// Sets the *update mask* query property to the given value. pub fn update_mask( mut self, new_value: common::FieldMask, ) -> ProjectLocationNamespacePatchCall<'a, C> { self._update_mask = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespacePatchCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespacePatchCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespacePatchCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespacePatchCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespacePatchCall<'a, C> { self._scopes.clear(); self } } /// Sets the IAM Policy for a resource (namespace or service only). /// /// A builder for the *locations.namespaces.setIamPolicy* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::SetIamPolicyRequest; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = SetIamPolicyRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_set_iam_policy(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceSetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: SetIamPolicyRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceSetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceSetIamPolicyCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.setIamPolicy", http_method: hyper::Method::POST, }); for &field in ["alt", "resource"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("resource", self._resource); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+resource}", "resource")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["resource"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: SetIamPolicyRequest, ) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> { self._request = new_value; self } /// 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. /// /// Sets the *resource* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource(mut self, new_value: &str) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> { self._resource = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceSetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Tests IAM permissions for a resource (namespace or service only). /// /// A builder for the *locations.namespaces.testIamPermissions* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// use servicedirectory1::api::TestIamPermissionsRequest; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = TestIamPermissionsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_namespaces_test_iam_permissions(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationNamespaceTestIamPermissionCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _request: TestIamPermissionsRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationNamespaceTestIamPermissionCall<'a, C> {} impl<'a, C> ProjectLocationNamespaceTestIamPermissionCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.namespaces.testIamPermissions", http_method: hyper::Method::POST, }); for &field in ["alt", "resource"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("resource", self._resource); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+resource}", "resource")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["resource"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: TestIamPermissionsRequest, ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> { self._request = new_value; self } /// 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. /// /// Sets the *resource* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource( mut self, new_value: &str, ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> { self._resource = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param( mut self, name: T, value: T, ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope( mut self, scope: St, ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationNamespaceTestIamPermissionCall<'a, C> { self._scopes.clear(); self } } /// Gets information about a location. /// /// A builder for the *locations.get* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_get("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGetCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {} impl<'a, C> ProjectLocationGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Location)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.get", http_method: hyper::Method::GET, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Resource name for the location. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationGetCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> { self._scopes.clear(); self } } /// Lists information about the supported locations for this service. /// /// A builder for the *locations.list* method supported by a *project* resource. /// It is not used directly, but through a [`ProjectMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_servicedirectory1 as servicedirectory1; /// # async fn dox() { /// # use servicedirectory1::{ServiceDirectory, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = ServiceDirectory::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().locations_list("name") /// .page_token("Stet") /// .page_size(-13) /// .filter("et") /// .doit().await; /// # } /// ``` pub struct ProjectLocationListCall<'a, C> where C: 'a, { hub: &'a ServiceDirectory, _name: String, _page_token: Option, _page_size: Option, _filter: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {} impl<'a, C> ProjectLocationListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "servicedirectory.projects.locations.list", http_method: hyper::Method::GET, }); for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("name", self._name); if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._page_size.as_ref() { params.push("pageSize", value.to_string()); } if let Some(value) = self._filter.as_ref() { params.push("filter", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}/locations"; if self._scopes.is_empty() { self._scopes .insert(Scope::CloudPlatform.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The resource that owns the locations collection, if applicable. /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> { self._name = new_value.to_string(); self } /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// The maximum number of results to return. If not set, the service selects a default. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> { self._page_size = Some(new_value); self } /// 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). /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> { self._filter = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> ProjectLocationListCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::CloudPlatform`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> ProjectLocationListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> ProjectLocationListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> { self._scopes.clear(); self } }