Google Cloud Storage C++ Client  1.24.0
A C++ Client Library for Google Cloud Storage
hmac_key_metadata.h
Go to the documentation of this file.
1 // Copyright 2019 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_STORAGE_HMAC_KEY_METADATA_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_HMAC_KEY_METADATA_H
17 
19 #include "google/cloud/status_or.h"
20 #include <chrono>
21 #include <iosfwd>
22 #include <string>
23 #include <tuple>
24 
25 namespace google {
26 namespace cloud {
27 namespace storage {
28 inline namespace STORAGE_CLIENT_NS {
29 namespace internal {
30 struct HmacKeyMetadataParser;
31 } // namespace internal
32 
49  public:
50  HmacKeyMetadata() = default;
51 
52  std::string const& access_id() const { return access_id_; }
53  std::string const& etag() const { return etag_; }
54  HmacKeyMetadata& set_etag(std::string v) {
55  etag_ = std::move(v);
56  return *this;
57  }
58 
59  std::string const& id() const { return id_; }
60  std::string const& kind() const { return kind_; }
61 
62  std::string const& project_id() const { return project_id_; }
63  std::string const& service_account_email() const {
64  return service_account_email_;
65  }
66  std::string const& state() const { return state_; }
67  HmacKeyMetadata& set_state(std::string v) {
68  state_ = std::move(v);
69  return *this;
70  }
71  std::chrono::system_clock::time_point time_created() const {
72  return time_created_;
73  }
74  std::chrono::system_clock::time_point updated() const { return updated_; }
75 
76  static std::string state_active() { return "ACTIVE"; }
77  static std::string state_inactive() { return "INACTIVE"; }
78  static std::string state_deleted() { return "DELETED"; }
79 
80  private:
81  friend struct internal::HmacKeyMetadataParser;
82  friend std::ostream& operator<<(std::ostream& os, HmacKeyMetadata const& rhs);
83 
84  // Keep the fields in alphabetical order.
85  std::string access_id_;
86  std::string etag_;
87  std::string id_;
88  std::string kind_;
89  std::string project_id_;
90  std::string service_account_email_;
91  std::string state_;
92  std::chrono::system_clock::time_point time_created_;
93  std::chrono::system_clock::time_point updated_;
94 };
95 
96 inline bool operator==(HmacKeyMetadata const& lhs, HmacKeyMetadata const& rhs) {
97  auto lhs_time_created = lhs.time_created();
98  auto rhs_time_created = rhs.time_created();
99  auto lhs_updated = lhs.updated();
100  auto rhs_updated = rhs.updated();
101  return std::tie(lhs.id(), lhs.access_id(), lhs.etag(), lhs.kind(),
102  lhs.project_id(), lhs.service_account_email(), lhs.state(),
103  lhs_time_created, lhs_updated) ==
104  std::tie(rhs.id(), rhs.access_id(), rhs.etag(), rhs.kind(),
105  rhs.project_id(), rhs.service_account_email(), rhs.state(),
106  rhs_time_created, rhs_updated);
107 }
108 
109 inline bool operator!=(HmacKeyMetadata const& lhs, HmacKeyMetadata const& rhs) {
110  return std::rel_ops::operator!=(lhs, rhs);
111 }
112 
113 std::ostream& operator<<(std::ostream& os, HmacKeyMetadata const& rhs);
114 
115 } // namespace STORAGE_CLIENT_NS
116 } // namespace storage
117 } // namespace cloud
118 } // namespace google
119 
120 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_HMAC_KEY_METADATA_H
google::cloud::storage::v1::HmacKeyMetadata::set_state
HmacKeyMetadata & set_state(std::string v)
Definition: hmac_key_metadata.h:67
google::cloud::storage::v1::HmacKeyMetadata::set_etag
HmacKeyMetadata & set_etag(std::string v)
Definition: hmac_key_metadata.h:54
status_or.h
google::cloud::storage::v1::operator<<
std::ostream & operator<<(std::ostream &os, BucketAccessControl const &rhs)
Definition: bucket_access_control.cc:27
google::cloud::storage::v1::HmacKeyMetadata::HmacKeyMetadata
HmacKeyMetadata()=default
google::cloud::storage::v1::HmacKeyMetadata::etag
std::string const & etag() const
Definition: hmac_key_metadata.h:53
google::cloud::storage::v1::HmacKeyMetadata
Represents the metadata for a Google Cloud Storage HmacKeyResource.
Definition: hmac_key_metadata.h:48
google::cloud::storage::v1::HmacKeyMetadata::service_account_email
std::string const & service_account_email() const
Definition: hmac_key_metadata.h:63
version.h
google::cloud::storage::v1::HmacKeyMetadata::project_id
std::string const & project_id() const
Definition: hmac_key_metadata.h:62
google::cloud::storage::v1::operator!=
bool operator!=(BucketBilling const &lhs, BucketBilling const &rhs)
Definition: bucket_metadata.h:61
google::cloud::storage::v1::HmacKeyMetadata::kind
std::string const & kind() const
Definition: hmac_key_metadata.h:60
google::cloud::storage::v1::HmacKeyMetadata::state
std::string const & state() const
Definition: hmac_key_metadata.h:66
google::cloud::storage::v1::HmacKeyMetadata::updated
std::chrono::system_clock::time_point updated() const
Definition: hmac_key_metadata.h:74
google::cloud::storage::v1::operator!=
bool operator!=(HmacKeyMetadata const &lhs, HmacKeyMetadata const &rhs)
Definition: hmac_key_metadata.h:109
google::cloud::storage::v1::HmacKeyMetadata::state_deleted
static std::string state_deleted()
Definition: hmac_key_metadata.h:78
STORAGE_CLIENT_NS
#define STORAGE_CLIENT_NS
Definition: version.h:22
google::cloud::storage::v1::HmacKeyMetadata::access_id
std::string const & access_id() const
Definition: hmac_key_metadata.h:52
google::cloud::storage::v1::HmacKeyMetadata::state_active
static std::string state_active()
Definition: hmac_key_metadata.h:76
google::cloud::storage::v1::HmacKeyMetadata::state_inactive
static std::string state_inactive()
Definition: hmac_key_metadata.h:77
google::cloud::storage::v1::operator==
bool operator==(BucketAccessControl const &lhs, BucketAccessControl const &rhs)
Definition: bucket_access_control.cc:22
google
google::cloud::storage::v1::HmacKeyMetadata::time_created
std::chrono::system_clock::time_point time_created() const
Definition: hmac_key_metadata.h:71
google::cloud::storage::v1::HmacKeyMetadata::id
std::string const & id() const
Definition: hmac_key_metadata.h:59