pub struct OrgPolicy { /* private fields */ }Expand description
Implements a client for the Organization Policy API.
§Example
let client = OrgPolicy::builder().build().await?;
// use `client` to make requests to the Organization Policy API.§Service Description
An interface for managing organization policies.
The Organization Policy Service provides a simple mechanism for organizations to restrict the allowed configurations across their entire resource hierarchy.
You can use a policy to configure restrictions on resources. For example, you can enforce a policy that restricts which Google Cloud APIs can be activated in a certain part of your resource hierarchy, or prevents serial port access to VM instances in a particular folder.
Policies are inherited down through the resource hierarchy. A policy applied to a parent resource automatically applies to all its child resources unless overridden with a policy lower in the hierarchy.
A constraint defines an aspect of a resource’s configuration that can be controlled by an organization’s policy administrator. Policies are a collection of constraints that defines their allowable configuration on a particular resource and its child resources.
§Configuration
To configure OrgPolicy use the with_* methods in the type returned
by builder(). The default configuration should
work for most applications. Common configuration changes include
- with_endpoint(): by default this client uses the global default endpoint
(
https://orgpolicy.googleapis.com). Applications using regional endpoints or running in restricted networks (e.g. a network configured override this default. - with_credentials(): by default this client uses Application Default Credentials. Applications using custom authentication may need to override this default.
§Pooling and Cloning
OrgPolicy holds a connection pool internally, it is advised to
create one and the reuse it. You do not need to wrap OrgPolicy in
an Rc or Arc to reuse it, because it
already uses an Arc internally.
Implementations§
Source§impl OrgPolicy
impl OrgPolicy
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for OrgPolicy.
let client = OrgPolicy::builder().build().await?;Sourcepub fn from_stub<T>(stub: T) -> Selfwhere
T: OrgPolicy + 'static,
pub fn from_stub<T>(stub: T) -> Selfwhere
T: OrgPolicy + 'static,
Creates a new client from the provided stub.
The most common case for calling this function is in tests mocking the client’s behavior.
Sourcepub fn list_constraints(&self) -> ListConstraints
pub fn list_constraints(&self) -> ListConstraints
Lists constraints that could be applied on the specified resource.
Sourcepub fn list_policies(&self) -> ListPolicies
pub fn list_policies(&self) -> ListPolicies
Retrieves all of the policies that exist on a particular resource.
Sourcepub fn get_policy(&self) -> GetPolicy
pub fn get_policy(&self) -> GetPolicy
Gets a policy on a resource.
If no policy is set on the resource, NOT_FOUND is returned. The
etag value can be used with UpdatePolicy() to update a
policy during read-modify-write.
Sourcepub fn get_effective_policy(&self) -> GetEffectivePolicy
pub fn get_effective_policy(&self) -> GetEffectivePolicy
Gets the effective policy on a resource. This is the result of merging
policies in the resource hierarchy and evaluating conditions. The
returned policy will not have an etag or condition set because it is
an evaluated policy across multiple resources.
Subtrees of Resource Manager resource hierarchy with ‘under:’ prefix will
not be expanded.
Sourcepub fn create_policy(&self) -> CreatePolicy
pub fn create_policy(&self) -> CreatePolicy
Creates a policy.
Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the
constraint does not exist.
Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the
policy already exists on the given Google Cloud resource.
Sourcepub fn update_policy(&self) -> UpdatePolicy
pub fn update_policy(&self) -> UpdatePolicy
Updates a policy.
Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the
constraint or the policy do not exist.
Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag
supplied in the request does not match the persisted etag of the policy
Note: the supplied policy will perform a full overwrite of all fields.
Sourcepub fn delete_policy(&self) -> DeletePolicy
pub fn delete_policy(&self) -> DeletePolicy
Deletes a policy.
Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the
constraint or organization policy does not exist.
Sourcepub fn create_custom_constraint(&self) -> CreateCustomConstraint
pub fn create_custom_constraint(&self) -> CreateCustomConstraint
Creates a custom constraint.
Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the
organization does not exist.
Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the
constraint already exists on the given organization.
Sourcepub fn update_custom_constraint(&self) -> UpdateCustomConstraint
pub fn update_custom_constraint(&self) -> UpdateCustomConstraint
Updates a custom constraint.
Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the
constraint does not exist.
Note: the supplied policy will perform a full overwrite of all fields.
Sourcepub fn get_custom_constraint(&self) -> GetCustomConstraint
pub fn get_custom_constraint(&self) -> GetCustomConstraint
Gets a custom or managed constraint.
Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the
custom or managed constraint does not exist.
Sourcepub fn list_custom_constraints(&self) -> ListCustomConstraints
pub fn list_custom_constraints(&self) -> ListCustomConstraints
Retrieves all of the custom constraints that exist on a particular organization resource.
Sourcepub fn delete_custom_constraint(&self) -> DeleteCustomConstraint
pub fn delete_custom_constraint(&self) -> DeleteCustomConstraint
Deletes a custom constraint.
Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the
constraint does not exist.