2020#include " google/cloud/options.h"
2121#include " google/cloud/status_or.h"
2222#include " google/cloud/version.h"
23- #include " absl/types/optional.h"
2423#include < chrono>
2524#include < functional>
2625#include < memory>
26+ #include < optional>
2727#include < string>
2828#include < vector>
2929
@@ -42,6 +42,7 @@ class ExternalAccountConfig;
4242class ApiKeyConfig ;
4343class ComputeEngineCredentialsConfig ;
4444class AuthorizedUserConfig ;
45+ class GDCHServiceAccountConfig ;
4546
4647std::shared_ptr<Credentials> MakeErrorCredentials (Status error_status);
4748
@@ -70,6 +71,7 @@ class CredentialsVisitor {
7071 virtual void visit (ApiKeyConfig const &) = 0;
7172 virtual void visit (ComputeEngineCredentialsConfig const &) = 0;
7273 virtual void visit (AuthorizedUserConfig const &) = 0;
74+ virtual void visit (GDCHServiceAccountConfig const &) = 0;
7375
7476 static void dispatch (Credentials const & credentials,
7577 CredentialsVisitor& visitor);
@@ -161,20 +163,18 @@ class ServiceAccountConfig : public Credentials {
161163 // Only one of json_object or file_path should have a value.
162164 // TODO(#15886): Use the C++ type system to make better constructors that
163165 // enforces this comment.
164- ServiceAccountConfig (absl ::optional<std::string> json_object,
165- absl ::optional<std::string> file_path, Options opts);
166+ ServiceAccountConfig (std ::optional<std::string> json_object,
167+ std ::optional<std::string> file_path, Options opts);
166168
167- absl::optional<std::string> const & json_object () const {
168- return json_object_;
169- }
170- absl::optional<std::string> const & file_path () const { return file_path_; }
169+ std::optional<std::string> const & json_object () const { return json_object_; }
170+ std::optional<std::string> const & file_path () const { return file_path_; }
171171 Options const & options () const { return options_; }
172172
173173 private:
174174 void dispatch (CredentialsVisitor& v) const override { v.visit (*this ); }
175175
176- absl ::optional<std::string> json_object_;
177- absl ::optional<std::string> file_path_;
176+ std ::optional<std::string> json_object_;
177+ std ::optional<std::string> file_path_;
178178 Options options_;
179179};
180180
@@ -235,6 +235,28 @@ class AuthorizedUserConfig : public Credentials {
235235 Options options_;
236236};
237237
238+ class GDCHServiceAccountConfig : public Credentials {
239+ public:
240+ GDCHServiceAccountConfig (std::string json_object, std::string audience,
241+ Options opts);
242+ GDCHServiceAccountConfig (std::string audience, Options opts);
243+
244+ ~GDCHServiceAccountConfig () override = default ;
245+
246+ std::optional<std::string> const & file_path () const { return file_path_; }
247+ std::string const & json_object () const { return json_object_; }
248+ std::string const & audience () const { return audience_; }
249+ Options const & options () const { return options_; }
250+
251+ private:
252+ void dispatch (CredentialsVisitor& v) const override { v.visit (*this ); }
253+
254+ std::optional<std::string> file_path_ = std::nullopt ;
255+ std::string json_object_;
256+ std::string audience_;
257+ Options options_;
258+ };
259+
238260// / A helper function to initialize Auth options.
239261Options PopulateAuthOptions (Options options);
240262
0 commit comments