#![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 ManagedServiceForMicrosoftActiveDirectoryConsumerAPI related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_managedidentities1 as managedidentities1; /// use managedidentities1::api::Backup; /// use managedidentities1::{Result, Error}; /// # async fn dox() { /// use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = Backup::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_global_domains_backups_create(req, "parent") /// .backup_id("At") /// .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 ManagedServiceForMicrosoftActiveDirectoryConsumerAPI { pub client: common::Client, pub auth: Box, _user_agent: String, _base_url: String, _root_url: String, } impl common::Hub for ManagedServiceForMicrosoftActiveDirectoryConsumerAPI {} impl<'a, C> ManagedServiceForMicrosoftActiveDirectoryConsumerAPI { pub fn new( client: common::Client, auth: A, ) -> ManagedServiceForMicrosoftActiveDirectoryConsumerAPI { ManagedServiceForMicrosoftActiveDirectoryConsumerAPI { client, auth: Box::new(auth), _user_agent: "google-api-rust-client/6.0.0".to_string(), _base_url: "https://managedidentities.googleapis.com/".to_string(), _root_url: "https://managedidentities.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://managedidentities.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://managedidentities.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 ### // ########## /// Request message for AttachTrust /// /// # 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 global domains attach trust projects](ProjectLocationGlobalDomainAttachTrustCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct AttachTrustRequest { /// Required. The domain trust resource. pub trust: Option, } impl common::RequestValue for AttachTrustRequest {} /// Represents a Managed Microsoft Identities backup. /// /// # 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 global domains backups create projects](ProjectLocationGlobalDomainBackupCreateCall) (request) /// * [locations global domains backups get projects](ProjectLocationGlobalDomainBackupGetCall) (response) /// * [locations global domains backups patch projects](ProjectLocationGlobalDomainBackupPatchCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Backup { /// Output only. The time the backups was created. #[serde(rename = "createTime")] pub create_time: Option>, /// Optional. Resource labels to represent user provided metadata. pub labels: Option>, /// Output only. The unique name of the Backup in the form of `projects/{project_id}/locations/global/domains/{domain_name}/backups/{name}` pub name: Option, /// Output only. The current state of the backup. pub state: Option, /// Output only. Additional information about the current status of this backup, if available. #[serde(rename = "statusMessage")] pub status_message: Option, /// Output only. Indicates whether it’s an on-demand backup or scheduled. #[serde(rename = "type")] pub type_: Option, /// Output only. Last update time. #[serde(rename = "updateTime")] pub update_time: Option>, } impl common::RequestValue for Backup {} impl common::ResponseResult for Backup {} /// 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 {} /// The request message for Operations.CancelOperation. /// /// # 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 global operations cancel projects](ProjectLocationGlobalOperationCancelCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct CancelOperationRequest { _never_set: Option, } impl common::RequestValue for CancelOperationRequest {} /// Certificate used to configure LDAPS. /// /// 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 Certificate { /// The certificate expire time. #[serde(rename = "expireTime")] pub expire_time: Option>, /// The issuer of this certificate. #[serde(rename = "issuingCertificate")] pub issuing_certificate: Option>>, /// The certificate subject. pub subject: Option, /// The additional hostnames for the domain. #[serde(rename = "subjectAlternativeName")] pub subject_alternative_name: Option>, /// The certificate thumbprint which uniquely identifies the certificate. pub thumbprint: Option, } impl common::Part for Certificate {} /// CheckMigrationPermissionRequest is the request message for CheckMigrationPermission 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 global domains check migration permission projects](ProjectLocationGlobalDomainCheckMigrationPermissionCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct CheckMigrationPermissionRequest { _never_set: Option, } impl common::RequestValue for CheckMigrationPermissionRequest {} /// CheckMigrationPermissionResponse is the response message for CheckMigrationPermission 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 global domains check migration permission projects](ProjectLocationGlobalDomainCheckMigrationPermissionCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct CheckMigrationPermissionResponse { /// The state of SID filtering of all the domains which has trust established. #[serde(rename = "onpremDomains")] pub onprem_domains: Option>, /// The state of DomainMigration. pub state: Option, } impl common::ResponseResult for CheckMigrationPermissionResponse {} /// Request message for DetachTrust /// /// # 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 global domains detach trust projects](ProjectLocationGlobalDomainDetachTrustCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct DetachTrustRequest { /// Required. The domain trust resource to removed. pub trust: Option, } impl common::RequestValue for DetachTrustRequest {} /// DisableMigrationRequest is the request message for DisableMigration 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 global domains disable migration projects](ProjectLocationGlobalDomainDisableMigrationCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct DisableMigrationRequest { _never_set: Option, } impl common::RequestValue for DisableMigrationRequest {} /// Represents a managed Microsoft Active Directory domain. If the domain is being changed, it will be placed into the UPDATING state, which indicates that the resource is being reconciled. At this point, Get will reflect an intermediate state. /// /// # 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 global domains create projects](ProjectLocationGlobalDomainCreateCall) (request) /// * [locations global domains get projects](ProjectLocationGlobalDomainGetCall) (response) /// * [locations global domains patch projects](ProjectLocationGlobalDomainPatchCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Domain { /// Optional. The name of delegated administrator account used to perform Active Directory operations. If not specified, `setupadmin` will be used. pub admin: Option, /// Optional. Configuration for audit logs. True if audit logs are enabled, else false. Default is audit logs disabled. #[serde(rename = "auditLogsEnabled")] pub audit_logs_enabled: Option, /// Optional. The full names of the Google Compute Engine [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) the domain instance is connected to. Networks can be added using UpdateDomain. The domain is only available on networks listed in `authorized_networks`. If CIDR subnets overlap between networks, domain creation will fail. #[serde(rename = "authorizedNetworks")] pub authorized_networks: Option>, /// Output only. The time the instance was created. #[serde(rename = "createTime")] pub create_time: Option>, /// Output only. The fully-qualified domain name of the exposed domain used by clients to connect to the service. Similar to what would be chosen for an Active Directory set up on an internal network. pub fqdn: Option, /// Optional. Resource labels that can contain user-provided metadata. pub labels: Option>, /// Required. Locations where domain needs to be provisioned. The locations can be specified according to https://cloud.google.com/compute/docs/regions-zones, such as `us-west1` or `us-east4`. Each domain supports up to 4 locations, separated by commas. Each location will use a /26 block. pub locations: Option>, /// Required. The unique name of the domain using the form: `projects/{project_id}/locations/global/domains/{domain_name}`. pub name: Option, /// Required. The CIDR range of internal addresses that are reserved for this domain. Reserved networks must be /24 or larger. Ranges must be unique and non-overlapping with existing subnets in [Domain].[authorized_networks]. #[serde(rename = "reservedIpRange")] pub reserved_ip_range: Option, /// Output only. The current state of this domain. pub state: Option, /// Output only. Additional information about the current status of this domain, if available. #[serde(rename = "statusMessage")] pub status_message: Option, /// Output only. The current trusts associated with the domain. pub trusts: Option>, /// Output only. The last update time. #[serde(rename = "updateTime")] pub update_time: Option>, } impl common::RequestValue for Domain {} impl common::ResponseResult for Domain {} /// DomainJoinMachineRequest is the request message for DomainJoinMachine 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 global domains domain join machine projects](ProjectLocationGlobalDomainDomainJoinMachineCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct DomainJoinMachineRequest { /// Optional. force if True, forces domain join even if the computer account already exists. pub force: Option, /// Optional. OU name where the VM needs to be domain joined #[serde(rename = "ouName")] pub ou_name: Option, /// Required. Full instance id token of compute engine VM to verify instance identity. More about this: https://cloud.google.com/compute/docs/instances/verifying-instance-identity#request_signature #[serde(rename = "vmIdToken")] pub vm_id_token: Option, } impl common::RequestValue for DomainJoinMachineRequest {} /// DomainJoinMachineResponse is the response message for DomainJoinMachine 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 global domains domain join machine projects](ProjectLocationGlobalDomainDomainJoinMachineCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct DomainJoinMachineResponse { /// Offline domain join blob as the response #[serde(rename = "domainJoinBlob")] pub domain_join_blob: Option, } impl common::ResponseResult for DomainJoinMachineResponse {} /// 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 global operations cancel projects](ProjectLocationGlobalOperationCancelCall) (response) /// * [locations global operations delete projects](ProjectLocationGlobalOperationDeleteCall) (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 {} /// EnableMigrationRequest is the request message for EnableMigration 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 global domains enable migration projects](ProjectLocationGlobalDomainEnableMigrationCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct EnableMigrationRequest { /// Required. List of the on-prem domains to be migrated. #[serde(rename = "migratingDomains")] pub migrating_domains: Option>, } impl common::RequestValue for EnableMigrationRequest {} /// 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 {} /// ExtendSchemaRequest is the request message for ExtendSchema 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 global domains extend schema projects](ProjectLocationGlobalDomainExtendSchemaCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ExtendSchemaRequest { /// Required. Description for Schema Change. pub description: Option, /// File uploaded as a byte stream input. #[serde(rename = "fileContents")] #[serde_as(as = "Option")] pub file_contents: Option>, /// File stored in Cloud Storage bucket and represented in the form projects/{project_id}/buckets/{bucket_name}/objects/{object_name} File should be in the same project as the domain. #[serde(rename = "gcsPath")] pub gcs_path: Option, } impl common::RequestValue for ExtendSchemaRequest {} /// LDAPSSettings represents the ldaps settings for domain resource. LDAP is the Lightweight Directory Access Protocol, defined in https://tools.ietf.org/html/rfc4511. The settings object configures LDAP over SSL/TLS, whether it is over port 636 or the StartTLS operation. If LDAPSSettings is being changed, it will be placed into the UPDATING state, which indicates that the resource is being reconciled. At this point, Get will reflect an intermediate state. /// /// # 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 global domains get ldapssettings projects](ProjectLocationGlobalDomainGetLdapssettingCall) (response) /// * [locations global domains update ldapssettings projects](ProjectLocationGlobalDomainUpdateLdapssettingCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct LDAPSSettings { /// Output only. The certificate used to configure LDAPS. Certificates can be chained with a maximum length of 15. pub certificate: Option, /// Input only. The password used to encrypt the uploaded PFX certificate. #[serde(rename = "certificatePassword")] pub certificate_password: Option, /// Input only. The uploaded PKCS12-formatted certificate to configure LDAPS with. It will enable the domain controllers in this domain to accept LDAPS connections (either LDAP over SSL/TLS or the StartTLS operation). A valid certificate chain must form a valid x.509 certificate chain (or be comprised of a single self-signed certificate. It must be encrypted with either: 1) PBES2 + PBKDF2 + AES256 encryption and SHA256 PRF; or 2) pbeWithSHA1And3-KeyTripleDES-CBC Private key must be included for the leaf / single self-signed certificate. Note: For a fqdn your-example-domain.com, the wildcard fqdn is *.your-example-domain.com. Specifically the leaf certificate must have: - Either a blank subject or a subject with CN matching the wildcard fqdn. - Exactly two SANs - the fqdn and wildcard fqdn. - Encipherment and digital key signature key usages. - Server authentication extended key usage (OID=1.3.6.1.5.5.7.3.1) - Private key must be in one of the following formats: RSA, ECDSA, ED25519. - Private key must have appropriate key length: 2048 for RSA, 256 for ECDSA - Signature algorithm of the leaf certificate cannot be MD2, MD5 or SHA1. #[serde(rename = "certificatePfx")] #[serde_as(as = "Option")] pub certificate_pfx: Option>, /// The resource name of the LDAPS settings. Uses the form: `projects/{project}/locations/{location}/domains/{domain}`. pub name: Option, /// Output only. The current state of this LDAPS settings. pub state: Option, /// Output only. Last update time. #[serde(rename = "updateTime")] pub update_time: Option>, } impl common::RequestValue for LDAPSSettings {} impl common::ResponseResult for LDAPSSettings {} /// ListBackupsResponse is the response message for ListBackups 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 global domains backups list projects](ProjectLocationGlobalDomainBackupListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListBackupsResponse { /// A list of Cloud AD backups in the domain. pub backups: 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, /// Locations that could not be reached. pub unreachable: Option>, } impl common::ResponseResult for ListBackupsResponse {} /// Response message for ListDomains /// /// # 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 global domains list projects](ProjectLocationGlobalDomainListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListDomainsResponse { /// A list of Managed Identities Service domains in the project. pub domains: Option>, /// A 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, /// A list of locations that could not be reached. pub unreachable: Option>, } impl common::ResponseResult for ListDomainsResponse {} /// 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 Operations.ListOperations. /// /// # 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 global operations list projects](ProjectLocationGlobalOperationListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListOperationsResponse { /// The standard List next-page token. #[serde(rename = "nextPageToken")] pub next_page_token: Option, /// A list of operations that matches the specified filter in the request. pub operations: Option>, } impl common::ResponseResult for ListOperationsResponse {} /// ListPeeringsResponse is the response message for ListPeerings 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 global peerings list projects](ProjectLocationGlobalPeeringListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListPeeringsResponse { /// 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, /// A list of Managed Identities Service Peerings in the project. pub peerings: Option>, /// Locations that could not be reached. pub unreachable: Option>, } impl common::ResponseResult for ListPeeringsResponse {} /// ListSqlIntegrationsResponse is the response message for ListSqlIntegrations 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 global domains sql integrations list projects](ProjectLocationGlobalDomainSqlIntegrationListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListSqlIntegrationsResponse { /// 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, /// A list of SQLIntegrations of a domain. #[serde(rename = "sqlIntegrations")] pub sql_integrations: Option>, /// A list of locations that could not be reached. pub unreachable: Option>, } impl common::ResponseResult for ListSqlIntegrationsResponse {} /// 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 {} /// OnPremDomainDetails is the message which contains details of on-prem domain which is trusted and needs to be migrated. /// /// 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 OnPremDomainDetails { /// Optional. Option to disable SID filtering. #[serde(rename = "disableSidFiltering")] pub disable_sid_filtering: Option, /// Required. FQDN of the on-prem domain being migrated. #[serde(rename = "domainName")] pub domain_name: Option, } impl common::Part for OnPremDomainDetails {} /// OnPremDomainDetails is the message which contains details of on-prem domain which is trusted and needs to be migrated. /// /// 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 OnPremDomainSIDDetails { /// FQDN of the on-prem domain being migrated. pub name: Option, /// Current SID filtering state. #[serde(rename = "sidFilteringState")] pub sid_filtering_state: Option, } impl common::Part for OnPremDomainSIDDetails {} /// This resource represents a long-running operation that is the result of a network API call. /// /// # 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 global domains backups create projects](ProjectLocationGlobalDomainBackupCreateCall) (response) /// * [locations global domains backups delete projects](ProjectLocationGlobalDomainBackupDeleteCall) (response) /// * [locations global domains backups patch projects](ProjectLocationGlobalDomainBackupPatchCall) (response) /// * [locations global domains attach trust projects](ProjectLocationGlobalDomainAttachTrustCall) (response) /// * [locations global domains create projects](ProjectLocationGlobalDomainCreateCall) (response) /// * [locations global domains delete projects](ProjectLocationGlobalDomainDeleteCall) (response) /// * [locations global domains detach trust projects](ProjectLocationGlobalDomainDetachTrustCall) (response) /// * [locations global domains disable migration projects](ProjectLocationGlobalDomainDisableMigrationCall) (response) /// * [locations global domains enable migration projects](ProjectLocationGlobalDomainEnableMigrationCall) (response) /// * [locations global domains extend schema projects](ProjectLocationGlobalDomainExtendSchemaCall) (response) /// * [locations global domains patch projects](ProjectLocationGlobalDomainPatchCall) (response) /// * [locations global domains reconfigure trust projects](ProjectLocationGlobalDomainReconfigureTrustCall) (response) /// * [locations global domains restore projects](ProjectLocationGlobalDomainRestoreCall) (response) /// * [locations global domains update ldapssettings projects](ProjectLocationGlobalDomainUpdateLdapssettingCall) (response) /// * [locations global domains validate trust projects](ProjectLocationGlobalDomainValidateTrustCall) (response) /// * [locations global operations get projects](ProjectLocationGlobalOperationGetCall) (response) /// * [locations global peerings create projects](ProjectLocationGlobalPeeringCreateCall) (response) /// * [locations global peerings delete projects](ProjectLocationGlobalPeeringDeleteCall) (response) /// * [locations global peerings patch projects](ProjectLocationGlobalPeeringPatchCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Operation { /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available. pub done: Option, /// The error result of the operation in case of failure or cancellation. pub error: Option, /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. pub metadata: Option>, /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. pub name: Option, /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. pub response: Option>, } impl common::ResponseResult for Operation {} /// Represents a Managed Service for Microsoft Active Directory Peering. /// /// # 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 global peerings create projects](ProjectLocationGlobalPeeringCreateCall) (request) /// * [locations global peerings get projects](ProjectLocationGlobalPeeringGetCall) (response) /// * [locations global peerings patch projects](ProjectLocationGlobalPeeringPatchCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Peering { /// Required. The full names of the Google Compute Engine [networks](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) to which the instance is connected. Caller needs to make sure that CIDR subnets do not overlap between networks, else peering creation will fail. #[serde(rename = "authorizedNetwork")] pub authorized_network: Option, /// Output only. The time the instance was created. #[serde(rename = "createTime")] pub create_time: Option>, /// Required. Full domain resource path for the Managed AD Domain involved in peering. The resource path should be in the form: `projects/{project_id}/locations/global/domains/{domain_name}` #[serde(rename = "domainResource")] pub domain_resource: Option, /// Optional. Resource labels to represent user-provided metadata. pub labels: Option>, /// Output only. Unique name of the peering in this scope including projects and location using the form: `projects/{project_id}/locations/global/peerings/{peering_id}`. pub name: Option, /// Output only. The current state of this Peering. pub state: Option, /// Output only. Additional information about the current status of this peering, if available. #[serde(rename = "statusMessage")] pub status_message: Option, /// Output only. Last update time. #[serde(rename = "updateTime")] pub update_time: Option>, } impl common::RequestValue for Peering {} impl common::ResponseResult for Peering {} /// 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 global domains backups get iam policy projects](ProjectLocationGlobalDomainBackupGetIamPolicyCall) (response) /// * [locations global domains backups set iam policy projects](ProjectLocationGlobalDomainBackupSetIamPolicyCall) (response) /// * [locations global domains get iam policy projects](ProjectLocationGlobalDomainGetIamPolicyCall) (response) /// * [locations global domains set iam policy projects](ProjectLocationGlobalDomainSetIamPolicyCall) (response) /// * [locations global peerings get iam policy projects](ProjectLocationGlobalPeeringGetIamPolicyCall) (response) /// * [locations global peerings set iam policy projects](ProjectLocationGlobalPeeringSetIamPolicyCall) (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 {} /// Request message for ReconfigureTrust /// /// # 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 global domains reconfigure trust projects](ProjectLocationGlobalDomainReconfigureTrustCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ReconfigureTrustRequest { /// Required. The target DNS server IP addresses to resolve the remote domain involved in the trust. #[serde(rename = "targetDnsIpAddresses")] pub target_dns_ip_addresses: Option>, /// Required. The fully-qualified target domain name which will be in trust with current domain. #[serde(rename = "targetDomainName")] pub target_domain_name: Option, } impl common::RequestValue for ReconfigureTrustRequest {} /// Request message for ResetAdminPassword /// /// # 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 global domains reset admin password projects](ProjectLocationGlobalDomainResetAdminPasswordCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ResetAdminPasswordRequest { _never_set: Option, } impl common::RequestValue for ResetAdminPasswordRequest {} /// Response message for ResetAdminPassword /// /// # 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 global domains reset admin password projects](ProjectLocationGlobalDomainResetAdminPasswordCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ResetAdminPasswordResponse { /// A random password. See admin for more information. pub password: Option, } impl common::ResponseResult for ResetAdminPasswordResponse {} /// RestoreDomainRequest is the request received by RestoreDomain rpc /// /// # 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 global domains restore projects](ProjectLocationGlobalDomainRestoreCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct RestoreDomainRequest { /// Required. ID of the backup to be restored #[serde(rename = "backupId")] pub backup_id: Option, } impl common::RequestValue for RestoreDomainRequest {} /// 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 global domains backups set iam policy projects](ProjectLocationGlobalDomainBackupSetIamPolicyCall) (request) /// * [locations global domains set iam policy projects](ProjectLocationGlobalDomainSetIamPolicyCall) (request) /// * [locations global peerings set iam policy projects](ProjectLocationGlobalPeeringSetIamPolicyCall) (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 {} /// Represents the SQL instance integrated with Managed AD. /// /// # 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 global domains sql integrations get projects](ProjectLocationGlobalDomainSqlIntegrationGetCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct SqlIntegration { /// Output only. The time the SQL integration was created. #[serde(rename = "createTime")] pub create_time: Option>, /// The unique name of the SQL integration in the form of `projects/{project_id}/locations/global/domains/{domain_name}/sqlIntegrations/{sql_integration}` pub name: Option, /// The full resource name of an integrated SQL instance #[serde(rename = "sqlInstance")] pub sql_instance: Option, /// Output only. The current state of the SQL integration. pub state: Option, /// Output only. The time the SQL integration was updated. #[serde(rename = "updateTime")] pub update_time: Option>, } impl common::ResponseResult for SqlIntegration {} /// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). /// /// 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 Status { /// The status code, which should be an enum value of google.rpc.Code. pub code: Option, /// A list of messages that carry the error details. There is a common set of message types for APIs to use. pub details: Option>>, /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. pub message: Option, } impl common::Part for Status {} /// 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 global domains backups test iam permissions projects](ProjectLocationGlobalDomainBackupTestIamPermissionCall) (request) /// * [locations global domains test iam permissions projects](ProjectLocationGlobalDomainTestIamPermissionCall) (request) /// * [locations global peerings test iam permissions projects](ProjectLocationGlobalPeeringTestIamPermissionCall) (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 global domains backups test iam permissions projects](ProjectLocationGlobalDomainBackupTestIamPermissionCall) (response) /// * [locations global domains test iam permissions projects](ProjectLocationGlobalDomainTestIamPermissionCall) (response) /// * [locations global peerings test iam permissions projects](ProjectLocationGlobalPeeringTestIamPermissionCall) (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 {} /// Represents a relationship between two domains. This allows a controller in one domain to authenticate a user in another domain. If the trust is being changed, it will be placed into the UPDATING state, which indicates that the resource is being reconciled. At this point, Get will reflect an intermediate state. /// /// 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 Trust { /// Output only. The time the instance was created. #[serde(rename = "createTime")] pub create_time: Option>, /// Output only. The last heartbeat time when the trust was known to be connected. #[serde(rename = "lastTrustHeartbeatTime")] pub last_trust_heartbeat_time: Option>, /// Optional. The trust authentication type, which decides whether the trusted side has forest/domain wide access or selective access to an approved set of resources. #[serde(rename = "selectiveAuthentication")] pub selective_authentication: Option, /// Output only. The current state of the trust. pub state: Option, /// Output only. Additional information about the current state of the trust, if available. #[serde(rename = "stateDescription")] pub state_description: Option, /// Required. The target DNS server IP addresses which can resolve the remote domain involved in the trust. #[serde(rename = "targetDnsIpAddresses")] pub target_dns_ip_addresses: Option>, /// Required. The fully qualified target domain name which will be in trust with the current domain. #[serde(rename = "targetDomainName")] pub target_domain_name: Option, /// Required. The trust direction, which decides if the current domain is trusted, trusting, or both. #[serde(rename = "trustDirection")] pub trust_direction: Option, /// Required. The trust secret used for the handshake with the target domain. This will not be stored. #[serde(rename = "trustHandshakeSecret")] pub trust_handshake_secret: Option, /// Required. The type of trust represented by the trust resource. #[serde(rename = "trustType")] pub trust_type: Option, /// Output only. The last update time. #[serde(rename = "updateTime")] pub update_time: Option>, } impl common::Part for Trust {} /// Request message for ValidateTrust /// /// # 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 global domains validate trust projects](ProjectLocationGlobalDomainValidateTrustCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ValidateTrustRequest { /// Required. The domain trust to validate trust state for. pub trust: Option, } impl common::RequestValue for ValidateTrustRequest {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *project* resources. /// It is not used directly, but through the [`ManagedServiceForMicrosoftActiveDirectoryConsumerAPI`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_managedidentities1 as managedidentities1; /// /// # async fn dox() { /// use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::new(client, auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `locations_get(...)`, `locations_global_domains_attach_trust(...)`, `locations_global_domains_backups_create(...)`, `locations_global_domains_backups_delete(...)`, `locations_global_domains_backups_get(...)`, `locations_global_domains_backups_get_iam_policy(...)`, `locations_global_domains_backups_list(...)`, `locations_global_domains_backups_patch(...)`, `locations_global_domains_backups_set_iam_policy(...)`, `locations_global_domains_backups_test_iam_permissions(...)`, `locations_global_domains_check_migration_permission(...)`, `locations_global_domains_create(...)`, `locations_global_domains_delete(...)`, `locations_global_domains_detach_trust(...)`, `locations_global_domains_disable_migration(...)`, `locations_global_domains_domain_join_machine(...)`, `locations_global_domains_enable_migration(...)`, `locations_global_domains_extend_schema(...)`, `locations_global_domains_get(...)`, `locations_global_domains_get_iam_policy(...)`, `locations_global_domains_get_ldapssettings(...)`, `locations_global_domains_list(...)`, `locations_global_domains_patch(...)`, `locations_global_domains_reconfigure_trust(...)`, `locations_global_domains_reset_admin_password(...)`, `locations_global_domains_restore(...)`, `locations_global_domains_set_iam_policy(...)`, `locations_global_domains_sql_integrations_get(...)`, `locations_global_domains_sql_integrations_list(...)`, `locations_global_domains_test_iam_permissions(...)`, `locations_global_domains_update_ldapssettings(...)`, `locations_global_domains_validate_trust(...)`, `locations_global_operations_cancel(...)`, `locations_global_operations_delete(...)`, `locations_global_operations_get(...)`, `locations_global_operations_list(...)`, `locations_global_peerings_create(...)`, `locations_global_peerings_delete(...)`, `locations_global_peerings_get(...)`, `locations_global_peerings_get_iam_policy(...)`, `locations_global_peerings_list(...)`, `locations_global_peerings_patch(...)`, `locations_global_peerings_set_iam_policy(...)`, `locations_global_peerings_test_iam_permissions(...)` and `locations_list(...)` /// // to build up your call. /// let rb = hub.projects(); /// # } /// ``` pub struct ProjectMethods<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, } 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 a Backup for a domain. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_backups_create( &self, request: Backup, parent: &str, ) -> ProjectLocationGlobalDomainBackupCreateCall<'a, C> { ProjectLocationGlobalDomainBackupCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _backup_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes identified Backup. /// /// # Arguments /// /// * `name` - Required. The backup resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}/backups/{backup_id}` pub fn locations_global_domains_backups_delete( &self, name: &str, ) -> ProjectLocationGlobalDomainBackupDeleteCall<'a, C> { ProjectLocationGlobalDomainBackupDeleteCall { 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 details of a single Backup. /// /// # Arguments /// /// * `name` - Required. The backup resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}/backups/{backup_id}` pub fn locations_global_domains_backups_get( &self, name: &str, ) -> ProjectLocationGlobalDomainBackupGetCall<'a, C> { ProjectLocationGlobalDomainBackupGetCall { 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 access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. /// /// # Arguments /// /// * `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_global_domains_backups_get_iam_policy( &self, resource: &str, ) -> ProjectLocationGlobalDomainBackupGetIamPolicyCall<'a, C> { ProjectLocationGlobalDomainBackupGetIamPolicyCall { hub: self.hub, _resource: resource.to_string(), _options_requested_policy_version: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists Backup in a given project. /// /// # Arguments /// /// * `parent` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_backups_list( &self, parent: &str, ) -> ProjectLocationGlobalDomainBackupListCall<'a, C> { ProjectLocationGlobalDomainBackupListCall { 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 the labels for specified Backup. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Output only. The unique name of the Backup in the form of `projects/{project_id}/locations/global/domains/{domain_name}/backups/{name}` pub fn locations_global_domains_backups_patch( &self, request: Backup, name: &str, ) -> ProjectLocationGlobalDomainBackupPatchCall<'a, C> { ProjectLocationGlobalDomainBackupPatchCall { 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 access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. /// /// # 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_global_domains_backups_set_iam_policy( &self, request: SetIamPolicyRequest, resource: &str, ) -> ProjectLocationGlobalDomainBackupSetIamPolicyCall<'a, C> { ProjectLocationGlobalDomainBackupSetIamPolicyCall { 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: /// /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. /// /// # 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_global_domains_backups_test_iam_permissions( &self, request: TestIamPermissionsRequest, resource: &str, ) -> ProjectLocationGlobalDomainBackupTestIamPermissionCall<'a, C> { ProjectLocationGlobalDomainBackupTestIamPermissionCall { 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 details of a single sqlIntegration. /// /// # Arguments /// /// * `name` - Required. SQLIntegration resource name using the form: `projects/{project_id}/locations/global/domains/{domain}/sqlIntegrations/{name}` pub fn locations_global_domains_sql_integrations_get( &self, name: &str, ) -> ProjectLocationGlobalDomainSqlIntegrationGetCall<'a, C> { ProjectLocationGlobalDomainSqlIntegrationGetCall { 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 SqlIntegrations in a given domain. /// /// # Arguments /// /// * `parent` - Required. The resource name of the SqlIntegrations using the form: `projects/{project_id}/locations/global/domains/*` pub fn locations_global_domains_sql_integrations_list( &self, parent: &str, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'a, C> { ProjectLocationGlobalDomainSqlIntegrationListCall { 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: /// /// Adds an AD trust to a domain. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The resource domain name, project name and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_attach_trust( &self, request: AttachTrustRequest, name: &str, ) -> ProjectLocationGlobalDomainAttachTrustCall<'a, C> { ProjectLocationGlobalDomainAttachTrustCall { 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: /// /// CheckMigrationPermission API gets the current state of DomainMigration /// /// # Arguments /// /// * `request` - No description provided. /// * `domain` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_check_migration_permission( &self, request: CheckMigrationPermissionRequest, domain: &str, ) -> ProjectLocationGlobalDomainCheckMigrationPermissionCall<'a, C> { ProjectLocationGlobalDomainCheckMigrationPermissionCall { hub: self.hub, _request: request, _domain: domain.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a Microsoft AD domain. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Required. The resource project name and location using the form: `projects/{project_id}/locations/global` pub fn locations_global_domains_create( &self, request: Domain, parent: &str, ) -> ProjectLocationGlobalDomainCreateCall<'a, C> { ProjectLocationGlobalDomainCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _domain_name: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a domain. /// /// # Arguments /// /// * `name` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_delete( &self, name: &str, ) -> ProjectLocationGlobalDomainDeleteCall<'a, C> { ProjectLocationGlobalDomainDeleteCall { 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: /// /// Removes an AD trust. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The resource domain name, project name, and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_detach_trust( &self, request: DetachTrustRequest, name: &str, ) -> ProjectLocationGlobalDomainDetachTrustCall<'a, C> { ProjectLocationGlobalDomainDetachTrustCall { 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: /// /// Disable Domain Migration /// /// # Arguments /// /// * `request` - No description provided. /// * `domain` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_disable_migration( &self, request: DisableMigrationRequest, domain: &str, ) -> ProjectLocationGlobalDomainDisableMigrationCall<'a, C> { ProjectLocationGlobalDomainDisableMigrationCall { hub: self.hub, _request: request, _domain: domain.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// DomainJoinMachine API joins a Compute Engine VM to the domain /// /// # Arguments /// /// * `request` - No description provided. /// * `domain` - Required. The domain resource name using the form: projects/{project_id}/locations/global/domains/{domain_name} pub fn locations_global_domains_domain_join_machine( &self, request: DomainJoinMachineRequest, domain: &str, ) -> ProjectLocationGlobalDomainDomainJoinMachineCall<'a, C> { ProjectLocationGlobalDomainDomainJoinMachineCall { hub: self.hub, _request: request, _domain: domain.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Enable Domain Migration /// /// # Arguments /// /// * `request` - No description provided. /// * `domain` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_enable_migration( &self, request: EnableMigrationRequest, domain: &str, ) -> ProjectLocationGlobalDomainEnableMigrationCall<'a, C> { ProjectLocationGlobalDomainEnableMigrationCall { hub: self.hub, _request: request, _domain: domain.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Extend Schema for Domain /// /// # Arguments /// /// * `request` - No description provided. /// * `domain` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_extend_schema( &self, request: ExtendSchemaRequest, domain: &str, ) -> ProjectLocationGlobalDomainExtendSchemaCall<'a, C> { ProjectLocationGlobalDomainExtendSchemaCall { hub: self.hub, _request: request, _domain: domain.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 domain. /// /// # Arguments /// /// * `name` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_get( &self, name: &str, ) -> ProjectLocationGlobalDomainGetCall<'a, C> { ProjectLocationGlobalDomainGetCall { 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 access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. /// /// # Arguments /// /// * `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_global_domains_get_iam_policy( &self, resource: &str, ) -> ProjectLocationGlobalDomainGetIamPolicyCall<'a, C> { ProjectLocationGlobalDomainGetIamPolicyCall { hub: self.hub, _resource: resource.to_string(), _options_requested_policy_version: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets the domain ldaps settings. /// /// # Arguments /// /// * `name` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_get_ldapssettings( &self, name: &str, ) -> ProjectLocationGlobalDomainGetLdapssettingCall<'a, C> { ProjectLocationGlobalDomainGetLdapssettingCall { 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 domains in a project. /// /// # Arguments /// /// * `parent` - Required. The resource name of the domain location using the form: `projects/{project_id}/locations/global` pub fn locations_global_domains_list( &self, parent: &str, ) -> ProjectLocationGlobalDomainListCall<'a, C> { ProjectLocationGlobalDomainListCall { 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 the metadata and configuration of a domain. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The unique name of the domain using the form: `projects/{project_id}/locations/global/domains/{domain_name}`. pub fn locations_global_domains_patch( &self, request: Domain, name: &str, ) -> ProjectLocationGlobalDomainPatchCall<'a, C> { ProjectLocationGlobalDomainPatchCall { 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: /// /// Updates the DNS conditional forwarder. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The resource domain name, project name and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_reconfigure_trust( &self, request: ReconfigureTrustRequest, name: &str, ) -> ProjectLocationGlobalDomainReconfigureTrustCall<'a, C> { ProjectLocationGlobalDomainReconfigureTrustCall { 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: /// /// Resets a domain's administrator password. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_reset_admin_password( &self, request: ResetAdminPasswordRequest, name: &str, ) -> ProjectLocationGlobalDomainResetAdminPasswordCall<'a, C> { ProjectLocationGlobalDomainResetAdminPasswordCall { 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: /// /// RestoreDomain restores domain backup mentioned in the RestoreDomainRequest /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. Resource name for the domain to which the backup belongs pub fn locations_global_domains_restore( &self, request: RestoreDomainRequest, name: &str, ) -> ProjectLocationGlobalDomainRestoreCall<'a, C> { ProjectLocationGlobalDomainRestoreCall { 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 access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. /// /// # 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_global_domains_set_iam_policy( &self, request: SetIamPolicyRequest, resource: &str, ) -> ProjectLocationGlobalDomainSetIamPolicyCall<'a, C> { ProjectLocationGlobalDomainSetIamPolicyCall { 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: /// /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. /// /// # 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_global_domains_test_iam_permissions( &self, request: TestIamPermissionsRequest, resource: &str, ) -> ProjectLocationGlobalDomainTestIamPermissionCall<'a, C> { ProjectLocationGlobalDomainTestIamPermissionCall { 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: /// /// Patches a single ldaps settings. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - The resource name of the LDAPS settings. Uses the form: `projects/{project}/locations/{location}/domains/{domain}`. pub fn locations_global_domains_update_ldapssettings( &self, request: LDAPSSettings, name: &str, ) -> ProjectLocationGlobalDomainUpdateLdapssettingCall<'a, C> { ProjectLocationGlobalDomainUpdateLdapssettingCall { 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: /// /// Validates a trust state, that the target domain is reachable, and that the target domain is able to accept incoming trust requests. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The resource domain name, project name, and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` pub fn locations_global_domains_validate_trust( &self, request: ValidateTrustRequest, name: &str, ) -> ProjectLocationGlobalDomainValidateTrustCall<'a, C> { ProjectLocationGlobalDomainValidateTrustCall { 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: /// /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - The name of the operation resource to be cancelled. pub fn locations_global_operations_cancel( &self, request: CancelOperationRequest, name: &str, ) -> ProjectLocationGlobalOperationCancelCall<'a, C> { ProjectLocationGlobalOperationCancelCall { 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: /// /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. /// /// # Arguments /// /// * `name` - The name of the operation resource to be deleted. pub fn locations_global_operations_delete( &self, name: &str, ) -> ProjectLocationGlobalOperationDeleteCall<'a, C> { ProjectLocationGlobalOperationDeleteCall { 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 latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. /// /// # Arguments /// /// * `name` - The name of the operation resource. pub fn locations_global_operations_get( &self, name: &str, ) -> ProjectLocationGlobalOperationGetCall<'a, C> { ProjectLocationGlobalOperationGetCall { 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 operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. /// /// # Arguments /// /// * `name` - The name of the operation's parent resource. pub fn locations_global_operations_list( &self, name: &str, ) -> ProjectLocationGlobalOperationListCall<'a, C> { ProjectLocationGlobalOperationListCall { 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(), } } /// Create a builder to help you perform the following task: /// /// Creates a Peering for Managed AD instance. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Required. Resource project name and location using the form: `projects/{project_id}/locations/global` pub fn locations_global_peerings_create( &self, request: Peering, parent: &str, ) -> ProjectLocationGlobalPeeringCreateCall<'a, C> { ProjectLocationGlobalPeeringCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _peering_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes identified Peering. /// /// # Arguments /// /// * `name` - Required. Peering resource name using the form: `projects/{project_id}/locations/global/peerings/{peering_id}` pub fn locations_global_peerings_delete( &self, name: &str, ) -> ProjectLocationGlobalPeeringDeleteCall<'a, C> { ProjectLocationGlobalPeeringDeleteCall { 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 details of a single Peering. /// /// # Arguments /// /// * `name` - Required. Peering resource name using the form: `projects/{project_id}/locations/global/peerings/{peering_id}` pub fn locations_global_peerings_get( &self, name: &str, ) -> ProjectLocationGlobalPeeringGetCall<'a, C> { ProjectLocationGlobalPeeringGetCall { 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 access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. /// /// # Arguments /// /// * `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_global_peerings_get_iam_policy( &self, resource: &str, ) -> ProjectLocationGlobalPeeringGetIamPolicyCall<'a, C> { ProjectLocationGlobalPeeringGetIamPolicyCall { hub: self.hub, _resource: resource.to_string(), _options_requested_policy_version: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists Peerings in a given project. /// /// # Arguments /// /// * `parent` - Required. The resource name of the peering location using the form: `projects/{project_id}/locations/global` pub fn locations_global_peerings_list( &self, parent: &str, ) -> ProjectLocationGlobalPeeringListCall<'a, C> { ProjectLocationGlobalPeeringListCall { 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 the labels for specified Peering. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Output only. Unique name of the peering in this scope including projects and location using the form: `projects/{project_id}/locations/global/peerings/{peering_id}`. pub fn locations_global_peerings_patch( &self, request: Peering, name: &str, ) -> ProjectLocationGlobalPeeringPatchCall<'a, C> { ProjectLocationGlobalPeeringPatchCall { 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 access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. /// /// # 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_global_peerings_set_iam_policy( &self, request: SetIamPolicyRequest, resource: &str, ) -> ProjectLocationGlobalPeeringSetIamPolicyCall<'a, C> { ProjectLocationGlobalPeeringSetIamPolicyCall { 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: /// /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. /// /// # 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_global_peerings_test_iam_permissions( &self, request: TestIamPermissionsRequest, resource: &str, ) -> ProjectLocationGlobalPeeringTestIamPermissionCall<'a, C> { ProjectLocationGlobalPeeringTestIamPermissionCall { 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 a Backup for a domain. /// /// A builder for the *locations.global.domains.backups.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::Backup; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = Backup::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_global_domains_backups_create(req, "parent") /// .backup_id("sed") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainBackupCreateCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: Backup, _parent: String, _backup_id: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainBackupCreateCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainBackupCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.backups.create", http_method: hyper::Method::POST, }); for &field in ["alt", "parent", "backupId"].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._backup_id.as_ref() { params.push("backupId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups"; 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: Backup, ) -> ProjectLocationGlobalDomainBackupCreateCall<'a, C> { self._request = new_value; self } /// Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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) -> ProjectLocationGlobalDomainBackupCreateCall<'a, C> { self._parent = new_value.to_string(); self } /// Required. Backup Id, unique name to identify the backups with the following restrictions: * Must be lowercase letters, numbers, and hyphens * Must start with a letter. * Must contain between 1-63 characters. * Must end with a number or a letter. * Must be unique within the domain. /// /// Sets the *backup id* query property to the given value. pub fn backup_id( mut self, new_value: &str, ) -> ProjectLocationGlobalDomainBackupCreateCall<'a, C> { self._backup_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, ) -> ProjectLocationGlobalDomainBackupCreateCall<'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, ) -> ProjectLocationGlobalDomainBackupCreateCall<'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) -> ProjectLocationGlobalDomainBackupCreateCall<'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, ) -> ProjectLocationGlobalDomainBackupCreateCall<'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) -> ProjectLocationGlobalDomainBackupCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes identified Backup. /// /// A builder for the *locations.global.domains.backups.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_backups_delete("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainBackupDeleteCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainBackupDeleteCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainBackupDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.backups.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 backup resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}/backups/{backup_id}` /// /// 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) -> ProjectLocationGlobalDomainBackupDeleteCall<'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, ) -> ProjectLocationGlobalDomainBackupDeleteCall<'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, ) -> ProjectLocationGlobalDomainBackupDeleteCall<'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) -> ProjectLocationGlobalDomainBackupDeleteCall<'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, ) -> ProjectLocationGlobalDomainBackupDeleteCall<'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) -> ProjectLocationGlobalDomainBackupDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets details of a single Backup. /// /// A builder for the *locations.global.domains.backups.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_backups_get("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainBackupGetCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainBackupGetCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainBackupGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Backup)> { 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: "managedidentities.projects.locations.global.domains.backups.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 backup resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}/backups/{backup_id}` /// /// 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) -> ProjectLocationGlobalDomainBackupGetCall<'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, ) -> ProjectLocationGlobalDomainBackupGetCall<'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) -> ProjectLocationGlobalDomainBackupGetCall<'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) -> ProjectLocationGlobalDomainBackupGetCall<'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) -> ProjectLocationGlobalDomainBackupGetCall<'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) -> ProjectLocationGlobalDomainBackupGetCall<'a, C> { self._scopes.clear(); self } } /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. /// /// A builder for the *locations.global.domains.backups.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_backups_get_iam_policy("resource") /// .options_requested_policy_version(-20) /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainBackupGetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _resource: String, _options_requested_policy_version: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainBackupGetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainBackupGetIamPolicyCall<'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: "managedidentities.projects.locations.global.domains.backups.getIamPolicy", http_method: hyper::Method::GET, }); for &field in ["alt", "resource", "options.requestedPolicyVersion"].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); if let Some(value) = self._options_requested_policy_version.as_ref() { params.push("options.requestedPolicyVersion", value.to_string()); } 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); 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 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, ) -> ProjectLocationGlobalDomainBackupGetIamPolicyCall<'a, C> { self._resource = new_value.to_string(); self } /// 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). /// /// Sets the *options.requested policy version* query property to the given value. pub fn options_requested_policy_version( mut self, new_value: i32, ) -> ProjectLocationGlobalDomainBackupGetIamPolicyCall<'a, C> { self._options_requested_policy_version = 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, ) -> ProjectLocationGlobalDomainBackupGetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainBackupGetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainBackupGetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainBackupGetIamPolicyCall<'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) -> ProjectLocationGlobalDomainBackupGetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Lists Backup in a given project. /// /// A builder for the *locations.global.domains.backups.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_backups_list("parent") /// .page_token("gubergren") /// .page_size(-51) /// .order_by("gubergren") /// .filter("eos") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainBackupListCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _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 ProjectLocationGlobalDomainBackupListCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainBackupListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListBackupsResponse)> { 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: "managedidentities.projects.locations.global.domains.backups.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}/backups"; 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 domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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) -> ProjectLocationGlobalDomainBackupListCall<'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, ) -> ProjectLocationGlobalDomainBackupListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// Optional. The maximum number of items to return. If not specified, a default value of 1000 will be used by the service. Regardless of the page_size value, the response may include a partial list and a caller should only rely on response's next_page_token to determine if there are more instances left to be queried. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ProjectLocationGlobalDomainBackupListCall<'a, C> { self._page_size = Some(new_value); self } /// Optional. Specifies the ordering of results following syntax at https://cloud.google.com/apis/design/design_patterns#sorting_order. /// /// Sets the *order by* query property to the given value. pub fn order_by(mut self, new_value: &str) -> ProjectLocationGlobalDomainBackupListCall<'a, C> { self._order_by = Some(new_value.to_string()); self } /// Optional. Filter specifying constraints of a list operation. /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> ProjectLocationGlobalDomainBackupListCall<'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, ) -> ProjectLocationGlobalDomainBackupListCall<'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) -> ProjectLocationGlobalDomainBackupListCall<'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) -> ProjectLocationGlobalDomainBackupListCall<'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, ) -> ProjectLocationGlobalDomainBackupListCall<'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) -> ProjectLocationGlobalDomainBackupListCall<'a, C> { self._scopes.clear(); self } } /// Updates the labels for specified Backup. /// /// A builder for the *locations.global.domains.backups.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::Backup; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = Backup::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_global_domains_backups_patch(req, "name") /// .update_mask(FieldMask::new::<&str>(&[])) /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainBackupPatchCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: Backup, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainBackupPatchCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainBackupPatchCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.backups.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: Backup, ) -> ProjectLocationGlobalDomainBackupPatchCall<'a, C> { self._request = new_value; self } /// Output only. The unique name of the Backup in the form of `projects/{project_id}/locations/global/domains/{domain_name}/backups/{name}` /// /// 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) -> ProjectLocationGlobalDomainBackupPatchCall<'a, C> { self._name = new_value.to_string(); self } /// Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields from Backup: * `labels` /// /// Sets the *update mask* query property to the given value. pub fn update_mask( mut self, new_value: common::FieldMask, ) -> ProjectLocationGlobalDomainBackupPatchCall<'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, ) -> ProjectLocationGlobalDomainBackupPatchCall<'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, ) -> ProjectLocationGlobalDomainBackupPatchCall<'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) -> ProjectLocationGlobalDomainBackupPatchCall<'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, ) -> ProjectLocationGlobalDomainBackupPatchCall<'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) -> ProjectLocationGlobalDomainBackupPatchCall<'a, C> { self._scopes.clear(); self } } /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. /// /// A builder for the *locations.global.domains.backups.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::SetIamPolicyRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_backups_set_iam_policy(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainBackupSetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: SetIamPolicyRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainBackupSetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainBackupSetIamPolicyCall<'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: "managedidentities.projects.locations.global.domains.backups.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, ) -> ProjectLocationGlobalDomainBackupSetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainBackupSetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainBackupSetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainBackupSetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainBackupSetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainBackupSetIamPolicyCall<'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) -> ProjectLocationGlobalDomainBackupSetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. /// /// A builder for the *locations.global.domains.backups.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::TestIamPermissionsRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_backups_test_iam_permissions(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainBackupTestIamPermissionCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: TestIamPermissionsRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainBackupTestIamPermissionCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainBackupTestIamPermissionCall<'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: "managedidentities.projects.locations.global.domains.backups.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, ) -> ProjectLocationGlobalDomainBackupTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainBackupTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainBackupTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainBackupTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainBackupTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainBackupTestIamPermissionCall<'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) -> ProjectLocationGlobalDomainBackupTestIamPermissionCall<'a, C> { self._scopes.clear(); self } } /// Gets details of a single sqlIntegration. /// /// A builder for the *locations.global.domains.sqlIntegrations.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_sql_integrations_get("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainSqlIntegrationGetCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainSqlIntegrationGetCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainSqlIntegrationGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, SqlIntegration)> { 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: "managedidentities.projects.locations.global.domains.sqlIntegrations.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. SQLIntegration resource name using the form: `projects/{project_id}/locations/global/domains/{domain}/sqlIntegrations/{name}` /// /// 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, ) -> ProjectLocationGlobalDomainSqlIntegrationGetCall<'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, ) -> ProjectLocationGlobalDomainSqlIntegrationGetCall<'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, ) -> ProjectLocationGlobalDomainSqlIntegrationGetCall<'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, ) -> ProjectLocationGlobalDomainSqlIntegrationGetCall<'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, ) -> ProjectLocationGlobalDomainSqlIntegrationGetCall<'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) -> ProjectLocationGlobalDomainSqlIntegrationGetCall<'a, C> { self._scopes.clear(); self } } /// Lists SqlIntegrations in a given domain. /// /// A builder for the *locations.global.domains.sqlIntegrations.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_sql_integrations_list("parent") /// .page_token("duo") /// .page_size(-50) /// .order_by("sed") /// .filter("ut") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainSqlIntegrationListCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _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 ProjectLocationGlobalDomainSqlIntegrationListCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainSqlIntegrationListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListSqlIntegrationsResponse)> { 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: "managedidentities.projects.locations.global.domains.sqlIntegrations.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}/sqlIntegrations"; 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 SqlIntegrations using the form: `projects/{project_id}/locations/global/domains/*` /// /// 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, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'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, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// Optional. The maximum number of items to return. If not specified, a default value of 1000 will be used by the service. Regardless of the page_size value, the response may include a partial list and a caller should only rely on response'ANIZATIONs next_page_token to determine if there are more instances left to be queried. /// /// Sets the *page size* query property to the given value. pub fn page_size( mut self, new_value: i32, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'a, C> { self._page_size = Some(new_value); self } /// Optional. Specifies the ordering of results following syntax at https://cloud.google.com/apis/design/design_patterns#sorting_order. /// /// Sets the *order by* query property to the given value. pub fn order_by( mut self, new_value: &str, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'a, C> { self._order_by = Some(new_value.to_string()); self } /// Optional. Filter specifying constraints of a list operation. For example, `SqlIntegration.name="sql"`. /// /// Sets the *filter* query property to the given value. pub fn filter( mut self, new_value: &str, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'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, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'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, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'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, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'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, ) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'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) -> ProjectLocationGlobalDomainSqlIntegrationListCall<'a, C> { self._scopes.clear(); self } } /// Adds an AD trust to a domain. /// /// A builder for the *locations.global.domains.attachTrust* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::AttachTrustRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = AttachTrustRequest::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_global_domains_attach_trust(req, "name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainAttachTrustCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: AttachTrustRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainAttachTrustCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainAttachTrustCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.attachTrust", 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}:attachTrust"; 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: AttachTrustRequest, ) -> ProjectLocationGlobalDomainAttachTrustCall<'a, C> { self._request = new_value; self } /// Required. The resource domain name, project name and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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) -> ProjectLocationGlobalDomainAttachTrustCall<'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, ) -> ProjectLocationGlobalDomainAttachTrustCall<'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, ) -> ProjectLocationGlobalDomainAttachTrustCall<'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) -> ProjectLocationGlobalDomainAttachTrustCall<'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, ) -> ProjectLocationGlobalDomainAttachTrustCall<'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) -> ProjectLocationGlobalDomainAttachTrustCall<'a, C> { self._scopes.clear(); self } } /// CheckMigrationPermission API gets the current state of DomainMigration /// /// A builder for the *locations.global.domains.checkMigrationPermission* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::CheckMigrationPermissionRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = CheckMigrationPermissionRequest::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_global_domains_check_migration_permission(req, "domain") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainCheckMigrationPermissionCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: CheckMigrationPermissionRequest, _domain: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainCheckMigrationPermissionCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainCheckMigrationPermissionCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<(common::Response, CheckMigrationPermissionResponse)> { 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: "managedidentities.projects.locations.global.domains.checkMigrationPermission", http_method: hyper::Method::POST, }); for &field in ["alt", "domain"].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("domain", self._domain); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+domain}:checkMigrationPermission"; 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 [("{+domain}", "domain")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["domain"]; 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: CheckMigrationPermissionRequest, ) -> ProjectLocationGlobalDomainCheckMigrationPermissionCall<'a, C> { self._request = new_value; self } /// Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// Sets the *domain* 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 domain( mut self, new_value: &str, ) -> ProjectLocationGlobalDomainCheckMigrationPermissionCall<'a, C> { self._domain = 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, ) -> ProjectLocationGlobalDomainCheckMigrationPermissionCall<'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, ) -> ProjectLocationGlobalDomainCheckMigrationPermissionCall<'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, ) -> ProjectLocationGlobalDomainCheckMigrationPermissionCall<'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, ) -> ProjectLocationGlobalDomainCheckMigrationPermissionCall<'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, ) -> ProjectLocationGlobalDomainCheckMigrationPermissionCall<'a, C> { self._scopes.clear(); self } } /// Creates a Microsoft AD domain. /// /// A builder for the *locations.global.domains.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::Domain; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = Domain::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_global_domains_create(req, "parent") /// .domain_name("ipsum") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainCreateCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: Domain, _parent: String, _domain_name: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainCreateCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.create", http_method: hyper::Method::POST, }); for &field in ["alt", "parent", "domainName"].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._domain_name.as_ref() { params.push("domainName", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/domains"; 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: Domain) -> ProjectLocationGlobalDomainCreateCall<'a, C> { self._request = new_value; self } /// Required. The resource project name and location using the form: `projects/{project_id}/locations/global` /// /// 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) -> ProjectLocationGlobalDomainCreateCall<'a, C> { self._parent = new_value.to_string(); self } /// Required. The fully qualified domain name. e.g. mydomain.myorganization.com, with the following restrictions: * Must contain only lowercase letters, numbers, periods and hyphens. * Must start with a letter. * Must contain between 2-64 characters. * Must end with a number or a letter. * Must not start with period. * First segment length (mydomain for example above) shouldn't exceed 15 chars. * The last segment cannot be fully numeric. * Must be unique within the customer project. /// /// Sets the *domain name* query property to the given value. pub fn domain_name(mut self, new_value: &str) -> ProjectLocationGlobalDomainCreateCall<'a, C> { self._domain_name = 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, ) -> ProjectLocationGlobalDomainCreateCall<'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) -> ProjectLocationGlobalDomainCreateCall<'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) -> ProjectLocationGlobalDomainCreateCall<'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) -> ProjectLocationGlobalDomainCreateCall<'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) -> ProjectLocationGlobalDomainCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a domain. /// /// A builder for the *locations.global.domains.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_delete("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainDeleteCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainDeleteCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.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 domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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) -> ProjectLocationGlobalDomainDeleteCall<'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, ) -> ProjectLocationGlobalDomainDeleteCall<'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) -> ProjectLocationGlobalDomainDeleteCall<'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) -> ProjectLocationGlobalDomainDeleteCall<'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) -> ProjectLocationGlobalDomainDeleteCall<'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) -> ProjectLocationGlobalDomainDeleteCall<'a, C> { self._scopes.clear(); self } } /// Removes an AD trust. /// /// A builder for the *locations.global.domains.detachTrust* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::DetachTrustRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = DetachTrustRequest::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_global_domains_detach_trust(req, "name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainDetachTrustCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: DetachTrustRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainDetachTrustCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainDetachTrustCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.detachTrust", 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}:detachTrust"; 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: DetachTrustRequest, ) -> ProjectLocationGlobalDomainDetachTrustCall<'a, C> { self._request = new_value; self } /// Required. The resource domain name, project name, and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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) -> ProjectLocationGlobalDomainDetachTrustCall<'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, ) -> ProjectLocationGlobalDomainDetachTrustCall<'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, ) -> ProjectLocationGlobalDomainDetachTrustCall<'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) -> ProjectLocationGlobalDomainDetachTrustCall<'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, ) -> ProjectLocationGlobalDomainDetachTrustCall<'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) -> ProjectLocationGlobalDomainDetachTrustCall<'a, C> { self._scopes.clear(); self } } /// Disable Domain Migration /// /// A builder for the *locations.global.domains.disableMigration* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::DisableMigrationRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = DisableMigrationRequest::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_global_domains_disable_migration(req, "domain") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainDisableMigrationCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: DisableMigrationRequest, _domain: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainDisableMigrationCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainDisableMigrationCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.disableMigration", http_method: hyper::Method::POST, }); for &field in ["alt", "domain"].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("domain", self._domain); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+domain}:disableMigration"; 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 [("{+domain}", "domain")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["domain"]; 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: DisableMigrationRequest, ) -> ProjectLocationGlobalDomainDisableMigrationCall<'a, C> { self._request = new_value; self } /// Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// Sets the *domain* 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 domain( mut self, new_value: &str, ) -> ProjectLocationGlobalDomainDisableMigrationCall<'a, C> { self._domain = 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, ) -> ProjectLocationGlobalDomainDisableMigrationCall<'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, ) -> ProjectLocationGlobalDomainDisableMigrationCall<'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, ) -> ProjectLocationGlobalDomainDisableMigrationCall<'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, ) -> ProjectLocationGlobalDomainDisableMigrationCall<'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) -> ProjectLocationGlobalDomainDisableMigrationCall<'a, C> { self._scopes.clear(); self } } /// DomainJoinMachine API joins a Compute Engine VM to the domain /// /// A builder for the *locations.global.domains.domainJoinMachine* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::DomainJoinMachineRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = DomainJoinMachineRequest::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_global_domains_domain_join_machine(req, "domain") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainDomainJoinMachineCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: DomainJoinMachineRequest, _domain: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainDomainJoinMachineCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainDomainJoinMachineCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, DomainJoinMachineResponse)> { 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: "managedidentities.projects.locations.global.domains.domainJoinMachine", http_method: hyper::Method::POST, }); for &field in ["alt", "domain"].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("domain", self._domain); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+domain}:domainJoinMachine"; 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 [("{+domain}", "domain")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["domain"]; 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: DomainJoinMachineRequest, ) -> ProjectLocationGlobalDomainDomainJoinMachineCall<'a, C> { self._request = new_value; self } /// Required. The domain resource name using the form: projects/{project_id}/locations/global/domains/{domain_name} /// /// Sets the *domain* 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 domain( mut self, new_value: &str, ) -> ProjectLocationGlobalDomainDomainJoinMachineCall<'a, C> { self._domain = 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, ) -> ProjectLocationGlobalDomainDomainJoinMachineCall<'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, ) -> ProjectLocationGlobalDomainDomainJoinMachineCall<'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, ) -> ProjectLocationGlobalDomainDomainJoinMachineCall<'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, ) -> ProjectLocationGlobalDomainDomainJoinMachineCall<'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) -> ProjectLocationGlobalDomainDomainJoinMachineCall<'a, C> { self._scopes.clear(); self } } /// Enable Domain Migration /// /// A builder for the *locations.global.domains.enableMigration* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::EnableMigrationRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = EnableMigrationRequest::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_global_domains_enable_migration(req, "domain") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainEnableMigrationCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: EnableMigrationRequest, _domain: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainEnableMigrationCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainEnableMigrationCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.enableMigration", http_method: hyper::Method::POST, }); for &field in ["alt", "domain"].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("domain", self._domain); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+domain}:enableMigration"; 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 [("{+domain}", "domain")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["domain"]; 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: EnableMigrationRequest, ) -> ProjectLocationGlobalDomainEnableMigrationCall<'a, C> { self._request = new_value; self } /// Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// Sets the *domain* 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 domain( mut self, new_value: &str, ) -> ProjectLocationGlobalDomainEnableMigrationCall<'a, C> { self._domain = 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, ) -> ProjectLocationGlobalDomainEnableMigrationCall<'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, ) -> ProjectLocationGlobalDomainEnableMigrationCall<'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, ) -> ProjectLocationGlobalDomainEnableMigrationCall<'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, ) -> ProjectLocationGlobalDomainEnableMigrationCall<'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) -> ProjectLocationGlobalDomainEnableMigrationCall<'a, C> { self._scopes.clear(); self } } /// Extend Schema for Domain /// /// A builder for the *locations.global.domains.extendSchema* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::ExtendSchemaRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = ExtendSchemaRequest::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_global_domains_extend_schema(req, "domain") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainExtendSchemaCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: ExtendSchemaRequest, _domain: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainExtendSchemaCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainExtendSchemaCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.extendSchema", http_method: hyper::Method::POST, }); for &field in ["alt", "domain"].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("domain", self._domain); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+domain}:extendSchema"; 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 [("{+domain}", "domain")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["domain"]; 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: ExtendSchemaRequest, ) -> ProjectLocationGlobalDomainExtendSchemaCall<'a, C> { self._request = new_value; self } /// Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// Sets the *domain* 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 domain(mut self, new_value: &str) -> ProjectLocationGlobalDomainExtendSchemaCall<'a, C> { self._domain = 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, ) -> ProjectLocationGlobalDomainExtendSchemaCall<'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, ) -> ProjectLocationGlobalDomainExtendSchemaCall<'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) -> ProjectLocationGlobalDomainExtendSchemaCall<'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, ) -> ProjectLocationGlobalDomainExtendSchemaCall<'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) -> ProjectLocationGlobalDomainExtendSchemaCall<'a, C> { self._scopes.clear(); self } } /// Gets information about a domain. /// /// A builder for the *locations.global.domains.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_get("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainGetCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainGetCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Domain)> { 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: "managedidentities.projects.locations.global.domains.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 domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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) -> ProjectLocationGlobalDomainGetCall<'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, ) -> ProjectLocationGlobalDomainGetCall<'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) -> ProjectLocationGlobalDomainGetCall<'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) -> ProjectLocationGlobalDomainGetCall<'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) -> ProjectLocationGlobalDomainGetCall<'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) -> ProjectLocationGlobalDomainGetCall<'a, C> { self._scopes.clear(); self } } /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. /// /// A builder for the *locations.global.domains.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_get_iam_policy("resource") /// .options_requested_policy_version(-43) /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainGetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _resource: String, _options_requested_policy_version: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainGetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainGetIamPolicyCall<'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: "managedidentities.projects.locations.global.domains.getIamPolicy", http_method: hyper::Method::GET, }); for &field in ["alt", "resource", "options.requestedPolicyVersion"].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); if let Some(value) = self._options_requested_policy_version.as_ref() { params.push("options.requestedPolicyVersion", value.to_string()); } 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); 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 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, ) -> ProjectLocationGlobalDomainGetIamPolicyCall<'a, C> { self._resource = new_value.to_string(); self } /// 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). /// /// Sets the *options.requested policy version* query property to the given value. pub fn options_requested_policy_version( mut self, new_value: i32, ) -> ProjectLocationGlobalDomainGetIamPolicyCall<'a, C> { self._options_requested_policy_version = 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, ) -> ProjectLocationGlobalDomainGetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainGetIamPolicyCall<'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) -> ProjectLocationGlobalDomainGetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainGetIamPolicyCall<'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) -> ProjectLocationGlobalDomainGetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Gets the domain ldaps settings. /// /// A builder for the *locations.global.domains.getLdapssettings* 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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_get_ldapssettings("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainGetLdapssettingCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainGetLdapssettingCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainGetLdapssettingCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, LDAPSSettings)> { 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: "managedidentities.projects.locations.global.domains.getLdapssettings", 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}/ldapssettings"; 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 domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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, ) -> ProjectLocationGlobalDomainGetLdapssettingCall<'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, ) -> ProjectLocationGlobalDomainGetLdapssettingCall<'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, ) -> ProjectLocationGlobalDomainGetLdapssettingCall<'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, ) -> ProjectLocationGlobalDomainGetLdapssettingCall<'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, ) -> ProjectLocationGlobalDomainGetLdapssettingCall<'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) -> ProjectLocationGlobalDomainGetLdapssettingCall<'a, C> { self._scopes.clear(); self } } /// Lists domains in a project. /// /// A builder for the *locations.global.domains.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_list("parent") /// .page_token("no") /// .page_size(-15) /// .order_by("kasd") /// .filter("et") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainListCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _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 ProjectLocationGlobalDomainListCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListDomainsResponse)> { 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: "managedidentities.projects.locations.global.domains.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}/domains"; 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 domain location using the form: `projects/{project_id}/locations/global` /// /// 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) -> ProjectLocationGlobalDomainListCall<'a, C> { self._parent = new_value.to_string(); self } /// Optional. The `next_page_token` value returned from a previous ListDomainsRequest request, if any. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ProjectLocationGlobalDomainListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// Optional. The maximum number of items to return. If not specified, a default value of 1000 will be used. Regardless of the page_size value, the response may include a partial list. Callers should rely on a response's next_page_token to determine if there are additional results to list. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ProjectLocationGlobalDomainListCall<'a, C> { self._page_size = Some(new_value); self } /// Optional. Specifies the ordering of results. See [Sorting order](https://cloud.google.com/apis/design/design_patterns#sorting_order) for more information. /// /// Sets the *order by* query property to the given value. pub fn order_by(mut self, new_value: &str) -> ProjectLocationGlobalDomainListCall<'a, C> { self._order_by = Some(new_value.to_string()); self } /// Optional. A filter specifying constraints of a list operation. For example, `Domain.fqdn="mydomain.myorginization"`. /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> ProjectLocationGlobalDomainListCall<'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, ) -> ProjectLocationGlobalDomainListCall<'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) -> ProjectLocationGlobalDomainListCall<'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) -> ProjectLocationGlobalDomainListCall<'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) -> ProjectLocationGlobalDomainListCall<'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) -> ProjectLocationGlobalDomainListCall<'a, C> { self._scopes.clear(); self } } /// Updates the metadata and configuration of a domain. /// /// A builder for the *locations.global.domains.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::Domain; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = Domain::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_global_domains_patch(req, "name") /// .update_mask(FieldMask::new::<&str>(&[])) /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainPatchCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: Domain, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainPatchCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainPatchCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.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: Domain) -> ProjectLocationGlobalDomainPatchCall<'a, C> { self._request = new_value; self } /// Required. The unique name of the domain using the form: `projects/{project_id}/locations/global/domains/{domain_name}`. /// /// 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) -> ProjectLocationGlobalDomainPatchCall<'a, C> { self._name = new_value.to_string(); self } /// Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include fields from Domain: * `labels` * `locations` * `authorized_networks` * `audit_logs_enabled` /// /// Sets the *update mask* query property to the given value. pub fn update_mask( mut self, new_value: common::FieldMask, ) -> ProjectLocationGlobalDomainPatchCall<'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, ) -> ProjectLocationGlobalDomainPatchCall<'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) -> ProjectLocationGlobalDomainPatchCall<'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) -> ProjectLocationGlobalDomainPatchCall<'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) -> ProjectLocationGlobalDomainPatchCall<'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) -> ProjectLocationGlobalDomainPatchCall<'a, C> { self._scopes.clear(); self } } /// Updates the DNS conditional forwarder. /// /// A builder for the *locations.global.domains.reconfigureTrust* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::ReconfigureTrustRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = ReconfigureTrustRequest::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_global_domains_reconfigure_trust(req, "name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainReconfigureTrustCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: ReconfigureTrustRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainReconfigureTrustCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainReconfigureTrustCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.reconfigureTrust", 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}:reconfigureTrust"; 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: ReconfigureTrustRequest, ) -> ProjectLocationGlobalDomainReconfigureTrustCall<'a, C> { self._request = new_value; self } /// Required. The resource domain name, project name and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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, ) -> ProjectLocationGlobalDomainReconfigureTrustCall<'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, ) -> ProjectLocationGlobalDomainReconfigureTrustCall<'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, ) -> ProjectLocationGlobalDomainReconfigureTrustCall<'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, ) -> ProjectLocationGlobalDomainReconfigureTrustCall<'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, ) -> ProjectLocationGlobalDomainReconfigureTrustCall<'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) -> ProjectLocationGlobalDomainReconfigureTrustCall<'a, C> { self._scopes.clear(); self } } /// Resets a domain's administrator password. /// /// A builder for the *locations.global.domains.resetAdminPassword* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::ResetAdminPasswordRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = ResetAdminPasswordRequest::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_global_domains_reset_admin_password(req, "name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainResetAdminPasswordCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: ResetAdminPasswordRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainResetAdminPasswordCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainResetAdminPasswordCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ResetAdminPasswordResponse)> { 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: "managedidentities.projects.locations.global.domains.resetAdminPassword", 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}:resetAdminPassword"; 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: ResetAdminPasswordRequest, ) -> ProjectLocationGlobalDomainResetAdminPasswordCall<'a, C> { self._request = new_value; self } /// Required. The domain resource name using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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, ) -> ProjectLocationGlobalDomainResetAdminPasswordCall<'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, ) -> ProjectLocationGlobalDomainResetAdminPasswordCall<'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, ) -> ProjectLocationGlobalDomainResetAdminPasswordCall<'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, ) -> ProjectLocationGlobalDomainResetAdminPasswordCall<'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, ) -> ProjectLocationGlobalDomainResetAdminPasswordCall<'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) -> ProjectLocationGlobalDomainResetAdminPasswordCall<'a, C> { self._scopes.clear(); self } } /// RestoreDomain restores domain backup mentioned in the RestoreDomainRequest /// /// A builder for the *locations.global.domains.restore* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::RestoreDomainRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = RestoreDomainRequest::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_global_domains_restore(req, "name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainRestoreCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: RestoreDomainRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainRestoreCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainRestoreCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.restore", 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}:restore"; 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: RestoreDomainRequest, ) -> ProjectLocationGlobalDomainRestoreCall<'a, C> { self._request = new_value; self } /// Required. Resource name for the domain to which the backup belongs /// /// 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) -> ProjectLocationGlobalDomainRestoreCall<'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, ) -> ProjectLocationGlobalDomainRestoreCall<'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) -> ProjectLocationGlobalDomainRestoreCall<'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) -> ProjectLocationGlobalDomainRestoreCall<'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) -> ProjectLocationGlobalDomainRestoreCall<'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) -> ProjectLocationGlobalDomainRestoreCall<'a, C> { self._scopes.clear(); self } } /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. /// /// A builder for the *locations.global.domains.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::SetIamPolicyRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_set_iam_policy(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainSetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: SetIamPolicyRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainSetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainSetIamPolicyCall<'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: "managedidentities.projects.locations.global.domains.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, ) -> ProjectLocationGlobalDomainSetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainSetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainSetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainSetIamPolicyCall<'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) -> ProjectLocationGlobalDomainSetIamPolicyCall<'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, ) -> ProjectLocationGlobalDomainSetIamPolicyCall<'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) -> ProjectLocationGlobalDomainSetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. /// /// A builder for the *locations.global.domains.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::TestIamPermissionsRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_domains_test_iam_permissions(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainTestIamPermissionCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: TestIamPermissionsRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainTestIamPermissionCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainTestIamPermissionCall<'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: "managedidentities.projects.locations.global.domains.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, ) -> ProjectLocationGlobalDomainTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainTestIamPermissionCall<'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, ) -> ProjectLocationGlobalDomainTestIamPermissionCall<'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) -> ProjectLocationGlobalDomainTestIamPermissionCall<'a, C> { self._scopes.clear(); self } } /// Patches a single ldaps settings. /// /// A builder for the *locations.global.domains.updateLdapssettings* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::LDAPSSettings; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = LDAPSSettings::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_global_domains_update_ldapssettings(req, "name") /// .update_mask(FieldMask::new::<&str>(&[])) /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainUpdateLdapssettingCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: LDAPSSettings, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainUpdateLdapssettingCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainUpdateLdapssettingCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.updateLdapssettings", 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}/ldapssettings"; 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: LDAPSSettings, ) -> ProjectLocationGlobalDomainUpdateLdapssettingCall<'a, C> { self._request = new_value; self } /// The resource name of the LDAPS settings. Uses the form: `projects/{project}/locations/{location}/domains/{domain}`. /// /// 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, ) -> ProjectLocationGlobalDomainUpdateLdapssettingCall<'a, C> { self._name = new_value.to_string(); self } /// Required. Mask of fields to update. At least one path must be supplied in this field. For the `FieldMask` definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask /// /// Sets the *update mask* query property to the given value. pub fn update_mask( mut self, new_value: common::FieldMask, ) -> ProjectLocationGlobalDomainUpdateLdapssettingCall<'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, ) -> ProjectLocationGlobalDomainUpdateLdapssettingCall<'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, ) -> ProjectLocationGlobalDomainUpdateLdapssettingCall<'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, ) -> ProjectLocationGlobalDomainUpdateLdapssettingCall<'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, ) -> ProjectLocationGlobalDomainUpdateLdapssettingCall<'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) -> ProjectLocationGlobalDomainUpdateLdapssettingCall<'a, C> { self._scopes.clear(); self } } /// Validates a trust state, that the target domain is reachable, and that the target domain is able to accept incoming trust requests. /// /// A builder for the *locations.global.domains.validateTrust* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::ValidateTrustRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = ValidateTrustRequest::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_global_domains_validate_trust(req, "name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalDomainValidateTrustCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: ValidateTrustRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalDomainValidateTrustCall<'a, C> {} impl<'a, C> ProjectLocationGlobalDomainValidateTrustCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.domains.validateTrust", 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}:validateTrust"; 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: ValidateTrustRequest, ) -> ProjectLocationGlobalDomainValidateTrustCall<'a, C> { self._request = new_value; self } /// Required. The resource domain name, project name, and location using the form: `projects/{project_id}/locations/global/domains/{domain_name}` /// /// 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) -> ProjectLocationGlobalDomainValidateTrustCall<'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, ) -> ProjectLocationGlobalDomainValidateTrustCall<'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, ) -> ProjectLocationGlobalDomainValidateTrustCall<'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) -> ProjectLocationGlobalDomainValidateTrustCall<'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, ) -> ProjectLocationGlobalDomainValidateTrustCall<'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) -> ProjectLocationGlobalDomainValidateTrustCall<'a, C> { self._scopes.clear(); self } } /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`. /// /// A builder for the *locations.global.operations.cancel* 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_managedidentities1 as managedidentities1; /// use managedidentities1::api::CancelOperationRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = CancelOperationRequest::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_global_operations_cancel(req, "name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalOperationCancelCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: CancelOperationRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalOperationCancelCall<'a, C> {} impl<'a, C> ProjectLocationGlobalOperationCancelCall<'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: "managedidentities.projects.locations.global.operations.cancel", 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}:cancel"; 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: CancelOperationRequest, ) -> ProjectLocationGlobalOperationCancelCall<'a, C> { self._request = new_value; self } /// The name of the operation resource to be cancelled. /// /// 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) -> ProjectLocationGlobalOperationCancelCall<'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, ) -> ProjectLocationGlobalOperationCancelCall<'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) -> ProjectLocationGlobalOperationCancelCall<'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) -> ProjectLocationGlobalOperationCancelCall<'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) -> ProjectLocationGlobalOperationCancelCall<'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) -> ProjectLocationGlobalOperationCancelCall<'a, C> { self._scopes.clear(); self } } /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. /// /// A builder for the *locations.global.operations.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_operations_delete("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalOperationDeleteCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalOperationDeleteCall<'a, C> {} impl<'a, C> ProjectLocationGlobalOperationDeleteCall<'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: "managedidentities.projects.locations.global.operations.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); } } } } /// The name of the operation resource to be deleted. /// /// 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) -> ProjectLocationGlobalOperationDeleteCall<'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, ) -> ProjectLocationGlobalOperationDeleteCall<'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) -> ProjectLocationGlobalOperationDeleteCall<'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) -> ProjectLocationGlobalOperationDeleteCall<'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) -> ProjectLocationGlobalOperationDeleteCall<'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) -> ProjectLocationGlobalOperationDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. /// /// A builder for the *locations.global.operations.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_operations_get("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalOperationGetCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalOperationGetCall<'a, C> {} impl<'a, C> ProjectLocationGlobalOperationGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.operations.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); } } } } /// The name of the operation resource. /// /// 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) -> ProjectLocationGlobalOperationGetCall<'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, ) -> ProjectLocationGlobalOperationGetCall<'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) -> ProjectLocationGlobalOperationGetCall<'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) -> ProjectLocationGlobalOperationGetCall<'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) -> ProjectLocationGlobalOperationGetCall<'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) -> ProjectLocationGlobalOperationGetCall<'a, C> { self._scopes.clear(); self } } /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. /// /// A builder for the *locations.global.operations.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_operations_list("name") /// .page_token("diam") /// .page_size(-49) /// .filter("et") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalOperationListCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _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 ProjectLocationGlobalOperationListCall<'a, C> {} impl<'a, C> ProjectLocationGlobalOperationListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> { 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: "managedidentities.projects.locations.global.operations.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}"; 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 name of the operation's parent resource. /// /// 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) -> ProjectLocationGlobalOperationListCall<'a, C> { self._name = new_value.to_string(); self } /// The standard list page token. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ProjectLocationGlobalOperationListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// The standard list page size. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ProjectLocationGlobalOperationListCall<'a, C> { self._page_size = Some(new_value); self } /// The standard list filter. /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> ProjectLocationGlobalOperationListCall<'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, ) -> ProjectLocationGlobalOperationListCall<'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) -> ProjectLocationGlobalOperationListCall<'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) -> ProjectLocationGlobalOperationListCall<'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) -> ProjectLocationGlobalOperationListCall<'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) -> ProjectLocationGlobalOperationListCall<'a, C> { self._scopes.clear(); self } } /// Creates a Peering for Managed AD instance. /// /// A builder for the *locations.global.peerings.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::Peering; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = Peering::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_global_peerings_create(req, "parent") /// .peering_id("sadipscing") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalPeeringCreateCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: Peering, _parent: String, _peering_id: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalPeeringCreateCall<'a, C> {} impl<'a, C> ProjectLocationGlobalPeeringCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.peerings.create", http_method: hyper::Method::POST, }); for &field in ["alt", "parent", "peeringId"].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._peering_id.as_ref() { params.push("peeringId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/peerings"; 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: Peering) -> ProjectLocationGlobalPeeringCreateCall<'a, C> { self._request = new_value; self } /// Required. Resource project name and location using the form: `projects/{project_id}/locations/global` /// /// 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) -> ProjectLocationGlobalPeeringCreateCall<'a, C> { self._parent = new_value.to_string(); self } /// Required. Peering Id, unique name to identify peering. It should follow the regex format “^(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)$” /// /// Sets the *peering id* query property to the given value. pub fn peering_id(mut self, new_value: &str) -> ProjectLocationGlobalPeeringCreateCall<'a, C> { self._peering_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, ) -> ProjectLocationGlobalPeeringCreateCall<'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) -> ProjectLocationGlobalPeeringCreateCall<'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) -> ProjectLocationGlobalPeeringCreateCall<'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) -> ProjectLocationGlobalPeeringCreateCall<'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) -> ProjectLocationGlobalPeeringCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes identified Peering. /// /// A builder for the *locations.global.peerings.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_peerings_delete("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalPeeringDeleteCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalPeeringDeleteCall<'a, C> {} impl<'a, C> ProjectLocationGlobalPeeringDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.peerings.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. Peering resource name using the form: `projects/{project_id}/locations/global/peerings/{peering_id}` /// /// 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) -> ProjectLocationGlobalPeeringDeleteCall<'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, ) -> ProjectLocationGlobalPeeringDeleteCall<'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) -> ProjectLocationGlobalPeeringDeleteCall<'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) -> ProjectLocationGlobalPeeringDeleteCall<'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) -> ProjectLocationGlobalPeeringDeleteCall<'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) -> ProjectLocationGlobalPeeringDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets details of a single Peering. /// /// A builder for the *locations.global.peerings.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_peerings_get("name") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalPeeringGetCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalPeeringGetCall<'a, C> {} impl<'a, C> ProjectLocationGlobalPeeringGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Peering)> { 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: "managedidentities.projects.locations.global.peerings.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. Peering resource name using the form: `projects/{project_id}/locations/global/peerings/{peering_id}` /// /// 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) -> ProjectLocationGlobalPeeringGetCall<'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, ) -> ProjectLocationGlobalPeeringGetCall<'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) -> ProjectLocationGlobalPeeringGetCall<'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) -> ProjectLocationGlobalPeeringGetCall<'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) -> ProjectLocationGlobalPeeringGetCall<'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) -> ProjectLocationGlobalPeeringGetCall<'a, C> { self._scopes.clear(); self } } /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. /// /// A builder for the *locations.global.peerings.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_peerings_get_iam_policy("resource") /// .options_requested_policy_version(-76) /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalPeeringGetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _resource: String, _options_requested_policy_version: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalPeeringGetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationGlobalPeeringGetIamPolicyCall<'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: "managedidentities.projects.locations.global.peerings.getIamPolicy", http_method: hyper::Method::GET, }); for &field in ["alt", "resource", "options.requestedPolicyVersion"].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); if let Some(value) = self._options_requested_policy_version.as_ref() { params.push("options.requestedPolicyVersion", value.to_string()); } 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); 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 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, ) -> ProjectLocationGlobalPeeringGetIamPolicyCall<'a, C> { self._resource = new_value.to_string(); self } /// 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). /// /// Sets the *options.requested policy version* query property to the given value. pub fn options_requested_policy_version( mut self, new_value: i32, ) -> ProjectLocationGlobalPeeringGetIamPolicyCall<'a, C> { self._options_requested_policy_version = 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, ) -> ProjectLocationGlobalPeeringGetIamPolicyCall<'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, ) -> ProjectLocationGlobalPeeringGetIamPolicyCall<'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) -> ProjectLocationGlobalPeeringGetIamPolicyCall<'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, ) -> ProjectLocationGlobalPeeringGetIamPolicyCall<'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) -> ProjectLocationGlobalPeeringGetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Lists Peerings in a given project. /// /// A builder for the *locations.global.peerings.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_peerings_list("parent") /// .page_token("invidunt") /// .page_size(-65) /// .order_by("vero") /// .filter("elitr") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalPeeringListCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _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 ProjectLocationGlobalPeeringListCall<'a, C> {} impl<'a, C> ProjectLocationGlobalPeeringListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListPeeringsResponse)> { 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: "managedidentities.projects.locations.global.peerings.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}/peerings"; 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 peering location using the form: `projects/{project_id}/locations/global` /// /// 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) -> ProjectLocationGlobalPeeringListCall<'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) -> ProjectLocationGlobalPeeringListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// Optional. The maximum number of items to return. If not specified, a default value of 1000 will be used by the service. Regardless of the page_size value, the response may include a partial list and a caller should only rely on response's next_page_token to determine if there are more instances left to be queried. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ProjectLocationGlobalPeeringListCall<'a, C> { self._page_size = Some(new_value); self } /// Optional. Specifies the ordering of results following syntax at https://cloud.google.com/apis/design/design_patterns#sorting_order. /// /// Sets the *order by* query property to the given value. pub fn order_by(mut self, new_value: &str) -> ProjectLocationGlobalPeeringListCall<'a, C> { self._order_by = Some(new_value.to_string()); self } /// Optional. Filter specifying constraints of a list operation. For example, `peering.authorized_network="projects/myprojectid/global/networks/mynetwork"`. /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> ProjectLocationGlobalPeeringListCall<'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, ) -> ProjectLocationGlobalPeeringListCall<'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) -> ProjectLocationGlobalPeeringListCall<'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) -> ProjectLocationGlobalPeeringListCall<'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) -> ProjectLocationGlobalPeeringListCall<'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) -> ProjectLocationGlobalPeeringListCall<'a, C> { self._scopes.clear(); self } } /// Updates the labels for specified Peering. /// /// A builder for the *locations.global.peerings.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::Peering; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 = Peering::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_global_peerings_patch(req, "name") /// .update_mask(FieldMask::new::<&str>(&[])) /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalPeeringPatchCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: Peering, _name: String, _update_mask: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalPeeringPatchCall<'a, C> {} impl<'a, C> ProjectLocationGlobalPeeringPatchCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> { 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: "managedidentities.projects.locations.global.peerings.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: Peering) -> ProjectLocationGlobalPeeringPatchCall<'a, C> { self._request = new_value; self } /// Output only. Unique name of the peering in this scope including projects and location using the form: `projects/{project_id}/locations/global/peerings/{peering_id}`. /// /// 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) -> ProjectLocationGlobalPeeringPatchCall<'a, C> { self._name = new_value.to_string(); self } /// Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields from Peering: * `labels` /// /// Sets the *update mask* query property to the given value. pub fn update_mask( mut self, new_value: common::FieldMask, ) -> ProjectLocationGlobalPeeringPatchCall<'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, ) -> ProjectLocationGlobalPeeringPatchCall<'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) -> ProjectLocationGlobalPeeringPatchCall<'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) -> ProjectLocationGlobalPeeringPatchCall<'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) -> ProjectLocationGlobalPeeringPatchCall<'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) -> ProjectLocationGlobalPeeringPatchCall<'a, C> { self._scopes.clear(); self } } /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. /// /// A builder for the *locations.global.peerings.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::SetIamPolicyRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_peerings_set_iam_policy(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalPeeringSetIamPolicyCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: SetIamPolicyRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalPeeringSetIamPolicyCall<'a, C> {} impl<'a, C> ProjectLocationGlobalPeeringSetIamPolicyCall<'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: "managedidentities.projects.locations.global.peerings.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, ) -> ProjectLocationGlobalPeeringSetIamPolicyCall<'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, ) -> ProjectLocationGlobalPeeringSetIamPolicyCall<'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, ) -> ProjectLocationGlobalPeeringSetIamPolicyCall<'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, ) -> ProjectLocationGlobalPeeringSetIamPolicyCall<'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) -> ProjectLocationGlobalPeeringSetIamPolicyCall<'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, ) -> ProjectLocationGlobalPeeringSetIamPolicyCall<'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) -> ProjectLocationGlobalPeeringSetIamPolicyCall<'a, C> { self._scopes.clear(); self } } /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. /// /// A builder for the *locations.global.peerings.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_managedidentities1 as managedidentities1; /// use managedidentities1::api::TestIamPermissionsRequest; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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_global_peerings_test_iam_permissions(req, "resource") /// .doit().await; /// # } /// ``` pub struct ProjectLocationGlobalPeeringTestIamPermissionCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _request: TestIamPermissionsRequest, _resource: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for ProjectLocationGlobalPeeringTestIamPermissionCall<'a, C> {} impl<'a, C> ProjectLocationGlobalPeeringTestIamPermissionCall<'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: "managedidentities.projects.locations.global.peerings.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, ) -> ProjectLocationGlobalPeeringTestIamPermissionCall<'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, ) -> ProjectLocationGlobalPeeringTestIamPermissionCall<'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, ) -> ProjectLocationGlobalPeeringTestIamPermissionCall<'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, ) -> ProjectLocationGlobalPeeringTestIamPermissionCall<'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, ) -> ProjectLocationGlobalPeeringTestIamPermissionCall<'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, ) -> ProjectLocationGlobalPeeringTestIamPermissionCall<'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) -> ProjectLocationGlobalPeeringTestIamPermissionCall<'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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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 ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _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: "managedidentities.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_managedidentities1 as managedidentities1; /// # async fn dox() { /// # use managedidentities1::{ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, 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 = ManagedServiceForMicrosoftActiveDirectoryConsumerAPI::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("takimata") /// .page_size(-46) /// .filter("voluptua.") /// .doit().await; /// # } /// ``` pub struct ProjectLocationListCall<'a, C> where C: 'a, { hub: &'a ManagedServiceForMicrosoftActiveDirectoryConsumerAPI, _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: "managedidentities.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 } }