Skip to content

Commit 48c3f2f

Browse files
Google APIscopybara-github
authored andcommitted
feat: add CRUD APIs on Databases
feat: add PG 17 as a Database version chore: annotate `EncryptionConfig.kms_key_name`, `SecondaryConfig.primary_cluster_name`, `PrimaryConfig.secondary_cluster_names`, and `PscInstanceConfig.service_attachment_link` with what resource they're referencing feat: add configuration for Managed Connection Pool feat: update `Database.charset` to be immutable feat: add additional fields to Database object to specify the collation type, character type, if it is a template database, and the template to use for the database feat: add field to ExecuteSQL request to just validate the sql statement feat: add fields on the estimated/actual start/end times for an Upgrade Cluster operation docs: specify that the STOPPED state is not used for clusters anymore fix!: An existing enum `PoolMode` is removed from the `ConnectionPoolConfig` PiperOrigin-RevId: 811874403
1 parent fc225fe commit 48c3f2f

File tree

3 files changed

+132
-37
lines changed

3 files changed

+132
-37
lines changed

google/cloud/alloydb/v1beta/alloydb_v1beta_grpc_service_config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
{ "service": "google.cloud.alloydb.v1beta.AlloyDBAdmin", "method": "GetConnectionInfo" },
1313
{ "service": "google.cloud.alloydb.v1beta.AlloyDBAdmin", "method": "ListUsers" },
1414
{ "service": "google.cloud.alloydb.v1beta.AlloyDBAdmin", "method": "GetUser" },
15-
{ "service": "google.cloud.alloydb.v1beta.AlloyDBAdmin", "method": "ListDatabases" }
15+
{ "service": "google.cloud.alloydb.v1beta.AlloyDBAdmin", "method": "ListDatabases" },
16+
{ "service": "google.cloud.alloydb.v1beta.AlloyDBAdmin", "method": "CreateDatabase" },
17+
{ "service": "google.cloud.alloydb.v1beta.AlloyDBAdmin", "method": "GetDatabase" },
18+
{ "service": "google.cloud.alloydb.v1beta.AlloyDBAdmin", "method": "UpdateDatabase" },
19+
{ "service": "google.cloud.alloydb.v1beta.AlloyDBAdmin", "method": "DeleteDatabase" }
1620
],
1721
"timeout": "60s",
1822
"retryPolicy": {

google/cloud/alloydb/v1beta/resources.proto

Lines changed: 74 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ option (google.api.resource_definition) = {
4343
type: "compute.googleapis.com/Network"
4444
pattern: "projects/{project}/global/networks/{network}"
4545
};
46+
option (google.api.resource_definition) = {
47+
type: "cloudkms.googleapis.com/CryptoKey"
48+
pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}"
49+
};
50+
option (google.api.resource_definition) = {
51+
type: "compute.googleapis.com/ServiceAttachment"
52+
pattern: "projects/{project}/regions/{region}/serviceAttachments/{service_attachment}"
53+
};
4654

4755
// View on Instance. Pass this enum to rpcs that returns an Instance message to
4856
// control which subsets of fields to get.
@@ -93,6 +101,9 @@ enum DatabaseVersion {
93101

94102
// The database version is Postgres 16.
95103
POSTGRES_16 = 4;
104+
105+
// The database version is Postgres 17.
106+
POSTGRES_17 = 5;
96107
}
97108

98109
// Subscription_type added to distinguish between Standard and Trial
@@ -151,7 +162,9 @@ message EncryptionConfig {
151162
// The fully-qualified resource name of the KMS key.
152163
// Each Cloud KMS key is regionalized and has the following format:
153164
// projects/[PROJECT]/locations/[REGION]/keyRings/[RING]/cryptoKeys/[KEY_NAME]
154-
string kms_key_name = 1;
165+
string kms_key_name = 1 [(google.api.resource_reference) = {
166+
type: "cloudkms.googleapis.com/CryptoKey"
167+
}];
155168
}
156169

