|
1 | 1 | #pragma once |
2 | 2 |
|
| 3 | +#include <library/cpp/threading/future/core/future.h> |
3 | 4 | #include <util/generic/map.h> |
4 | 5 | #include <util/generic/string.h> |
5 | 6 |
|
6 | 7 | #include <ydb/core/protos/external_sources.pb.h> |
| 8 | +#include <ydb/library/actors/core/actorsystem.h> |
7 | 9 | #include <ydb/library/yql/public/issue/yql_issue.h> |
8 | 10 |
|
9 | 11 | namespace NKikimr::NExternalSource { |
10 | 12 |
|
11 | 13 | struct TExternalSourceException: public yexception { |
12 | 14 | }; |
13 | 15 |
|
| 16 | +namespace NAuth { |
| 17 | + |
| 18 | +struct TNone { |
| 19 | + static constexpr std::string_view Method = "NONE"; |
| 20 | +}; |
| 21 | + |
| 22 | +struct TAws { |
| 23 | + static constexpr std::string_view Method = "AWS"; |
| 24 | + |
| 25 | + TAws(const TString& accessKey, const TString& secretAccessKey, const TString& region) |
| 26 | + : AccessKey{accessKey} |
| 27 | + , SecretAccessKey{secretAccessKey} |
| 28 | + , Region{region} |
| 29 | + {} |
| 30 | + |
| 31 | + TString AccessKey; |
| 32 | + TString SecretAccessKey; |
| 33 | + TString Region; |
| 34 | +}; |
| 35 | + |
| 36 | +struct TServiceAccount { |
| 37 | + static constexpr std::string_view Method = "SERVICE_ACCOUNT"; |
| 38 | + |
| 39 | + TServiceAccount(TString serviceAccountId, TString serviceAccountIdSignature) |
| 40 | + : ServiceAccountId{std::move(serviceAccountId)} |
| 41 | + , ServiceAccountIdSignature{std::move(serviceAccountIdSignature)} |
| 42 | + {} |
| 43 | + |
| 44 | + TString ServiceAccountId; |
| 45 | + TString ServiceAccountIdSignature; |
| 46 | +}; |
| 47 | + |
| 48 | +using TAuth = std::variant<TNone, TServiceAccount, TAws>; |
| 49 | + |
| 50 | +std::string_view GetMethod(const TAuth& auth); |
| 51 | + |
| 52 | +inline TAuth MakeNone() { |
| 53 | + return TAuth{std::in_place_type_t<TNone>{}}; |
| 54 | +} |
| 55 | + |
| 56 | +inline TAuth MakeServiceAccount(const TString& serviceAccountId, const TString& serviceAccountIdSignature) { |
| 57 | + return TAuth{std::in_place_type_t<TServiceAccount>{}, serviceAccountId, serviceAccountIdSignature}; |
| 58 | +} |
| 59 | + |
| 60 | +inline TAuth MakeAws(const TString& accessKey, const TString& secretAccessKey, const TString& region) { |
| 61 | + return TAuth{std::in_place_type_t<TAws>{}, accessKey, secretAccessKey, region}; |
| 62 | +} |
| 63 | +} |
| 64 | + |
| 65 | +using TAuth = NAuth::TAuth; |
| 66 | + |
| 67 | +struct TMetadata { |
| 68 | + bool Changed = false; |
| 69 | + TString TableLocation; |
| 70 | + TString DataSourceLocation; |
| 71 | + TString DataSourcePath; |
| 72 | + TString Type; |
| 73 | + |
| 74 | + THashMap<TString, TString> Attributes; |
| 75 | + |
| 76 | + TAuth Auth; |
| 77 | + |
| 78 | + NKikimrExternalSources::TSchema Schema; |
| 79 | +}; |
| 80 | + |
14 | 81 | struct IExternalSource : public TThrRefBase { |
15 | 82 | using TPtr = TIntrusivePtr<IExternalSource>; |
16 | 83 |
|
@@ -54,6 +121,17 @@ struct IExternalSource : public TThrRefBase { |
54 | 121 | If an error occurs, an exception is thrown. |
55 | 122 | */ |
56 | 123 | virtual void ValidateExternalDataSource(const TString& externalDataSourceDescription) const = 0; |
| 124 | + |
| 125 | + /* |
| 126 | + Retrieve additional metadata from runtime data, enrich provided metadata |
| 127 | + */ |
| 128 | + virtual NThreading::TFuture<std::shared_ptr<TMetadata>> LoadDynamicMetadata(std::shared_ptr<TMetadata> meta) = 0; |
| 129 | + |
| 130 | + /* |
| 131 | + A method that should tell whether there is an implementation |
| 132 | + of the previous method. |
| 133 | + */ |
| 134 | + virtual bool CanLoadDynamicMetadata() const = 0; |
57 | 135 | }; |
58 | 136 |
|
59 | 137 | } |
0 commit comments