fix: add resource definition for Table/ReadStream/WriteStream message

fix: add proper resource_reference for messages
chore: enable gapic v2 and proto annotation for bigquery/storage/v1alpha2 API.
committer: @xiaozhenliu-gg5

PiperOrigin-RevId: 310224144
This commit is contained in:
Google APIs 2020-05-06 14:09:13 -07:00 committed by Copybara-Service
parent 839fae4233
commit 30cfca0943
7 changed files with 84 additions and 23 deletions

View File

@ -22,6 +22,7 @@ proto_library(
"//google/api:client_proto",
"//google/api:field_behavior_proto",
"//google/rpc:status_proto",
"//google/api:resource_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:timestamp_proto",
@ -163,6 +164,7 @@ moved_proto_library(
"//google/api:client_proto",
"//google/api:field_behavior_proto",
"//google/rpc:status_proto",
"//google/api:resource_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:timestamp_proto",

View File

@ -0,0 +1,18 @@
type: com.google.api.codegen.ConfigProto
config_schema_version: 1.0.0
# The settings of generated code in a specific language.
language_settings:
java:
package_name: com.google.cloud.bigquery.storage.v1alpha2
python:
package_name: google.cloud.bigquery.storage_v1alpha2.gapic
go:
package_name: cloud.google.com/go/bigquery/storage/apiv1alpha2
csharp:
package_name: Google.Cloud.Bigquery.Storage.V1alpha2
ruby:
package_name: Google::Cloud::Bigquery::Storage::V1alpha2
php:
package_name: Google\Cloud\Bigquery\Storage\V1alpha2
nodejs:
package_name: storage.v1alpha2

View File

@ -1,5 +1,5 @@
type: com.google.api.codegen.ConfigProto
config_schema_version: 1.0.0
config_schema_version: 2.0.0
# The settings of generated code in a specific language.
language_settings:
java:

View File

@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -11,7 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
syntax = "proto3";
@ -25,9 +24,8 @@ option java_package = "com.google.cloud.bigquery.storage.v1alpha2";
// Protobuf schema is an API presentation the proto buffer schema.
message ProtoSchema {
// Message descriptor for the data. The descriptor has to be self contained
// to include all the nested type definition, excepted for proto buffer well
// known types
// Descriptor for input message. The descriptor has to be self contained,
// including all the nested types, excepted for proto buffer well known types
// (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf)
// and zetasql public protos
// (https://github.com/google/zetasql/tree/master/zetasql/public/proto).

View File

@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -11,7 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
syntax = "proto3";
@ -20,8 +19,10 @@ package google.cloud.bigquery.storage.v1alpha2;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/bigquery/storage/v1alpha2/protobuf.proto";
import "google/cloud/bigquery/storage/v1alpha2/stream.proto";
import "google/cloud/bigquery/storage/v1alpha2/table.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
@ -33,8 +34,13 @@ option java_package = "com.google.cloud.bigquery.storage.v1alpha2";
// Request message for `CreateWriteStream`.
message CreateWriteStreamRequest {
// Required. Reference to the table to which the stream belongs, in the format
// of `projects/{project_id}/datasets/{dataset_id}/tables/{table_id}`.
string parent = 1 [(google.api.field_behavior) = REQUIRED];
// of `projects/{project}/datasets/{dataset}/tables/{table}`.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "bigquerystorage.googleapis.com/Table"
}
];
// Required. Stream to be created.
WriteStream write_stream = 2 [(google.api.field_behavior) = REQUIRED];
@ -53,7 +59,12 @@ message AppendRowsRequest {
// Required. The stream that is the target of the append operation. This value must be
// specified for the initial request. If subsequent requests specify the
// stream name, it must equal to the value provided in the first request.
string write_stream = 1 [(google.api.field_behavior) = REQUIRED];
string write_stream = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "bigquerystorage.googleapis.com/WriteStream"
}
];
// Optional. If present, the write is only performed if the next append offset is same
// as the provided value. If not present, the write is performed at the
@ -84,15 +95,25 @@ message AppendRowsResponse {
// Request message for `GetWriteStreamRequest`.
message GetWriteStreamRequest {
// Required. Name of the stream to get, in the form of
// `projects/{project_id}/datasets/{dataset_id}/tables/{table_id}/streams/{stream_id}`.
string name = 1 [(google.api.field_behavior) = REQUIRED];
// `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "bigquerystorage.googleapis.com/WriteStream"
}
];
}
// Request message for `BatchCommitWriteStreams`.
message BatchCommitWriteStreamsRequest {
// Required. Parent table that all the streams should belong to, in the form of
// `projects/{project_id}/datasets/{dataset_id}/tables/{table_id}`.
string parent = 1 [(google.api.field_behavior) = REQUIRED];
// `projects/{project}/datasets/{dataset}/tables/{table}`.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "bigquerystorage.googleapis.com/Table"
}
];
// Required. The group of streams that will be committed atomically.
repeated string write_streams = 2 [(google.api.field_behavior) = REQUIRED];
@ -107,8 +128,13 @@ message BatchCommitWriteStreamsResponse {
// Request message for invoking `FinalizeWriteStream`.
message FinalizeWriteStreamRequest {
// Required. Name of the stream to finalize, in the form of
// `projects/{project_id}/datasets/{dataset_id}/tables/{table_id}/streams/{stream_id}`.
string name = 1 [(google.api.field_behavior) = REQUIRED];
// `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "bigquerystorage.googleapis.com/WriteStream"
}
];
}
// Response message for `FinalizeWriteStream`.
@ -131,8 +157,9 @@ service BigQueryWrite {
rpc CreateWriteStream(CreateWriteStreamRequest) returns (WriteStream) {
option (google.api.http) = {
post: "/v1alpha2/{parent=projects/*/datasets/*/tables/*}"
body: "*"
body: "write_stream"
};
option (google.api.method_signature) = "parent,write_stream";
}
// Appends data to the given stream.
@ -159,6 +186,7 @@ service BigQueryWrite {
post: "/v1alpha2/{write_stream=projects/*/datasets/*/tables/*/streams/*}"
body: "*"
};
option (google.api.method_signature) = "write_stream";
}
// Gets a write stream.
@ -167,6 +195,7 @@ service BigQueryWrite {
post: "/v1alpha2/{name=projects/*/datasets/*/tables/*/streams/*}"
body: "*"
};
option (google.api.method_signature) = "name";
}
// Finalize a write stream so that no new data can be appended to the
@ -176,6 +205,7 @@ service BigQueryWrite {
post: "/v1alpha2/{name=projects/*/datasets/*/tables/*/streams/*}"
body: "*"
};
option (google.api.method_signature) = "name";
}
// Atomically commits a group of `PENDING` streams that belong to the same
@ -187,5 +217,7 @@ service BigQueryWrite {
option (google.api.http) = {
get: "/v1alpha2/{parent=projects/*/datasets/*/tables/*}"
};
option (google.api.method_signature) = "parent";
}
}