157170
// EncryptionInfo describes the encryption information of a cluster or a backup.
@@ -496,7 +509,9 @@ message Cluster {
496509
message SecondaryConfig {
497510
// The name of the primary cluster name with the format:
498511
// * projects/{project}/locations/{region}/clusters/{cluster_id}
499-
string primary_cluster_name = 1;
512+
string primary_cluster_name = 1 [(google.api.resource_reference) = {
513+
type: "alloydb.googleapis.com/Cluster"
514+
}];
500515
}
501516

502517
// Configuration for the primary cluster. It has the list of clusters that are
@@ -505,8 +520,12 @@ message Cluster {
505520
message PrimaryConfig {
506521
// Output only. Names of the clusters that are replicating from this
507522
// cluster.
508-
repeated string secondary_cluster_names = 1
509-
[(google.api.field_behavior) = OUTPUT_ONLY];
523+
repeated string secondary_cluster_names = 1 [
524+
(google.api.field_behavior) = OUTPUT_ONLY,
525+
(google.api.resource_reference) = {
526+
type: "alloydb.googleapis.com/Cluster"
527+
}
528+
];
510529
}
511530

512531
// PscConfig contains PSC related configuration at a cluster level.
@@ -544,11 +563,8 @@ message Cluster {
544563
// The cluster is active and running.
545564
READY = 1;
546565

547-
// The cluster is stopped. All instances in the cluster are stopped.
548-
// Customers can start a stopped cluster at any point and all their
549-
// instances will come back to life with same names and IP resources. In
550-
// this state, customer pays for storage.
551-
// Associated backups could also be present in a stopped cluster.
566+
// This is unused. Even when all instances in the cluster are stopped, the
567+
// cluster remains in READY state.
552568
STOPPED = 2;
553569

554570
// The cluster is empty and has no associated resources.
@@ -761,10 +777,10 @@ message Cluster {
761777
(google.api.field_behavior) = OPTIONAL
762778
];
763779

764-
// Output only. AlloyDB per-cluster service agent email. This service account
765-
// is created per-cluster per-project, and is different from that of the
766-
// primary service agent which is created per-project. The service account
767-
// naming format is subject to change.
780+
// Output only. AlloyDB per-cluster service account. This service account is
781+
// created per-cluster per-project, and is different from the per-project
782+
// service account. The per-cluster service account naming format is subject
783+
// to change.
768784
string service_account_email = 46 [(google.api.field_behavior) = OUTPUT_ONLY];
769785
}
770786

@@ -980,8 +996,12 @@ message Instance {
980996
// Service Connect (PSC) is enabled for the instance.
981997
// The name of the resource will be in the format of
982998
// `projects/<alloydb-tenant-project-number>/regions/<region-name>/serviceAttachments/<service-attachment-name>`
983-
string service_attachment_link = 1
984-
[(google.api.field_behavior) = OUTPUT_ONLY];
999+
string service_attachment_link = 1 [
1000+
(google.api.field_behavior) = OUTPUT_ONLY,
1001+
(google.api.resource_reference) = {
1002+
type: "compute.googleapis.com/ServiceAttachment"
1003+
}
1004+
];
9851005

9861006
// Optional. List of consumer projects that are allowed to create
9871007
// PSC endpoints to service-attachments to this instance.
@@ -1048,23 +1068,14 @@ message Instance {
10481068

10491069
// Configuration for Managed Connection Pool (MCP).
10501070
message ConnectionPoolConfig {
1051-
// The pool mode. Defaults to `POOL_MODE_TRANSACTION`.
1052-
enum PoolMode {
1053-
// The pool mode is not specified. Defaults to `POOL_MODE_TRANSACTION`.
1054-
POOL_MODE_UNSPECIFIED = 0;
1055-
1056-
// Server is released back to pool after a client disconnects.
1057-
POOL_MODE_SESSION = 1;
1058-
1059-
// Server is released back to pool after a transaction finishes.
1060-
POOL_MODE_TRANSACTION = 2;
1061-
}
1062-
10631071
// Optional. Whether to enable Managed Connection Pool (MCP).
10641072
bool enabled = 12 [(google.api.field_behavior) = OPTIONAL];
10651073

10661074
// Optional. Connection Pool flags, as a list of "key": "value" pairs.
10671075
map<string, string> flags = 13 [(google.api.field_behavior) = OPTIONAL];
1076+
1077+
// Output only. The number of running poolers per instance.
1078+
int32 pooler_count = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
10681079
}
10691080

10701081
// Instance State
@@ -1719,13 +1730,43 @@ message Database {
17191730
// `projects/{project}/locations/{location}/clusters/{cluster}/databases/{database}`.
17201731
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
17211732

1722-
// Optional. Charset for the database.
1733+
// Optional. Immutable. Charset for the database.
17231734
// This field can contain any PostgreSQL supported charset name.
17241735
// Example values include "UTF8", "SQL_ASCII", etc.
1725-
string charset = 2 [(google.api.field_behavior) = OPTIONAL];
1736+
string charset = 2 [
1737+
(google.api.field_behavior) = OPTIONAL,
1738+
(google.api.field_behavior) = IMMUTABLE
1739+
];
1740+
1741+
// Optional. Immutable. lc_collate for the database.
1742+
// String sort order.
1743+
// Example values include "C", "POSIX", etc.
1744+
string collation = 3 [
1745+
(google.api.field_behavior) = OPTIONAL,
1746+
(google.api.field_behavior) = IMMUTABLE
1747+
];
17261748

1727-
// Optional. Collation for the database.
1728-
// Name of the custom or native collation for postgres.
1729-
// Example values include "C", "POSIX", etc
1730-
string collation = 3 [(google.api.field_behavior) = OPTIONAL];
1749+
// Optional. Immutable. lc_ctype for the database.
1750+
// Character classification (What is a letter? The upper-case equivalent?).
1751+
// Example values include "C", "POSIX", etc.
1752+
string character_type = 4 [
1753+
(google.api.field_behavior) = OPTIONAL,
1754+
(google.api.field_behavior) = IMMUTABLE
1755+
];
1756+
1757+
// Optional. Whether the database is a template database.
1758+
// Deprecated in favor of is_template_database.
1759+
bool is_template = 5
1760+
[deprecated = true, (google.api.field_behavior) = OPTIONAL];
1761+
1762+
// Input only. Immutable. Template of the database to be used for creating a
1763+
// new database.
1764+
string database_template = 6 [
1765+
(google.api.field_behavior) = INPUT_ONLY,
1766+
(google.api.field_behavior) = IMMUTABLE
1767+
];
1768+
1769+
// Optional. Whether the database is a template database.
1770+
optional bool is_template_database = 7
1771+
[(google.api.field_behavior) = OPTIONAL];
17311772
}

google/cloud/alloydb/v1beta/service.proto

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ service AlloyDBAdmin {
492492
};
493493
option (google.api.method_signature) = "parent";
494494
}
495+
496+
// Creates a new Database in a given project, location, and cluster.
497+
rpc CreateDatabase(CreateDatabaseRequest) returns (Database) {
498+
option (google.api.http) = {
499+
post: "/v1beta/{parent=projects/*/locations/*/clusters/*}/databases"
500+
body: "database"
501+
};
502+
option (google.api.method_signature) = "parent,database,database_id";
503+
}
495504
}
496505

497506
// Message for requesting list of Clusters
@@ -1606,6 +1615,10 @@ message ExecuteSqlRequest {
16061615
// Required. SQL statement to execute on database. Any valid statement is
16071616
// permitted, including DDL, DML, DQL statements.
16081617
string sql_statement = 4 [(google.api.field_behavior) = REQUIRED];
1618+
1619+
// Optional. If set, validates the sql statement by performing
1620+
// syntax and semantic validation and doesn't execute the query.
1621+
bool validate_only = 6 [(google.api.field_behavior) = OPTIONAL];
16091622
}
16101623

16111624
// Execute a SQL statement response.
@@ -2021,6 +2034,23 @@ message PromoteClusterStatus {
20212034
message UpgradeClusterStatus {
20222035
// Status of an upgrade stage.
20232036
message StageStatus {
2037+
// Timing information for the stage execution.
2038+
message StageSchedule {
2039+
// When the stage is expected to start. Set only if the stage has not
2040+
// started yet.
2041+
google.protobuf.Timestamp estimated_start_time = 1;
2042+
2043+
// Actual start time of the stage. Set only if the stage has started.
2044+
google.protobuf.Timestamp actual_start_time = 2;
2045+
2046+
// When the stage is expected to end. Set only if the stage has not
2047+
// completed yet.
2048+
google.protobuf.Timestamp estimated_end_time = 3;
2049+
2050+
// Actual end time of the stage. Set only if the stage has completed.
2051+
google.protobuf.Timestamp actual_end_time = 4;
2052+
}
2053+
20242054
// Stage specific status information, if any.
20252055
oneof stage_specific_status {
20262056
// Read pool instances upgrade metadata.
@@ -2032,6 +2062,9 @@ message UpgradeClusterStatus {
20322062

20332063
// State of this stage.
20342064
UpgradeClusterResponse.Status state = 2;
2065+
2066+
// Output only. Timing information for the stage execution.
2067+
StageSchedule schedule = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
20352068
}
20362069

20372070
// Read pool instances upgrade specific status.
@@ -2218,7 +2251,7 @@ message DeleteUserRequest {
22182251
bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL];
22192252
}
22202253

2221-
// Message for requesting list of Databases.
2254+
// Message for ListDatabases request.
22222255
message ListDatabasesRequest {
22232256
// Required. Parent value for ListDatabasesRequest.
22242257
string parent = 1 [
@@ -2244,12 +2277,29 @@ message ListDatabasesRequest {
22442277
string filter = 4 [(google.api.field_behavior) = OPTIONAL];
22452278
}
22462279

2247-
// Message for response to listing Databases.
2280+
// Message for ListDatabases response.
22482281
message ListDatabasesResponse {
2249-
// The list of databases
2282+
// The list of databases.
22502283
repeated Database databases = 1;
22512284

22522285
// A token identifying the next page of results the server should return.
22532286
// If this field is omitted, there are no subsequent pages.
22542287
string next_page_token = 2;
22552288
}
2289+
2290+
// Message for CreateDatabase request.
2291+
message CreateDatabaseRequest {
2292+
// Required. Value for parent.
2293+
string parent = 1 [
2294+
(google.api.field_behavior) = REQUIRED,
2295+
(google.api.resource_reference) = {
2296+
child_type: "alloydb.googleapis.com/Database"
2297+
}
2298+
];
2299+
2300+
// Required. ID of the requesting object.
2301+
string database_id = 2 [(google.api.field_behavior) = REQUIRED];
2302+
2303+
// Required. The resource being created.
2304+
Database database = 3 [(google.api.field_behavior) = REQUIRED];
2305+
}

0 commit comments

Comments
 (0)