Google Cloud Storage C++ Client  1.32.1
A C++ Client Library for Google Cloud Storage
object_access_control.cc
Go to the documentation of this file.
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 #include "google/cloud/storage/object_access_control.h"
16 #include "google/cloud/storage/internal/metadata_parser.h"
17 #include <nlohmann/json.hpp>
18 
19 namespace google {
20 namespace cloud {
21 namespace storage {
22 inline namespace STORAGE_CLIENT_NS {
23 bool operator==(ObjectAccessControl const& lhs,
24  ObjectAccessControl const& rhs) {
25  // Start with id, generation, object, bucket, etag because they should fail
26  // early, then alphabetical for readability.
27  return lhs.object_ == rhs.object_ && lhs.generation_ == rhs.generation_ &&
28  *static_cast<internal::AccessControlCommon const*>(&lhs) == rhs;
29 }
30 
31 std::ostream& operator<<(std::ostream& os, ObjectAccessControl const& rhs) {
32  os << "ObjectAccessControl={bucket=" << rhs.bucket()
33  << ", domain=" << rhs.domain() << ", email=" << rhs.email()
34  << ", entity=" << rhs.entity() << ", entity_id=" << rhs.entity_id()
35  << ", etag=" << rhs.etag() << ", generation=" << rhs.generation()
36  << ", id=" << rhs.id() << ", kind=" << rhs.kind()
37  << ", object=" << rhs.object();
38 
39  if (rhs.has_project_team()) {
40  os << ", project_team.project_number=" << rhs.project_team().project_number
41  << ", project_team.team=" << rhs.project_team().team;
42  }
43 
44  return os << ", role=" << rhs.role() << ", self_link=" << rhs.self_link()
45  << "}";
46 }
47 } // namespace STORAGE_CLIENT_NS
48 } // namespace storage
49 } // namespace cloud
50 } // namespace google