Skip to content

Commit 3dee5b5

Browse files
authored
Add protos as an artifact to library (#7205)
1 parent f14d539 commit 3dee5b5

File tree

13 files changed

+3373
-5
lines changed

13 files changed

+3373
-5
lines changed
Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
// Copyright 2018 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+
15+
syntax = "proto3";
16+
17+
package google.spanner.admin.database.v1;
18+
19+
import "google/api/annotations.proto";
20+
import "google/iam/v1/iam_policy.proto";
21+
import "google/iam/v1/policy.proto";
22+
import "google/longrunning/operations.proto";
23+
import "google/protobuf/empty.proto";
24+
import "google/protobuf/timestamp.proto";
25+
26+
option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
27+
option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
28+
option java_multiple_files = true;
29+
option java_outer_classname = "SpannerDatabaseAdminProto";
30+
option java_package = "com.google.spanner.admin.database.v1";
31+
option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1";
32+
33+
34+
// Cloud Spanner Database Admin API
35+
//
36+
// The Cloud Spanner Database Admin API can be used to create, drop, and
37+
// list databases. It also enables updating the schema of pre-existing
38+
// databases.
39+
service DatabaseAdmin {
40+
// Lists Cloud Spanner databases.
41+
rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse) {
42+
option (google.api.http) = {
43+
get: "/v1/{parent=projects/*/instances/*}/databases"
44+
};
45+
}
46+
47+
// Creates a new Cloud Spanner database and starts to prepare it for serving.
48+
// The returned [long-running operation][google.longrunning.Operation] will
49+
// have a name of the format `<database_name>/operations/<operation_id>` and
50+
// can be used to track preparation of the database. The
51+
// [metadata][google.longrunning.Operation.metadata] field type is
52+
// [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The
53+
// [response][google.longrunning.Operation.response] field type is
54+
// [Database][google.spanner.admin.database.v1.Database], if successful.
55+
rpc CreateDatabase(CreateDatabaseRequest) returns (google.longrunning.Operation) {
56+
option (google.api.http) = {
57+
post: "/v1/{parent=projects/*/instances/*}/databases"
58+
body: "*"
59+
};
60+
}
61+
62+
// Gets the state of a Cloud Spanner database.
63+
rpc GetDatabase(GetDatabaseRequest) returns (Database) {
64+
option (google.api.http) = {
65+
get: "/v1/{name=projects/*/instances/*/databases/*}"
66+
};
67+
}
68+
69+
// Updates the schema of a Cloud Spanner database by
70+
// creating/altering/dropping tables, columns, indexes, etc. The returned
71+
// [long-running operation][google.longrunning.Operation] will have a name of
72+
// the format `<database_name>/operations/<operation_id>` and can be used to
73+
// track execution of the schema change(s). The
74+
// [metadata][google.longrunning.Operation.metadata] field type is
75+
// [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response.
76+
rpc UpdateDatabaseDdl(UpdateDatabaseDdlRequest) returns (google.longrunning.Operation) {
77+
option (google.api.http) = {
78+
patch: "/v1/{database=projects/*/instances/*/databases/*}/ddl"
79+
body: "*"
80+
};
81+
}
82+
83+
// Drops (aka deletes) a Cloud Spanner database.
84+
rpc DropDatabase(DropDatabaseRequest) returns (google.protobuf.Empty) {
85+
option (google.api.http) = {
86+
delete: "/v1/{database=projects/*/instances/*/databases/*}"
87+
};
88+
}
89+
90+
// Returns the schema of a Cloud Spanner database as a list of formatted
91+
// DDL statements. This method does not show pending schema updates, those may
92+
// be queried using the [Operations][google.longrunning.Operations] API.
93+
rpc GetDatabaseDdl(GetDatabaseDdlRequest) returns (GetDatabaseDdlResponse) {
94+
option (google.api.http) = {
95+
get: "/v1/{database=projects/*/instances/*/databases/*}/ddl"
96+
};
97+
}
98+
99+
// Sets the access control policy on a database resource. Replaces any
100+
// existing policy.
101+
//
102+
// Authorization requires `spanner.databases.setIamPolicy` permission on
103+
// [resource][google.iam.v1.SetIamPolicyRequest.resource].
104+
rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) {
105+
option (google.api.http) = {
106+
post: "/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy"
107+
body: "*"
108+
};
109+
}
110+
111+
// Gets the access control policy for a database resource. Returns an empty
112+
// policy if a database exists but does not have a policy set.
113+
//
114+
// Authorization requires `spanner.databases.getIamPolicy` permission on
115+
// [resource][google.iam.v1.GetIamPolicyRequest.resource].
116+
rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) {
117+
option (google.api.http) = {
118+
post: "/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy"
119+
body: "*"
120+
};
121+
}
122+
123+
// Returns permissions that the caller has on the specified database resource.
124+
//
125+
// Attempting this RPC on a non-existent Cloud Spanner database will result in
126+
// a NOT_FOUND error if the user has `spanner.databases.list` permission on
127+
// the containing Cloud Spanner instance. Otherwise returns an empty set of
128+
// permissions.
129+
rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) {
130+
option (google.api.http) = {
131+
post: "/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions"
132+
body: "*"
133+
};
134+
}
135+
}
136+
137+
// A Cloud Spanner database.
138+
message Database {
139+
// Indicates the current state of the database.
140+
enum State {
141+
// Not specified.
142+
STATE_UNSPECIFIED = 0;
143+
144+
// The database is still being created. Operations on the database may fail
145+
// with `FAILED_PRECONDITION` in this state.
146+
CREATING = 1;
147+
148+
// The database is fully created and ready for use.
149+
READY = 2;
150+
}
151+
152+
// Required. The name of the database. Values are of the form
153+
// `projects/<project>/instances/<instance>/databases/<database>`,
154+
// where `<database>` is as specified in the `CREATE DATABASE`
155+
// statement. This name can be passed to other API methods to
156+
// identify the database.
157+
string name = 1;
158+
159+
// Output only. The current database state.
160+
State state = 2;
161+
}
162+
163+
// The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
164+
message ListDatabasesRequest {
165+
// Required. The instance whose databases should be listed.
166+
// Values are of the form `projects/<project>/instances/<instance>`.
167+
string parent = 1;
168+
169+
// Number of databases to be returned in the response. If 0 or less,
170+
// defaults to the server's maximum allowed page size.
171+
int32 page_size = 3;
172+
173+
// If non-empty, `page_token` should contain a
174+
// [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] from a
175+
// previous [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse].
176+
string page_token = 4;
177+
}
178+
179+
// The response for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
180+
message ListDatabasesResponse {
181+
// Databases that matched the request.
182+
repeated Database databases = 1;
183+
184+
// `next_page_token` can be sent in a subsequent
185+
// [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] call to fetch more
186+
// of the matching databases.
187+
string next_page_token = 2;
188+
}
189+
190+
// The request for [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
191+
message CreateDatabaseRequest {
192+
// Required. The name of the instance that will serve the new database.
193+
// Values are of the form `projects/<project>/instances/<instance>`.
194+
string parent = 1;
195+
196+
// Required. A `CREATE DATABASE` statement, which specifies the ID of the
197+
// new database. The database ID must conform to the regular expression
198+
// `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length.
199+
// If the database ID is a reserved word or if it contains a hyphen, the
200+
// database ID must be enclosed in backticks (`` ` ``).
201+
string create_statement = 2;
202+
203+
// An optional list of DDL statements to run inside the newly created
204+
// database. Statements can create tables, indexes, etc. These
205+
// statements execute atomically with the creation of the database:
206+
// if there is an error in any statement, the database is not created.
207+
repeated string extra_statements = 3;
208+
}
209+
210+
// Metadata type for the operation returned by
211+
// [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
212+
message CreateDatabaseMetadata {
213+
// The database being created.
214+
string database = 1;
215+
}
216+
217+
// The request for [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase].
218+
message GetDatabaseRequest {
219+
// Required. The name of the requested database. Values are of the form
220+
// `projects/<project>/instances/<instance>/databases/<database>`.
221+
string name = 1;
222+
}
223+
224+
// Enqueues the given DDL statements to be applied, in order but not
225+
// necessarily all at once, to the database schema at some point (or
226+
// points) in the future. The server checks that the statements
227+
// are executable (syntactically valid, name tables that exist, etc.)
228+
// before enqueueing them, but they may still fail upon
229+
// later execution (e.g., if a statement from another batch of
230+
// statements is applied first and it conflicts in some way, or if
231+
// there is some data-related problem like a `NULL` value in a column to
232+
// which `NOT NULL` would be added). If a statement fails, all
233+
// subsequent statements in the batch are automatically cancelled.
234+
//
235+
// Each batch of statements is assigned a name which can be used with
236+
// the [Operations][google.longrunning.Operations] API to monitor
237+
// progress. See the
238+
// [operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id] field for more
239+
// details.
240+
message UpdateDatabaseDdlRequest {
241+
// Required. The database to update.
242+
string database = 1;
243+
244+
// DDL statements to be applied to the database.
245+
repeated string statements = 2;
246+
247+
// If empty, the new update request is assigned an
248+
// automatically-generated operation ID. Otherwise, `operation_id`
249+
// is used to construct the name of the resulting
250+
// [Operation][google.longrunning.Operation].
251+
//
252+
// Specifying an explicit operation ID simplifies determining
253+
// whether the statements were executed in the event that the
254+
// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] call is replayed,
255+
// or the return value is otherwise lost: the [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.database] and
256+
// `operation_id` fields can be combined to form the
257+
// [name][google.longrunning.Operation.name] of the resulting
258+
// [longrunning.Operation][google.longrunning.Operation]: `<database>/operations/<operation_id>`.
259+
//
260+
// `operation_id` should be unique within the database, and must be
261+
// a valid identifier: `[a-z][a-z0-9_]*`. Note that
262+
// automatically-generated operation IDs always begin with an
263+
// underscore. If the named operation already exists,
264+
// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns
265+
// `ALREADY_EXISTS`.
266+
string operation_id = 3;
267+
}
268+
269+
// Metadata type for the operation returned by
270+
// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl].
271+
message UpdateDatabaseDdlMetadata {
272+
// The database being modified.
273+
string database = 1;
274+
275+
// For an update this list contains all the statements. For an
276+
// individual statement, this list contains only that statement.
277+
repeated string statements = 2;
278+
279+
// Reports the commit timestamps of all statements that have
280+
// succeeded so far, where `commit_timestamps[i]` is the commit
281+
// timestamp for the statement `statements[i]`.
282+
repeated google.protobuf.Timestamp commit_timestamps = 3;
283+
}
284+
285+
// The request for [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase].
286+
message DropDatabaseRequest {
287+
// Required. The database to be dropped.
288+
string database = 1;
289+
}
290+
291+
// The request for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
292+
message GetDatabaseDdlRequest {
293+
// Required. The database whose schema we wish to get.
294+
string database = 1;
295+
}
296+
297+
// The response for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
298+
message GetDatabaseDdlResponse {
299+
// A list of formatted DDL statements defining the schema of the database
300+
// specified in the request.
301+
repeated string statements = 1;
302+
}

0 commit comments

Comments
 (0)