bigquery_audit_metadata.proto 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  1. // Copyright 2022 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. syntax = "proto3";
  15. package google.cloud.audit;
  16. import "google/iam/v1/policy.proto";
  17. import "google/protobuf/duration.proto";
  18. import "google/protobuf/timestamp.proto";
  19. import "google/rpc/status.proto";
  20. option csharp_namespace = "Google.Cloud.Audit";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/audit;audit";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "BigQueryAuditMetadataProto";
  24. option java_package = "com.google.cloud.audit";
  25. option objc_class_prefix = "GCA";
  26. option php_namespace = "Google\\Cloud\\Audit";
  27. // Audit log format for BigQuery cloud audit logs metadata.
  28. //
  29. message BigQueryAuditMetadata {
  30. // Job insertion event.
  31. message JobInsertion {
  32. // Describes how the job was inserted.
  33. enum Reason {
  34. // Unknown.
  35. REASON_UNSPECIFIED = 0;
  36. // Job was inserted using the jobs.insert API.
  37. JOB_INSERT_REQUEST = 1;
  38. // Job was inserted using the jobs.query RPC.
  39. QUERY_REQUEST = 2;
  40. }
  41. // Job metadata.
  42. Job job = 1;
  43. // Describes how the job was inserted.
  44. Reason reason = 2;
  45. }
  46. // Job state change event.
  47. message JobChange {
  48. // Job state before the job state change.
  49. JobState before = 1;
  50. // Job state after the job state change.
  51. JobState after = 2;
  52. // Job metadata.
  53. Job job = 3;
  54. }
  55. // Job deletion event.
  56. message JobDeletion {
  57. // Describes how the job was deleted.
  58. enum Reason {
  59. // Unknown.
  60. REASON_UNSPECIFIED = 0;
  61. // Job was deleted using the jobs.delete API.
  62. JOB_DELETE_REQUEST = 1;
  63. }
  64. // Job URI.
  65. //
  66. // Format: `projects/<project_id>/jobs/<job_id>`.
  67. string job_name = 1;
  68. // Describes how the job was deleted.
  69. Reason reason = 2;
  70. }
  71. // Dataset creation event.
  72. message DatasetCreation {
  73. // Describes how the dataset was created.
  74. enum Reason {
  75. // Unknown.
  76. REASON_UNSPECIFIED = 0;
  77. // Dataset was created using the datasets.create API.
  78. CREATE = 1;
  79. // Dataset was created using a query job, e.g., CREATE SCHEMA statement.
  80. QUERY = 2;
  81. }
  82. // Dataset metadata.
  83. Dataset dataset = 1;
  84. // Describes how the dataset was created.
  85. Reason reason = 2;
  86. // The URI of the job that created the dataset.
  87. // Present if the reason is QUERY.
  88. //
  89. // Format: `projects/<project_id>/jobs/<job_id>`.
  90. string job_name = 3;
  91. }
  92. // Dataset change event.
  93. message DatasetChange {
  94. // Describes how the dataset was changed.
  95. enum Reason {
  96. // Unknown.
  97. REASON_UNSPECIFIED = 0;
  98. // Dataset was changed using the datasets.update or datasets.patch API.
  99. UPDATE = 1;
  100. // Dataset was changed using the SetIamPolicy API.
  101. SET_IAM_POLICY = 2;
  102. // Dataset was changed using a query job, e.g., ALTER SCHEMA statement.
  103. QUERY = 3;
  104. }
  105. // Dataset metadata after the change.
  106. Dataset dataset = 1;
  107. // Describes how the dataset was changed.
  108. Reason reason = 2;
  109. // The URI of the job that updated the dataset.
  110. // Present if the reason is QUERY.
  111. //
  112. // Format: `projects/<project_id>/jobs/<job_id>`.
  113. string job_name = 3;
  114. }
  115. // Dataset deletion event.
  116. message DatasetDeletion {
  117. // Describes how the dataset was deleted.
  118. enum Reason {
  119. // Unknown.
  120. REASON_UNSPECIFIED = 0;
  121. // Dataset was deleted using the datasets.delete API.
  122. DELETE = 1;
  123. // Dataset was deleted using a query job, e.g., DROP SCHEMA statement.
  124. QUERY = 2;
  125. }
  126. // Describes how the dataset was deleted.
  127. Reason reason = 1;
  128. // The URI of the job that deleted the dataset.
  129. // Present if the reason is QUERY.
  130. //
  131. // Format: `projects/<project_id>/jobs/<job_id>`.
  132. string job_name = 2;
  133. }
  134. // Table creation event.
  135. message TableCreation {
  136. // Describes how the table was created.
  137. enum Reason {
  138. // Unknown.
  139. REASON_UNSPECIFIED = 0;
  140. // Table was created as a destination table during a query, load or copy
  141. // job.
  142. JOB = 1;
  143. // Table was created using a DDL query.
  144. QUERY = 2;
  145. // Table was created using the tables.create API.
  146. TABLE_INSERT_REQUEST = 3;
  147. }
  148. // Table metadata.
  149. Table table = 1;
  150. // Describes how the table was created.
  151. Reason reason = 3;
  152. // The URI of the job that created a table.
  153. // Present if the reason is JOB or QUERY.
  154. //
  155. // Format: `projects/<project_id>/jobs/<job_id>`.
  156. string job_name = 4;
  157. }
  158. // Model creation event.
  159. message ModelCreation {
  160. // Describes how the model was created.
  161. enum Reason {
  162. // Unknown.
  163. REASON_UNSPECIFIED = 0;
  164. // Model was created using a DDL query.
  165. QUERY = 2;
  166. }
  167. // Model metadata.
  168. Model model = 1;
  169. // Describes how the model was created.
  170. Reason reason = 3;
  171. // The URI of the job that created the model.
  172. //
  173. // Format: `projects/<project_id>/jobs/<job_id>`.
  174. string job_name = 4;
  175. }
  176. // Routine creation event.
  177. message RoutineCreation {
  178. // Describes how the routine was created.
  179. enum Reason {
  180. // Unknown.
  181. REASON_UNSPECIFIED = 0;
  182. // Routine was created using a DDL query.
  183. QUERY = 1;
  184. // Routine was created using the routines.create API.
  185. ROUTINE_INSERT_REQUEST = 2;
  186. }
  187. // Created routine.
  188. Routine routine = 1;
  189. // Describes how the routine was created.
  190. Reason reason = 3;
  191. // The URI of the job that created the routine.
  192. //
  193. // Format: `projects/<project_id>/jobs/<job_id>`.
  194. string job_name = 4;
  195. }
  196. // Table data read event.
  197. message TableDataRead {
  198. // Describes how the table data was read.
  199. enum Reason {
  200. // Unknown.
  201. REASON_UNSPECIFIED = 0;
  202. // Table was used as a source table during a BigQuery job.
  203. JOB = 1;
  204. // Table data was accessed using the tabledata.list API.
  205. TABLEDATA_LIST_REQUEST = 2;
  206. // Table data was accessed using the jobs.getQueryResults API.
  207. GET_QUERY_RESULTS_REQUEST = 3;
  208. // Table data was accessed using the jobs.query RPC.
  209. QUERY_REQUEST = 4;
  210. // Table data was accessed using storage.CreateReadSession API.
  211. CREATE_READ_SESSION = 5;
  212. // Table data was accessed during a materialized view refresh.
  213. MATERIALIZED_VIEW_REFRESH = 6;
  214. }
  215. // List of the accessed fields. Entire list is truncated if the record size
  216. // exceeds 100K.
  217. repeated string fields = 2;
  218. // True if the fields list was truncated.
  219. bool fields_truncated = 8;
  220. // List of the referenced policy tags. That is, policy tags attached to the
  221. // accessed fields or their ancestors.
  222. // Policy tag resource name is a string of the format:
  223. // `projects/<project_id>/locations/<location_id>/taxonomies/<taxonomy_id>/policyTags/<policy_tag_id>`
  224. repeated string policy_tags = 9;
  225. // True if the policy tag list was truncated. At most 100 policy tags can be
  226. // saved.
  227. bool policy_tags_truncated = 10;
  228. // Describes how the table data was read.
  229. Reason reason = 3;
  230. // The URI of the job that read a table.
  231. // Present if the reason is JOB but can be redacted for privacy reasons.
  232. //
  233. // Format: `projects/<project_id>/jobs/<job_id>`.
  234. string job_name = 4;
  235. // The URI of the read session that read a table.
  236. // Present if the reason is CREATE_READ_SESSION.
  237. //
  238. // Format:
  239. // `projects/<project_id>/locations/<location>/sessions/<session_id>`.
  240. string session_name = 5;
  241. }
  242. // Table metadata change event.
  243. message TableChange {
  244. // Describes how the table metadata was changed.
  245. enum Reason {
  246. // Unknown.
  247. REASON_UNSPECIFIED = 0;
  248. // Table metadata was updated using the tables.update or tables.patch API.
  249. TABLE_UPDATE_REQUEST = 1;
  250. // Table was used as a job destination table.
  251. JOB = 2;
  252. // Table metadata was updated using a DML or DDL query.
  253. QUERY = 3;
  254. }
  255. // Updated table metadata.
  256. Table table = 1;
  257. // True if the table was truncated.
  258. bool truncated = 4;
  259. // Describes how the table metadata was changed.
  260. Reason reason = 5;
  261. // The URI of the job that changed a table.
  262. // Present if the reason is JOB or QUERY.
  263. //
  264. // Format: `projects/<project_id>/jobs/<job_id>`.
  265. string job_name = 6;
  266. }
  267. // Model metadata change event.
  268. message ModelMetadataChange {
  269. // Describes how the model metadata was changed.
  270. enum Reason {
  271. // Unknown.
  272. REASON_UNSPECIFIED = 0;
  273. // Model metadata was updated using the models.patch API.
  274. MODEL_PATCH_REQUEST = 1;
  275. // Model metadata was updated using a DDL query.
  276. QUERY = 2;
  277. }
  278. // Updated model.
  279. Model model = 1;
  280. // Describes how the model metadata was changed.
  281. Reason reason = 2;
  282. // The URI of the job that changed the model metadata.
  283. // Present if and only if the reason is QUERY.
  284. //
  285. // Format: `projects/<project_id>/jobs/<job_id>`.
  286. string job_name = 3;
  287. }
  288. // Routine change event.
  289. message RoutineChange {
  290. // Describes how the routine was updated.
  291. enum Reason {
  292. // Unknown.
  293. REASON_UNSPECIFIED = 0;
  294. // Routine was updated using a DDL query.
  295. QUERY = 1;
  296. // Routine was updated using the routines.update or routines.patch API.
  297. ROUTINE_UPDATE_REQUEST = 2;
  298. }
  299. // Updated routine.
  300. Routine routine = 1;
  301. // Describes how the routine was updated.
  302. Reason reason = 3;
  303. // The URI of the job that updated the routine.
  304. //
  305. // Format: `projects/<project_id>/jobs/<job_id>`.
  306. string job_name = 4;
  307. }
  308. // Table data change event.
  309. message TableDataChange {
  310. // Describes how the table data was changed.
  311. enum Reason {
  312. // Unknown.
  313. REASON_UNSPECIFIED = 0;
  314. // Table was used as a job destination table.
  315. JOB = 1;
  316. // Table data was updated using a DML or DDL query.
  317. QUERY = 2;
  318. // Table data was updated during a materialized view refresh.
  319. MATERIALIZED_VIEW_REFRESH = 3;
  320. // Table data was added using the Write API.
  321. WRITE_API = 4;
  322. }
  323. // Number of deleted rows.
  324. int64 deleted_rows_count = 1;
  325. // Number of inserted rows.
  326. int64 inserted_rows_count = 2;
  327. // True if the table was truncated.
  328. bool truncated = 3;
  329. // Describes how the table data was changed.
  330. Reason reason = 4;
  331. // The URI of the job that changed a table.
  332. //
  333. // Format: `projects/<project_id>/jobs/<job_id>`.
  334. string job_name = 5;
  335. // If written from WRITE_API, the name of the stream.
  336. //
  337. // Format:
  338. // `projects/<project_id>/datasets/<dataset_id>/tables/<table_id>/streams/<stream_id>`
  339. string stream_name = 6;
  340. }
  341. // Model data change event.
  342. message ModelDataChange {
  343. // Describes how the model data was changed.
  344. enum Reason {
  345. // Unknown.
  346. REASON_UNSPECIFIED = 0;
  347. // Model data was changed using a DDL query.
  348. QUERY = 1;
  349. }
  350. // Describes how the model data was changed.
  351. Reason reason = 1;
  352. // The URI of the job that changed the model data.
  353. //
  354. // Format: `projects/<project_id>/jobs/<job_id>`.
  355. string job_name = 2;
  356. }
  357. // Model data read event.
  358. message ModelDataRead {
  359. // Describes how the model data was read.
  360. enum Reason {
  361. // Unknown.
  362. REASON_UNSPECIFIED = 0;
  363. // Model was used as a source model during a BigQuery job.
  364. JOB = 1;
  365. }
  366. // Describes how the model data was read.
  367. Reason reason = 1;
  368. // The URI of the job that read the model data.
  369. //
  370. // Format: `projects/<project_id>/jobs/<job_id>`.
  371. string job_name = 2;
  372. }
  373. // Table deletion event.
  374. message TableDeletion {
  375. // Describes how the table was deleted.
  376. enum Reason {
  377. // Unknown.
  378. REASON_UNSPECIFIED = 0;
  379. // Table was deleted using the tables.delete API.
  380. TABLE_DELETE_REQUEST = 2;
  381. // Table expired.
  382. EXPIRED = 3;
  383. // Table deleted using a DDL query.
  384. QUERY = 4;
  385. }
  386. // Describes how table was deleted.
  387. Reason reason = 1;
  388. // The URI of the job that deleted a table.
  389. // Present if the reason is QUERY.
  390. //
  391. // Format: `projects/<project_id>/jobs/<job_id>`.
  392. string job_name = 2;
  393. }
  394. // Model deletion event.
  395. message ModelDeletion {
  396. // Describes how the model was deleted.
  397. enum Reason {
  398. // Unknown.
  399. REASON_UNSPECIFIED = 0;
  400. // Model was deleted using the models.delete API.
  401. MODEL_DELETE_REQUEST = 1;
  402. // Model expired.
  403. EXPIRED = 2;
  404. // Model was deleted using DDL query.
  405. QUERY = 3;
  406. }
  407. // Describes how the model was deleted.
  408. Reason reason = 1;
  409. // The URI of the job that deleted a model.
  410. // Present if the reason is QUERY.
  411. //
  412. // Format: `projects/<project_id>/jobs/<job_id>`.
  413. string job_name = 2;
  414. }
  415. // Routine deletion event.
  416. message RoutineDeletion {
  417. // Describes how the routine was deleted.
  418. enum Reason {
  419. // Unknown.
  420. REASON_UNSPECIFIED = 0;
  421. // Routine was deleted using DDL query.
  422. QUERY = 1;
  423. // Routine was deleted using the API.
  424. ROUTINE_DELETE_REQUEST = 2;
  425. }
  426. // Deleted routine.
  427. Routine routine = 1;
  428. // Describes how the routine was deleted.
  429. Reason reason = 3;
  430. // The URI of the job that deleted the routine.
  431. // Present if the reason is QUERY.
  432. //
  433. // Format: `projects/<project_id>/jobs/<job_id>`.
  434. string job_name = 4;
  435. }
  436. // Row access policy creation event.
  437. message RowAccessPolicyCreation {
  438. // The row access policy created by this event.
  439. RowAccessPolicy row_access_policy = 1;
  440. // The URI of the job that created this row access policy.
  441. //
  442. // Format: `projects/<project_id>/jobs/<job_id>`.
  443. string job_name = 2;
  444. }
  445. // Row access policy change event.
  446. message RowAccessPolicyChange {
  447. // The row access policy that was changed by this event.
  448. RowAccessPolicy row_access_policy = 1;
  449. // The URI of the job that created this row access policy.
  450. //
  451. // Format: `projects/<project_id>/jobs/<job_id>`.
  452. string job_name = 2;
  453. }
  454. // Row access policy deletion event.
  455. message RowAccessPolicyDeletion {
  456. // The row access policies that were deleted. At present, only populated
  457. // when a single policy is dropped.
  458. repeated RowAccessPolicy row_access_policies = 1;
  459. // The job that deleted these row access policies.
  460. //
  461. // Format: `projects/<project_id>/jobs/<job_id>`.
  462. string job_name = 2;
  463. // This field is set to true when a DROP ALL command has been executed, thus
  464. // removing all row access policies on the table.
  465. bool all_row_access_policies_dropped = 3;
  466. }
  467. // Unlink linked dataset from its source dataset event
  468. message UnlinkDataset {
  469. // Describes how the unlinking operation occurred.
  470. enum Reason {
  471. // Unknown.
  472. REASON_UNSPECIFIED = 0;
  473. // Linked dataset unlinked via API
  474. UNLINK_API = 1;
  475. }
  476. // The linked dataset URI which is unlinked from its source.
  477. //
  478. // Format: `projects/<project_id>/datasets/<dataset_id>`.
  479. string linked_dataset = 1;
  480. // The source dataset URI from which the linked dataset is unlinked.
  481. //
  482. // Format: `projects/<project_id>/datasets/<dataset_id>`.
  483. string source_dataset = 2;
  484. // Reason for unlinking linked dataset
  485. Reason reason = 3;
  486. }
  487. // BigQuery job.
  488. message Job {
  489. // Job URI.
  490. //
  491. // Format: `projects/<project_id>/jobs/<job_id>`.
  492. string job_name = 1;
  493. // Job configuration.
  494. JobConfig job_config = 2;
  495. // Job status.
  496. JobStatus job_status = 3;
  497. // Job statistics.
  498. JobStats job_stats = 4;
  499. }
  500. // Job configuration.
  501. // See the [Jobs](https://cloud.google.com/bigquery/docs/reference/v2/jobs)
  502. // API resource for more details on individual fields.
  503. message JobConfig {
  504. // Job type.
  505. enum Type {
  506. // Unknown.
  507. TYPE_UNSPECIFIED = 0;
  508. // Query job.
  509. QUERY = 1;
  510. // Table copy job.
  511. COPY = 2;
  512. // Export (extract) job.
  513. EXPORT = 3;
  514. // Import (load) job.
  515. IMPORT = 4;
  516. }
  517. // Query job configuration.
  518. message Query {
  519. // Priority given to the query.
  520. enum Priority {
  521. // Unknown.
  522. PRIORITY_UNSPECIFIED = 0;
  523. // Interactive query.
  524. QUERY_INTERACTIVE = 1;
  525. // Batch query.
  526. QUERY_BATCH = 2;
  527. }
  528. // The SQL query to run. Truncated if exceeds 50K.
  529. string query = 1;
  530. // True if the query field was truncated.
  531. bool query_truncated = 10;
  532. // The destination table for the query results.
  533. string destination_table = 2;
  534. // Destination table create disposition.
  535. CreateDisposition create_disposition = 3;
  536. // Destination table write disposition.
  537. WriteDisposition write_disposition = 4;
  538. // Default dataset for the query.
  539. string default_dataset = 5;
  540. // External data sources used in the query.
  541. repeated TableDefinition table_definitions = 6;
  542. // Priority given to the query.
  543. Priority priority = 7;
  544. // Result table encryption information. Set when non-default encryption is
  545. // used.
  546. EncryptionInfo destination_table_encryption = 8;
  547. // Type of the query.
  548. QueryStatementType statement_type = 9;
  549. }
  550. // Load job configuration.
  551. message Load {
  552. // URIs for the data to be imported. Entire list is truncated if exceeds
  553. // 40K.
  554. repeated string source_uris = 1;
  555. // True if the source_URIs field was truncated.
  556. bool source_uris_truncated = 7;
  557. // The table schema in JSON format. Entire field is truncated if exceeds
  558. // 40K.
  559. string schema_json = 2;
  560. // True if the schema_json field was truncated.
  561. bool schema_json_truncated = 8;
  562. // The destination table for the import.
  563. string destination_table = 3;
  564. // Destination table create disposition.
  565. CreateDisposition create_disposition = 4;
  566. // Destination table write disposition.
  567. WriteDisposition write_disposition = 5;
  568. // Result table encryption information. Set when non-default encryption is
  569. // used.
  570. EncryptionInfo destination_table_encryption = 6;
  571. }
  572. // Extract job configuration.
  573. message Extract {
  574. // URIs where extracted data should be written. Entire list is truncated
  575. // if exceeds 50K.
  576. repeated string destination_uris = 1;
  577. // True if the destination_URIs field was truncated.
  578. bool destination_uris_truncated = 3;
  579. oneof source {
  580. // The source table.
  581. string source_table = 2;
  582. // The source model.
  583. string source_model = 4;
  584. }
  585. }
  586. // Table copy job configuration.
  587. message TableCopy {
  588. // Source tables. Entire list is truncated if exceeds 50K.
  589. repeated string source_tables = 1;
  590. // True if the source_tables field was truncated.
  591. bool source_tables_truncated = 6;
  592. // Destination table.
  593. string destination_table = 2;
  594. // Destination table create disposition.
  595. CreateDisposition create_disposition = 3;
  596. // Destination table write disposition.
  597. WriteDisposition write_disposition = 4;
  598. // Result table encryption information. Set when non-default encryption is
  599. // used.
  600. EncryptionInfo destination_table_encryption = 5;
  601. // Supported operation types in the table copy job.
  602. OperationType operation_type = 7;
  603. // Expiration time set on the destination table. Expired tables will be
  604. // deleted and their storage reclaimed.
  605. google.protobuf.Timestamp destination_expiration_time = 8;
  606. }
  607. // Job type.
  608. Type type = 1;
  609. // Job configuration information.
  610. oneof config {
  611. // Query job information.
  612. Query query_config = 2;
  613. // Load job information.
  614. Load load_config = 3;
  615. // Extract job information.
  616. Extract extract_config = 4;
  617. // TableCopy job information.
  618. TableCopy table_copy_config = 5;
  619. }
  620. // Labels provided for the job.
  621. map<string, string> labels = 6;
  622. }
  623. // Definition of an external data source used in a query.
  624. message TableDefinition {
  625. // Name of the table, used in queries.
  626. string name = 1;
  627. // URIs for the data.
  628. repeated string source_uris = 2;
  629. }
  630. // Describes whether a job should create a destination table if it doesn't
  631. // exist.
  632. enum CreateDisposition {
  633. // Unknown.
  634. CREATE_DISPOSITION_UNSPECIFIED = 0;
  635. // This job should never create tables.
  636. CREATE_NEVER = 1;
  637. // This job should create a table if it doesn't already exist.
  638. CREATE_IF_NEEDED = 2;
  639. }
  640. // Describes whether a job should overwrite or append the existing destination
  641. // table if it already exists.
  642. enum WriteDisposition {
  643. // Unknown.
  644. WRITE_DISPOSITION_UNSPECIFIED = 0;
  645. // This job should only be writing to empty tables.
  646. WRITE_EMPTY = 1;
  647. // This job will truncate the existing table data.
  648. WRITE_TRUNCATE = 2;
  649. // This job will append to the table.
  650. WRITE_APPEND = 3;
  651. }
  652. // Table copy job operation type.
  653. enum OperationType {
  654. // Unspecified operation type.
  655. OPERATION_TYPE_UNSPECIFIED = 0;
  656. // The source and the destination table have the same table type.
  657. COPY = 1;
  658. // The source table type is TABLE and
  659. // the destination table type is SNAPSHOT.
  660. SNAPSHOT = 2;
  661. // The source table type is SNAPSHOT and
  662. // the destination table type is TABLE.
  663. RESTORE = 3;
  664. }
  665. // State of a job.
  666. enum JobState {
  667. // State unknown.
  668. JOB_STATE_UNSPECIFIED = 0;
  669. // Job is waiting for the resources.
  670. PENDING = 1;
  671. // Job is running.
  672. RUNNING = 2;
  673. // Job is done.
  674. DONE = 3;
  675. }
  676. // Type of the statement (e.g. SELECT, INSERT, CREATE_TABLE, CREATE_MODEL..)
  677. enum QueryStatementType {
  678. // Unknown.
  679. QUERY_STATEMENT_TYPE_UNSPECIFIED = 0;
  680. // SELECT ... FROM &lt;Table list&gt; ...
  681. SELECT = 1;
  682. // ASSERT &lt;condition&gt; AS 'description'
  683. ASSERT = 23;
  684. // INSERT INTO &lt;Table&gt; ....
  685. INSERT = 2;
  686. // UPDATE &lt;Table&gt; SET ...
  687. UPDATE = 3;
  688. // DELETE &lt;Table&gt; ...
  689. DELETE = 4;
  690. // MERGE INTO &lt;Table&gt; ....
  691. MERGE = 5;
  692. // CREATE TABLE &lt;Table&gt; &lt;column list&gt;
  693. CREATE_TABLE = 6;
  694. // CREATE TABLE &lt;Table&gt; AS SELECT
  695. CREATE_TABLE_AS_SELECT = 7;
  696. // CREATE VIEW &lt;View&gt;
  697. CREATE_VIEW = 8;
  698. // CREATE MODEL &lt;Model&gt; AS &lt;Query&gt;
  699. CREATE_MODEL = 9;
  700. // CREATE MATERIALIZED VIEW &lt;View&gt; AS ...
  701. CREATE_MATERIALIZED_VIEW = 13;
  702. // CREATE FUNCTION &lt;Function&gt;(&lt;Signature&gt;) AS ...
  703. CREATE_FUNCTION = 14;
  704. // CREATE TABLE FUNCTION &lt;Function&gt;(&lt;Signature&gt;) AS ...
  705. CREATE_TABLE_FUNCTION = 56;
  706. // CREATE PROCEDURE &lt;Procedure&gt;
  707. CREATE_PROCEDURE = 20;
  708. // CREATE ROW ACCESS POLICY &lt;RowAccessPolicy&gt ON &lt;Table&gt;
  709. CREATE_ROW_ACCESS_POLICY = 24;
  710. // CREATE SCHEMA &lt;Schema&gt;
  711. CREATE_SCHEMA = 53;
  712. // CREATE SNAPSHOT TABLE &lt;Snapshot&gt CLONE &lt;Table&gt;
  713. CREATE_SNAPSHOT_TABLE = 59;
  714. // DROP TABLE &lt;Table&gt;
  715. DROP_TABLE = 10;
  716. // DROP EXTERNAL TABLE &lt;Table&gt;
  717. DROP_EXTERNAL_TABLE = 33;
  718. // DROP VIEW &lt;View&gt;
  719. DROP_VIEW = 11;
  720. // DROP MODEL &lt;Model&gt;
  721. DROP_MODEL = 12;
  722. // DROP MATERIALIZED VIEW &lt;View&gt;
  723. DROP_MATERIALIZED_VIEW = 15;
  724. // DROP FUNCTION &lt;Function&gt;
  725. DROP_FUNCTION = 16;
  726. // DROP PROCEDURE &lt;Procedure&gt;
  727. DROP_PROCEDURE = 21;
  728. // DROP SCHEMA &lt;Schema&gt;
  729. DROP_SCHEMA = 54;
  730. // DROP ROW ACCESS POLICY &lt;RowAccessPolicy&gt ON &lt;Table&gt; <or> DROP
  731. // ALL ROW ACCESS POLICIES ON ON &lt;Table&gt;
  732. DROP_ROW_ACCESS_POLICY = 25;
  733. // DROP SNAPSHOT TABLE &lt;Snapshot&gt;
  734. DROP_SNAPSHOT_TABLE = 62;
  735. // ALTER TABLE &lt;Table&gt;
  736. ALTER_TABLE = 17;
  737. // ALTER VIEW &lt;View&gt;
  738. ALTER_VIEW = 18;
  739. // ALTER MATERIALIZED_VIEW &lt;view&gt;
  740. ALTER_MATERIALIZED_VIEW = 22;
  741. // ALTER SCHEMA &lt;Schema&gt;
  742. ALTER_SCHEMA = 55;
  743. // Script
  744. SCRIPT = 19;
  745. // TRUNCATE TABLE &lt;Table&gt;
  746. TRUNCATE_TABLE = 26;
  747. // CREATE EXTERNAL TABLE &lt;TABLE&gt;
  748. CREATE_EXTERNAL_TABLE = 27;
  749. // EXPORT DATA;
  750. EXPORT_DATA = 28;
  751. // CALL &lt;stored procedure&gt;
  752. CALL = 29;
  753. }
  754. // Status of a job.
  755. message JobStatus {
  756. // State of the job.
  757. JobState job_state = 1;
  758. // Job error, if the job failed.
  759. google.rpc.Status error_result = 2;
  760. // Errors encountered during the running of the job. Does not necessarily
  761. // mean that the job has completed or was unsuccessful.
  762. repeated google.rpc.Status errors = 3;
  763. }
  764. // Job statistics.
  765. message JobStats {
  766. // Query job statistics.
  767. message Query {
  768. // Total bytes processed by the query job.
  769. int64 total_processed_bytes = 1;
  770. // Total bytes billed by the query job.
  771. int64 total_billed_bytes = 2;
  772. // The tier assigned by the CPU-based billing.
  773. int32 billing_tier = 3;
  774. // Tables accessed by the query job.
  775. repeated string referenced_tables = 6;
  776. // Views accessed by the query job.
  777. repeated string referenced_views = 7;
  778. // Routines accessed by the query job.
  779. repeated string referenced_routines = 10;
  780. // Number of output rows produced by the query job.
  781. int64 output_row_count = 8;
  782. // True if the query job results were read from the query cache.
  783. bool cache_hit = 9;
  784. }
  785. // Load job statistics.
  786. message Load {
  787. // Total bytes loaded by the import job.
  788. int64 total_output_bytes = 1;
  789. }
  790. // Extract job statistics.
  791. message Extract {
  792. // Total bytes exported by the extract job.
  793. int64 total_input_bytes = 1;
  794. }
  795. // Job resource usage breakdown by reservation.
  796. message ReservationResourceUsage {
  797. // Reservation name or "unreserved" for on-demand resources usage.
  798. string name = 1;
  799. // Total slot milliseconds used by the reservation for a particular job.
  800. int64 slot_ms = 2;
  801. }
  802. // Job creation time.
  803. google.protobuf.Timestamp create_time = 1;
  804. // Job execution start time.
  805. google.protobuf.Timestamp start_time = 2;
  806. // Job completion time.
  807. google.protobuf.Timestamp end_time = 3;
  808. // Statistics specific to the job type.
  809. oneof extended {
  810. // Query job statistics.
  811. Query query_stats = 8;
  812. // Load job statistics.
  813. Load load_stats = 9;
  814. // Extract job statistics.
  815. Extract extract_stats = 13;
  816. }
  817. // The total number of slot-ms consumed by the query job.
  818. int64 total_slot_ms = 10;
  819. // Reservation usage attributed from each tier of a reservation hierarchy.
  820. repeated ReservationResourceUsage reservation_usage = 11;
  821. // Parent job name. Only present for child jobs.
  822. string parent_job_name = 12;
  823. }
  824. // BigQuery table.
  825. message Table {
  826. // Table URI.
  827. //
  828. // Format: `projects/<project_id>/datasets/<dataset_id>/tables/<table_id>`.
  829. string table_name = 1;
  830. // User-provided metadata for the table.
  831. EntityInfo table_info = 10;
  832. // A JSON representation of the table's schema. Entire field is truncated
  833. // if exceeds 40K.
  834. string schema_json = 3;
  835. // True if the schema_json field was truncated.
  836. bool schema_json_truncated = 11;
  837. // View metadata. Only present for views.
  838. TableViewDefinition view = 4;
  839. // Table expiration time.
  840. google.protobuf.Timestamp expire_time = 5;
  841. // The table creation time.
  842. google.protobuf.Timestamp create_time = 6;
  843. // The last time metadata update time.
  844. google.protobuf.Timestamp update_time = 7;
  845. // The last table truncation time.
  846. google.protobuf.Timestamp truncate_time = 8;
  847. // Table encryption information. Set when non-default encryption is used.
  848. EncryptionInfo encryption = 9;
  849. }
  850. // Trained BigQuery ML model.
  851. message Model {
  852. // Model URI.
  853. //
  854. // Format: `projects/<project_id>/datasets/<dataset_id>/models/<model_id>`.
  855. string model_name = 1;
  856. // User-provided metadata for the model.
  857. EntityInfo model_info = 2;
  858. // Model expiration time.
  859. google.protobuf.Timestamp expire_time = 5;
  860. // Model creation time.
  861. google.protobuf.Timestamp create_time = 6;
  862. // Model last update time.
  863. google.protobuf.Timestamp update_time = 7;
  864. // Model encryption information. Set when non-default encryption is used.
  865. EncryptionInfo encryption = 8;
  866. }
  867. // User Defined Function (UDF) or Stored Procedure.
  868. message Routine {
  869. // Routine URI.
  870. //
  871. // Format:
  872. // `projects/<project_id>/datasets/<dataset_id>/routines/<routine_id>`.
  873. string routine_name = 1;
  874. // Routine creation time.
  875. google.protobuf.Timestamp create_time = 5;
  876. // Routine last update time.
  877. google.protobuf.Timestamp update_time = 6;
  878. }
  879. // User-provided metadata for an entity, for e.g. dataset, table or model.
  880. message EntityInfo {
  881. // A short name for the entity.
  882. string friendly_name = 1;
  883. // A long description for the entity.
  884. string description = 2;
  885. // Labels provided for the entity.
  886. map<string, string> labels = 3;
  887. }
  888. // View definition.
  889. message TableViewDefinition {
  890. // SQL query defining the view. Truncated if exceeds 40K.
  891. string query = 1;
  892. // True if the schema_json field was truncated.
  893. bool query_truncated = 2;
  894. }
  895. // BigQuery dataset.
  896. message Dataset {
  897. // Dataset URI.
  898. //
  899. // Format: `projects/<project_id>/datasets/<dataset_id>`.
  900. string dataset_name = 1;
  901. // User-provided metadata for the dataset.
  902. EntityInfo dataset_info = 7;
  903. // Dataset creation time.
  904. google.protobuf.Timestamp create_time = 3;
  905. // Dataset metadata last update time.
  906. google.protobuf.Timestamp update_time = 4;
  907. // The access control list for the dataset.
  908. BigQueryAcl acl = 5;
  909. // Default expiration time for tables in the dataset.
  910. google.protobuf.Duration default_table_expire_duration = 6;
  911. // Default encryption for tables in the dataset.
  912. EncryptionInfo default_encryption = 8;
  913. // Default collation for the dataset.
  914. string default_collation = 9;
  915. }
  916. // An access control list.
  917. message BigQueryAcl {
  918. // IAM policy for the resource.
  919. google.iam.v1.Policy policy = 1;
  920. // List of authorized views for a dataset.
  921. //
  922. // Format: `projects/<project_id>/datasets/<dataset_id>/tables/<view_id>`.
  923. repeated string authorized_views = 2;
  924. }
  925. // Encryption properties for a table or a job
  926. message EncryptionInfo {
  927. // Cloud kms key identifier.
  928. //
  929. // Format:
  930. // `projects/<project_id>/locations/<location>/keyRings/<key_ring_name>/cryptoKeys/<key_name>`
  931. string kms_key_name = 1;
  932. }
  933. // BigQuery row access policy.
  934. message RowAccessPolicy {
  935. // Row access policy URI.
  936. //
  937. // Format:
  938. // `projects/<project_id>/datasets/<dataset_id>/tables/<table_id>/rowAccessPolicies/<row_access_policy_id>`
  939. string row_access_policy_name = 1;
  940. }
  941. // First party (Google) application specific request metadata.
  942. message FirstPartyAppMetadata {
  943. oneof metadata {
  944. // Google Sheets metadata.
  945. SheetsMetadata sheets_metadata = 1;
  946. }
  947. }
  948. // Google Sheets specific request metadata.
  949. message SheetsMetadata {
  950. // The ID of the spreadsheet from which the request is sent.
  951. string doc_id = 1;
  952. }
  953. // BigQuery event information.
  954. oneof event {
  955. // Job insertion event.
  956. JobInsertion job_insertion = 1;
  957. // Job state change event.
  958. JobChange job_change = 2;
  959. // Job deletion event.
  960. JobDeletion job_deletion = 23;
  961. // Dataset creation event.
  962. DatasetCreation dataset_creation = 3;
  963. // Dataset change event.
  964. DatasetChange dataset_change = 4;
  965. // Dataset deletion event.
  966. DatasetDeletion dataset_deletion = 5;
  967. // Table creation event.
  968. TableCreation table_creation = 6;
  969. // Table metadata change event.
  970. TableChange table_change = 8;
  971. // Table deletion event.
  972. TableDeletion table_deletion = 9;
  973. // Table data read event.
  974. TableDataRead table_data_read = 10;
  975. // Table data change event.
  976. TableDataChange table_data_change = 11;
  977. // Model deletion event.
  978. ModelDeletion model_deletion = 12;
  979. // Model creation event.
  980. ModelCreation model_creation = 13;
  981. // Model metadata change event.
  982. ModelMetadataChange model_metadata_change = 14;
  983. // Model data change event.
  984. ModelDataChange model_data_change = 15;
  985. // Model data read event.
  986. ModelDataRead model_data_read = 19;
  987. // Routine creation event.
  988. RoutineCreation routine_creation = 16;
  989. // Routine change event.
  990. RoutineChange routine_change = 17;
  991. // Routine deletion event.
  992. RoutineDeletion routine_deletion = 18;
  993. // Row access policy create event.
  994. RowAccessPolicyCreation row_access_policy_creation = 20;
  995. // Row access policy change event.
  996. RowAccessPolicyChange row_access_policy_change = 21;
  997. // Row access policy deletion event.
  998. RowAccessPolicyDeletion row_access_policy_deletion = 22;
  999. // Unlink linked dataset from its source dataset event
  1000. UnlinkDataset unlink_dataset = 25;
  1001. }
  1002. // First party (Google) application specific metadata.
  1003. FirstPartyAppMetadata first_party_app_metadata = 24;
  1004. }