Google Cloud IAM C++ Client 2.13.0
A C++ Client Library for Google Cloud IAM
Loading...
Searching...
No Matches
Public Member Functions | List of all members
google::cloud::iam_v2::PoliciesClient Class Reference

An interface for managing Identity and Access Management (IAM) policies. More...

#include <google/cloud/iam/v2/policies_client.h>

Public Member Functions

 PoliciesClient (std::shared_ptr< PoliciesConnection > connection, Options opts={})
 
 ~PoliciesClient ()
 
StreamRange< google::iam::v2::Policy > ListPolicies (std::string const &parent, Options opts={})
 Retrieves the policies of the specified kind that are attached to a resource. More...
 
StreamRange< google::iam::v2::Policy > ListPolicies (google::iam::v2::ListPoliciesRequest request, Options opts={})
 Retrieves the policies of the specified kind that are attached to a resource. More...
 
StatusOr< google::iam::v2::Policy > GetPolicy (std::string const &name, Options opts={})
 Gets a policy. More...
 
StatusOr< google::iam::v2::Policy > GetPolicy (google::iam::v2::GetPolicyRequest const &request, Options opts={})
 Gets a policy. More...
 
future< StatusOr< google::iam::v2::Policy > > CreatePolicy (std::string const &parent, google::iam::v2::Policy const &policy, std::string const &policy_id, Options opts={})
 Creates a policy. More...
 
future< StatusOr< google::iam::v2::Policy > > CreatePolicy (google::iam::v2::CreatePolicyRequest const &request, Options opts={})
 Creates a policy. More...
 
future< StatusOr< google::iam::v2::Policy > > UpdatePolicy (google::iam::v2::UpdatePolicyRequest const &request, Options opts={})
 Updates the specified policy. More...
 
future< StatusOr< google::iam::v2::Policy > > DeletePolicy (std::string const &name, Options opts={})
 Deletes a policy. More...
 
future< StatusOr< google::iam::v2::Policy > > DeletePolicy (google::iam::v2::DeletePolicyRequest const &request, Options opts={})
 Deletes a policy. More...
 
Copy and move support
 PoliciesClient (PoliciesClient const &)=default
 
PoliciesClientoperator= (PoliciesClient const &)=default
 
 PoliciesClient (PoliciesClient &&)=default
 
PoliciesClientoperator= (PoliciesClient &&)=default
 

Friends

Equality
bool operator== (PoliciesClient const &a, PoliciesClient const &b)
 
bool operator!= (PoliciesClient const &a, PoliciesClient const &b)
 

Detailed Description

An interface for managing Identity and Access Management (IAM) policies.

Equality

Instances of this class created via copy-construction or copy-assignment always compare equal. Instances created with equal std::shared_ptr<*Connection> objects compare equal. Objects that compare equal share the same underlying resources.

Performance

Creating a new instance of this class is a relatively expensive operation, new objects establish new connections to the service. In contrast, copy-construction, move-construction, and the corresponding assignment operations are relatively efficient as the copies share all underlying resources.

Thread Safety

Concurrent access to different instances of this class, even if they compare equal, is guaranteed to work. Two or more threads operating on the same instance of this class is not guaranteed to work. Since copy-construction and move-construction is a relatively efficient operation, consider using such a copy when using this class from multiple threads.

Constructor & Destructor Documentation

◆ PoliciesClient() [1/3]

google::cloud::iam_v2::PoliciesClient::PoliciesClient ( std::shared_ptr< PoliciesConnection connection,
Options  opts = {} 
)
explicit

◆ ~PoliciesClient()

google::cloud::iam_v2::PoliciesClient::~PoliciesClient ( )

◆ PoliciesClient() [2/3]

google::cloud::iam_v2::PoliciesClient::PoliciesClient ( PoliciesClient const &  )
default

◆ PoliciesClient() [3/3]

google::cloud::iam_v2::PoliciesClient::PoliciesClient ( PoliciesClient &&  )
default

Member Function Documentation

◆ CreatePolicy() [1/2]

future< StatusOr< google::iam::v2::Policy > > google::cloud::iam_v2::PoliciesClient::CreatePolicy ( google::iam::v2::CreatePolicyRequest const &  request,
Options  opts = {} 
)

Creates a policy.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.iam.v2.CreatePolicyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
A `future` that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the `StatusOr` returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.iam.v2.Policy proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.

◆ CreatePolicy() [2/2]

future< StatusOr< google::iam::v2::Policy > > google::cloud::iam_v2::PoliciesClient::CreatePolicy ( std::string const &  parent,
google::iam::v2::Policy const &  policy,
std::string const &  policy_id,
Options  opts = {} 
)

Creates a policy.