View File

@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -11,21 +11,30 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
syntax = "proto3";
package google.cloud.bigquery.storage.v1alpha2;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/bigquery/storage/v1alpha2/table.proto";
import "google/protobuf/timestamp.proto";
option go_package = "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1alpha2;storage";
option java_package = "com.google.cloud.bigquery.storage.v1alpha2";
option (google.api.resource_definition) = {
type: "bigquerystorage.googleapis.com/Table"
pattern: "projects/{project}/datasets/{dataset}/tables/{table}"
};
// Information about a single stream that gets data inside the storage system.
message WriteStream {
option (google.api.resource) = {
type: "bigquerystorage.googleapis.com/WriteStream"
pattern: "projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}"
};
enum Type {
// Unknown type.
TYPE_UNSPECIFIED = 0;
@ -36,10 +45,13 @@ message WriteStream {
// Data is invisible until the stream is committed.
PENDING = 2;
// Data is only visible up to the offset to which it was flushed.
BUFFERED = 3;
}
// Output only. Name of the stream, in the form
// `projects/{project_id}/datasets/{dataset_id}/tables/{table_id}/streams/{stream_id}`.
// `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
Type type = 2 [(google.api.field_behavior) = IMMUTABLE];

View File

@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -11,7 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
syntax = "proto3";