@@ -43,69 +43,63 @@ TargetType TargetType::Views() { return TargetType{"VIEWS"}; }
4343TargetType TargetType::Routines () { return TargetType{" ROUTINES" }; }
4444
4545void to_json (nlohmann::json& j, Dataset const & d) {
46- j = nlohmann::json{
47- {" kind" , d.kind },
48- {" etag" , d.etag },
49- {" id" , d.id },
50- {" self_link" , d.self_link },
51- {" friendly_name" , d.friendly_name },
52- {" description" , d.description },
53- {" type" , d.type },
54- {" location" , d.location },
55- {" default_collation" , d.default_collation },
56- {" published" , d.published },
57- {" is_case_insensitive" , d.is_case_insensitive },
58- {" labels" , d.labels },
59- {" access" , d.access },
60- {" tags" , d.tags },
61- {" dataset_reference" , d.dataset_reference },
62-
63- {" linked_dataset_source" , d.linked_dataset_source },
64- {" external_dataset_reference" , d.external_dataset_reference },
65- {" default_rounding_mode" , d.default_rounding_mode },
66- {" storage_billing_model" , d.storage_billing_model }};
67-
68- ToJson (d.default_table_expiration , j, " default_table_expiration" );
69- ToJson (d.default_partition_expiration , j, " default_partition_expiration" );
70- ToJson (d.creation_time , j, " creation_time" );
71- ToJson (d.last_modified_time , j, " last_modified_time" );
72- ToJson (d.max_time_travel , j, " max_time_travel" );
46+ j = nlohmann::json{{" kind" , d.kind },
47+ {" etag" , d.etag },
48+ {" id" , d.id },
49+ {" selfLink" , d.self_link },
50+ {" friendlyName" , d.friendly_name },
51+ {" description" , d.description },
52+ {" type" , d.type },
53+ {" location" , d.location },
54+ {" defaultCollation" , d.default_collation },
55+ {" published" , d.published },
56+ {" isCaseInsensitive" , d.is_case_insensitive },
57+ {" labels" , d.labels },
58+ {" access" , d.access },
59+ {" tags" , d.tags },
60+ {" datasetReference" , d.dataset_reference },
61+ {" linkedDatasetSource" , d.linked_dataset_source },
62+ {" defaultRoundingMode" , d.default_rounding_mode },
63+ {" storageBillingModel" , d.storage_billing_model }};
64+
65+ ToJson (d.default_table_expiration , j, " defaultTableExpirationMs" );
66+ ToJson (d.default_partition_expiration , j, " defaultPartitionExpirationMs" );
67+ ToJson (d.creation_time , j, " creationTime" );
68+ ToJson (d.last_modified_time , j, " lastModifiedTime" );
69+ ToJson (d.max_time_travel , j, " maxTimeTravelHours" );
7370}
7471
7572void from_json (nlohmann::json const & j, Dataset& d) {
7673 if (j.contains (" kind" )) j.at (" kind" ).get_to (d.kind );
7774 if (j.contains (" etag" )) j.at (" etag" ).get_to (d.etag );
7875 if (j.contains (" id" )) j.at (" id" ).get_to (d.id );
79- if (j.contains (" self_link" )) j.at (" self_link" ).get_to (d.self_link );
80- if (j.contains (" friendly_name" ))
81- j.at (" friendly_name" ).get_to (d.friendly_name );
76+ if (j.contains (" selfLink" )) j.at (" selfLink" ).get_to (d.self_link );
77+ if (j.contains (" friendlyName" )) j.at (" friendlyName" ).get_to (d.friendly_name );
8278 if (j.contains (" description" )) j.at (" description" ).get_to (d.description );
8379 if (j.contains (" type" )) j.at (" type" ).get_to (d.type );
8480 if (j.contains (" location" )) j.at (" location" ).get_to (d.location );
85- if (j.contains (" default_collation " ))
86- j.at (" default_collation " ).get_to (d.default_collation );
81+ if (j.contains (" defaultCollation " ))
82+ j.at (" defaultCollation " ).get_to (d.default_collation );
8783 if (j.contains (" published" )) j.at (" published" ).get_to (d.published );
88- if (j.contains (" is_case_insensitive " ))
89- j.at (" is_case_insensitive " ).get_to (d.is_case_insensitive );
84+ if (j.contains (" isCaseInsensitive " ))
85+ j.at (" isCaseInsensitive " ).get_to (d.is_case_insensitive );
9086 if (j.contains (" labels" )) j.at (" labels" ).get_to (d.labels );
9187 if (j.contains (" access" )) j.at (" access" ).get_to (d.access );
9288 if (j.contains (" tags" )) j.at (" tags" ).get_to (d.tags );
93- if (j.contains (" dataset_reference" ))
94- j.at (" dataset_reference" ).get_to (d.dataset_reference );
95- if (j.contains (" linked_dataset_source" ))
96- j.at (" linked_dataset_source" ).get_to (d.linked_dataset_source );
97- if (j.contains (" external_dataset_reference" ))
98- j.at (" external_dataset_reference" ).get_to (d.external_dataset_reference );
99- if (j.contains (" default_rounding_mode" ))
100- j.at (" default_rounding_mode" ).get_to (d.default_rounding_mode );
101- if (j.contains (" storage_billing_model" ))
102- j.at (" storage_billing_model" ).get_to (d.storage_billing_model );
103-
104- FromJson (d.default_table_expiration , j, " default_table_expiration" );
105- FromJson (d.default_partition_expiration , j, " default_partition_expiration" );
106- FromJson (d.creation_time , j, " creation_time" );
107- FromJson (d.last_modified_time , j, " last_modified_time" );
108- FromJson (d.max_time_travel , j, " max_time_travel" );
89+ if (j.contains (" datasetReference" ))
90+ j.at (" datasetReference" ).get_to (d.dataset_reference );
91+ if (j.contains (" linkedDatasetSource" ))
92+ j.at (" linkedDatasetSource" ).get_to (d.linked_dataset_source );
93+ if (j.contains (" defaultRoundingMode" ))
94+ j.at (" defaultRoundingMode" ).get_to (d.default_rounding_mode );
95+ if (j.contains (" storageBillingModel" ))
96+ j.at (" storageBillingModel" ).get_to (d.storage_billing_model );
97+
98+ FromJson (d.default_table_expiration , j, " defaultTableExpirationMs" );
99+ FromJson (d.default_partition_expiration , j, " defaultPartitionExpirationMs" );
100+ FromJson (d.creation_time , j, " creationTime" );
101+ FromJson (d.last_modified_time , j, " lastModifiedTime" );
102+ FromJson (d.max_time_travel , j, " maxTimeTravelHours" );
109103}
110104
111105std::string LinkedDatasetSource::DebugString (absl::string_view name,
@@ -157,34 +151,6 @@ std::string Access::DebugString(absl::string_view name,
157151 .Build ();
158152}
159153
160- std::string HiveMetastoreConnectivity::DebugString (
161- absl::string_view name, TracingOptions const & options, int indent) const {
162- return internal::DebugFormatter (name, options, indent)
163- .StringField (" access_uri_type" , access_uri_type)
164- .StringField (" access_uri" , access_uri)
165- .StringField (" metadata_connection" , metadata_connection)
166- .StringField (" storage_connection" , storage_connection)
167- .Build ();
168- }
169-
170- std::string HiveDatabaseReference::DebugString (absl::string_view name,
171- TracingOptions const & options,
172- int indent) const {
173- return internal::DebugFormatter (name, options, indent)
174- .StringField (" catalog_id" , catalog_id)
175- .StringField (" database" , database)
176- .SubMessage (" metadata_connectivity" , metadata_connectivity)
177- .Build ();
178- }
179-
180- std::string ExternalDatasetReference::DebugString (absl::string_view name,
181- TracingOptions const & options,
182- int indent) const {
183- return internal::DebugFormatter (name, options, indent)
184- .SubMessage (" hive_database" , hive_database)
185- .Build ();
186- }
187-
188154std::string GcpTag::DebugString (absl::string_view name,
189155 TracingOptions const & options,
190156 int indent) const {
@@ -219,7 +185,6 @@ std::string Dataset::DebugString(absl::string_view name,
219185 .Field (" tags" , tags)
220186 .SubMessage (" dataset_reference" , dataset_reference)
221187 .SubMessage (" linked_dataset_source" , linked_dataset_source)
222- .SubMessage (" external_dataset_reference" , external_dataset_reference)
223188 .SubMessage (" default_rounding_mode" , default_rounding_mode)
224189 .SubMessage (" storage_billing_model" , storage_billing_model)
225190 .Build ();
@@ -239,6 +204,80 @@ std::string ListFormatDataset::DebugString(absl::string_view name,
239204 .Build ();
240205}
241206
207+ void to_json (nlohmann::json& j, ListFormatDataset const & d) {
208+ j = nlohmann::json{{" kind" , d.kind },
209+ {" id" , d.id },
210+ {" friendlyName" , d.friendly_name },
211+ {" location" , d.location },
212+ {" type" , d.type },
213+ {" datasetReference" , d.dataset_reference },
214+ {" labels" , d.labels }};
215+ }
216+ void from_json (nlohmann::json const & j, ListFormatDataset& d) {
217+ // TODO(#12188): Implement SafeGetTo(...) for potentially better performance.
218+ if (j.contains (" kind" )) j.at (" kind" ).get_to (d.kind );
219+ if (j.contains (" id" )) j.at (" id" ).get_to (d.id );
220+ if (j.contains (" friendlyName" )) j.at (" friendlyName" ).get_to (d.friendly_name );
221+ if (j.contains (" location" )) j.at (" location" ).get_to (d.location );
222+ if (j.contains (" type" )) j.at (" type" ).get_to (d.type );
223+ if (j.contains (" datasetReference" )) {
224+ j.at (" datasetReference" ).get_to (d.dataset_reference );
225+ }
226+ if (j.contains (" labels" )) j.at (" labels" ).get_to (d.labels );
227+ }
228+
229+ void to_json (nlohmann::json& j, GcpTag const & t) {
230+ j = nlohmann::json{{" tagKey" , t.tag_key }, {" tagValue" , t.tag_value }};
231+ }
232+ void from_json (nlohmann::json const & j, GcpTag& t) {
233+ // TODO(#12188): Implement SafeGetTo(...) for potentially better performance.
234+ if (j.contains (" tagKey" )) j.at (" tagKey" ).get_to (t.tag_key );
235+ if (j.contains (" tagValue" )) j.at (" tagValue" ).get_to (t.tag_value );
236+ }
237+
238+ void to_json (nlohmann::json& j, Access const & a) {
239+ j = nlohmann::json{{" role" , a.role },
240+ {" userByEmail" , a.user_by_email },
241+ {" groupByEmail" , a.group_by_email },
242+ {" domain" , a.domain },
243+ {" specialGroup" , a.special_group },
244+ {" iamMember" , a.iam_member },
245+ {" view" , a.view },
246+ {" routine" , a.routine },
247+ {" dataset" , a.dataset }};
248+ }
249+ void from_json (nlohmann::json const & j, Access& a) {
250+ // TODO(#12188): Implement SafeGetTo(...) for potentially better performance.
251+ if (j.contains (" role" )) j.at (" role" ).get_to (a.role );
252+ if (j.contains (" userByEmail" )) j.at (" userByEmail" ).get_to (a.user_by_email );
253+ if (j.contains (" groupByEmail" )) j.at (" groupByEmail" ).get_to (a.group_by_email );
254+ if (j.contains (" domain" )) j.at (" domain" ).get_to (a.domain );
255+ if (j.contains (" specialGroup" )) j.at (" specialGroup" ).get_to (a.special_group );
256+ if (j.contains (" iamMember" )) j.at (" iamMember" ).get_to (a.iam_member );
257+ if (j.contains (" view" )) j.at (" view" ).get_to (a.view );
258+ if (j.contains (" routine" )) j.at (" routine" ).get_to (a.routine );
259+ if (j.contains (" dataset" )) j.at (" dataset" ).get_to (a.dataset );
260+ }
261+
262+ void to_json (nlohmann::json& j, DatasetAccessEntry const & d) {
263+ j = nlohmann::json{{" dataset" , d.dataset }, {" targetTypes" , d.target_types }};
264+ }
265+ void from_json (nlohmann::json const & j, DatasetAccessEntry& d) {
266+ // TODO(#12188): Implement SafeGetTo(...) for potentially better performance.
267+ if (j.contains (" dataset" )) j.at (" dataset" ).get_to (d.dataset );
268+ if (j.contains (" targetTypes" )) j.at (" targetTypes" ).get_to (d.target_types );
269+ }
270+
271+ void to_json (nlohmann::json& j, LinkedDatasetSource const & d) {
272+ j = nlohmann::json{{" sourceDataset" , d.source_dataset }};
273+ }
274+ void from_json (nlohmann::json const & j, LinkedDatasetSource& d) {
275+ // TODO(#12188): Implement SafeGetTo(...) for potentially better performance.
276+ if (j.contains (" sourceDataset" )) {
277+ j.at (" sourceDataset" ).get_to (d.source_dataset );
278+ }
279+ }
280+
242281GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
243282} // namespace bigquery_v2_minimal_internal
244283} // namespace cloud
0 commit comments