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