Parameters
parentRequired. The resource that the policy is attached to, along with the kind of policy to create. Format: policies/{attachment_point}/denypolicies
The attachment point is identified by its URL-encoded full resource name, which means that the forward-slash character, /, must be written as %2F. For example, policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies.
For organizations and folders, use the numeric ID in the full resource name. For projects, you can use the alphanumeric or the numeric ID.
policyRequired. The policy to create.
policy_idThe ID to use for this policy, which will become the final component of the policy's resource name. The ID must contain 3 to 63 characters. It can contain lowercase letters and numbers, as well as dashes (-) and periods (.). The first character must be a lowercase letter.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
A `future` that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the `StatusOr` returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.iam.v2.Policy proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.

◆ DeletePolicy() [1/2]

future< StatusOr< google::iam::v2::Policy > > google::cloud::iam_v2::PoliciesClient::DeletePolicy ( google::iam::v2::DeletePolicyRequest const &  request,
Options  opts = {} 
)

Deletes a policy.

This action is permanent.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.iam.v2.DeletePolicyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
A `future` that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the `StatusOr` returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.iam.v2.Policy proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.

◆ DeletePolicy() [2/2]

future< StatusOr< google::iam::v2::Policy > > google::cloud::iam_v2::PoliciesClient::DeletePolicy ( std::string const &  name,
Options  opts = {} 
)

Deletes a policy.

This action is permanent.

Parameters
nameRequired. The resource name of the policy to delete. Format: policies/{attachment_point}/denypolicies/{policy_id}
Use the URL-encoded full resource name, which means that the forward-slash character, /, must be written as %2F. For example, policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy.
For organizations and folders, use the numeric ID in the full resource name. For projects, you can use the alphanumeric or the numeric ID.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
A `future` that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the `StatusOr` returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.iam.v2.Policy proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.

◆ GetPolicy() [1/2]

StatusOr< google::iam::v2::Policy > google::cloud::iam_v2::PoliciesClient::GetPolicy ( google::iam::v2::GetPolicyRequest const &  request,
Options  opts = {} 
)

Gets a policy.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.iam.v2.GetPolicyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.iam.v2.Policy) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ GetPolicy() [2/2]

StatusOr< google::iam::v2::Policy > google::cloud::iam_v2::PoliciesClient::GetPolicy ( std::string const &  name,
Options  opts = {} 
)

Gets a policy.

Parameters
nameRequired. The resource name of the policy to retrieve. Format: policies/{attachment_point}/denypolicies/{policy_id}
Use the URL-encoded full resource name, which means that the forward-slash character, /, must be written as %2F. For example, policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy.
For organizations and folders, use the numeric ID in the full resource name. For projects, you can use the alphanumeric or the numeric ID.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
the result of the RPC. The response message type (google.iam.v2.Policy) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the `StatusOr` contains the error details.

◆ ListPolicies() [1/2]

StreamRange< google::iam::v2::Policy > google::cloud::iam_v2::PoliciesClient::ListPolicies ( google::iam::v2::ListPoliciesRequest  request,
Options  opts = {} 
)

Retrieves the policies of the specified kind that are attached to a resource.

The response lists only policy metadata. In particular, policy rules are omitted.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.iam.v2.ListPoliciesRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a `StatusOr` as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.iam.v2.Policy, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

◆ ListPolicies() [2/2]

StreamRange< google::iam::v2::Policy > google::cloud::iam_v2::PoliciesClient::ListPolicies ( std::string const &  parent,
Options  opts = {} 
)

Retrieves the policies of the specified kind that are attached to a resource.

The response lists only policy metadata. In particular, policy rules are omitted.

Parameters
parentRequired. The resource that the policy is attached to, along with the kind of policy to list. Format: policies/{attachment_point}/denypolicies
The attachment point is identified by its URL-encoded full resource name, which means that the forward-slash character, /, must be written as %2F. For example, policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies.
For organizations and folders, use the numeric ID in the full resource name. For projects, you can use the alphanumeric or the numeric ID.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a `StatusOr` as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.iam.v2.Policy, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

◆ operator=() [1/2]

PoliciesClient & google::cloud::iam_v2::PoliciesClient::operator= ( PoliciesClient &&  )
default

◆ operator=() [2/2]

PoliciesClient & google::cloud::iam_v2::PoliciesClient::operator= ( PoliciesClient const &  )
default

◆ UpdatePolicy()

future< StatusOr< google::iam::v2::Policy > > google::cloud::iam_v2::PoliciesClient::UpdatePolicy ( google::iam::v2::UpdatePolicyRequest const &  request,
Options  opts = {} 
)

Updates the specified policy.

You can update only the rules and the display name for the policy.

To update a policy, you should use a read-modify-write loop:

  1. Use GetPolicy to read the current version of the policy.
  2. Modify the policy as needed.
  3. Use UpdatePolicy to write the updated policy.

This pattern helps prevent conflicts between concurrent updates.

Parameters
requestUnary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.iam.v2.UpdatePolicyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
optsOptional. Override the class-level options, such as retry and backoff policies.
Returns
A `future` that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the `StatusOr` returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.iam.v2.Policy proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( PoliciesClient const &  a,
PoliciesClient const &  b 
)
friend

◆ operator==

bool operator== ( PoliciesClient const &  a,
PoliciesClient const &  b 
)
friend