1 // Copyright 2018 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_POLICY_H 16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_POLICY_H 17 18 #include "google/cloud/iam_bindings.h" 19 #include "google/cloud/version.h" 20 21 namespace google { 22 namespace cloud { 23 inline namespace GOOGLE_CLOUD_CPP_NS { 24 /** 25 * Represent the result of a GetIamPolicy or SetIamPolicy request. 26 * 27 * This is a simple struct to hold the version, IamBindings, and ETag. 28 * 29 * @see 30 * https://cloud.google.com/resource-manager/reference/rest/Shared.Types/Policy 31 * for more information about a AIM policies. 32 * 33 * @see https://tools.ietf.org/html/rfc7232#section-2.3 for more information 34 * about ETags. 35 */ 36 struct IamPolicy { 37 std::int32_t version; 38 IamBindings bindings; 39 std::string etag; 40 }; 41 42 inline bool operator==(IamPolicy const& lhs, IamPolicy const& rhs) { 43 return std::tie(lhs.version, lhs.bindings, lhs.etag) == 44 std::tie(rhs.version, rhs.bindings, rhs.etag); 45 } 46 47 inline bool operator<(IamPolicy const& lhs, IamPolicy const& rhs) { 48 return std::tie(lhs.version, lhs.bindings, lhs.etag) < 49 std::tie(rhs.version, rhs.bindings, rhs.etag); 50 } 51 52 inline bool operator!=(IamPolicy const& lhs, IamPolicy const& rhs) { 53 return std::rel_ops::operator!=(lhs, rhs); 54 } 55 56 inline bool operator>(IamPolicy const& lhs, IamPolicy const& rhs) { 57 return std::rel_ops::operator>(lhs, rhs); 58 } 59 60 inline bool operator<=(IamPolicy const& lhs, IamPolicy const& rhs) { 61 return std::rel_ops::operator<=(lhs, rhs); 62 } 63 64 inline bool operator>=(IamPolicy const& lhs, IamPolicy const& rhs) { 65 return std::rel_ops::operator>=(lhs, rhs); 66 } 67 68 std::ostream& operator<<(std::ostream& os, IamPolicy const& rhs); 69 70 } // namespace GOOGLE_CLOUD_CPP_NS 71 } // namespace cloud 72 } // namespace google 73 74 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_IAM_POLICY_H 75