Skip to content

Commit 8cd7806

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: 811874519
1 parent 48c3f2f commit 8cd7806

File tree

3 files changed

+135
-37
lines changed

3 files changed

+135
-37
lines changed

google/cloud/alloydb/v1alpha/alloydb_v1alpha_grpc_service_config.json

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

google/cloud/alloydb/v1alpha/resources.proto

Lines changed: 77 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.
@@ -764,10 +780,10 @@ message Cluster {
764780
(google.api.field_behavior) = OPTIONAL
765781
];
766782

767-
// Output only. AlloyDB per-cluster service agent email. This service account
768-
// is created per-cluster per-project, and is different from that of the
769-
// primary service agent which is created per-project. The service account
770-
// naming format is subject to change.
783+
// Output only. AlloyDB per-cluster service account. This service account is
784+
// created per-cluster per-project, and is different from the per-project
785+
// service account. The per-cluster service account naming format is subject
786+
// to change.
771787
string service_account_email = 46 [(google.api.field_behavior) = OUTPUT_ONLY];
772788
}
773789

@@ -983,8 +999,12 @@ message Instance {
983999
// Service Connect (PSC) is enabled for the instance.
9841000
// The name of the resource will be in the format of
9851001
// `projects/<alloydb-tenant-project-number>/regions/<region-name>/serviceAttachments/<service-attachment-name>`
986-
string service_attachment_link = 1
987-
[(google.api.field_behavior) = OUTPUT_ONLY];
1002+
string service_attachment_link = 1 [
1003+
(google.api.field_behavior) = OUTPUT_ONLY,
1004+
(google.api.resource_reference) = {
1005+
type: "compute.googleapis.com/ServiceAttachment"
1006+
}
1007+
];
9881008

9891009
// Optional. List of consumer projects that are allowed to create
9901010
// PSC endpoints to service-attachments to this instance.
@@ -1051,20 +1071,14 @@ message Instance {
10511071

10521072
// Configuration for Managed Connection Pool (MCP).
10531073
message ConnectionPoolConfig {
1054-
// The pool mode. Defaults to `POOL_MODE_TRANSACTION`.
1055-
enum PoolMode {
1056-
// The pool mode is not specified. Defaults to `POOL_MODE_TRANSACTION`.
1057-
POOL_MODE_UNSPECIFIED = 0;
1058-
1059-
// Server is released back to pool after a client disconnects.
1060-
POOL_MODE_SESSION = 1;
1061-
1062-
// Server is released back to pool after a transaction finishes.
1063-
POOL_MODE_TRANSACTION = 2;
1064-
}
1065-
10661074
// Optional. Whether to enable Managed Connection Pool (MCP).
10671075
bool enabled = 12 [(google.api.field_behavior) = OPTIONAL];
1076+
1077+
// Optional. Connection Pool flags, as a list of "key": "value" pairs.
1078+
map<string, string> flags = 13 [(google.api.field_behavior) = OPTIONAL];
1079+
1080+
// Output only. The number of running poolers per instance.
1081+
int32 pooler_count = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
10681082
}
10691083

10701084
// Instance State
@@ -1725,13 +1739,43 @@ message Database {
17251739
// `projects/{project}/locations/{location}/clusters/{cluster}/databases/{database}`.
17261740
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
17271741

1728-
// Optional. Charset for the database.
1742+
// Optional. Immutable. Charset for the database.
17291743
// This field can contain any PostgreSQL supported charset name.
17301744
// Example values include "UTF8", "SQL_ASCII", etc.
1731-
string charset = 2 [(google.api.field_behavior) = OPTIONAL];
1745+
string charset = 2 [
1746+
(google.api.field_behavior) = OPTIONAL,
1747+
(google.api.field_behavior) = IMMUTABLE
1748+
];
1749+
1750+
// Optional. Immutable. lc_collate for the database.
1751+
// String sort order.
1752+
// Example values include "C", "POSIX", etc.
1753+
string collation = 3 [
1754+
(google.api.field_behavior) = OPTIONAL,
1755+
(google.api.field_behavior) = IMMUTABLE
1756+
];
17321757

1733-
// Optional. Collation for the database.
1734-
// Name of the custom or native collation for postgres.
1735-
// Example values include "C", "POSIX", etc
1736-
string collation = 3 [(google.api.field_behavior) = OPTIONAL];
1758+
// Optional. Immutable. lc_ctype for the database.
1759+
// Character classification (What is a letter? The upper-case equivalent?).
1760+
// Example values include "C", "POSIX", etc.
1761+
string character_type = 4 [
1762+
(google.api.field_behavior) = OPTIONAL,
1763+
(google.api.field_behavior) = IMMUTABLE
1764+
];
1765+
1766+
// Optional. Whether the database is a template database.
1767+
// Deprecated in favor of is_template_database.
1768+
bool is_template = 5
1769+
[deprecated = true, (google.api.field_behavior) = OPTIONAL];
1770+
1771+
// Input only. Immutable. Template of the database to be used for creating a
1772+
// new database.
1773+
string database_template = 6 [
1774+
(google.api.field_behavior) = INPUT_ONLY,
1775+
(google.api.field_behavior) = IMMUTABLE
1776+
];
1777+
1778+
// Optional. Whether the database is a template database.
1779+
optional bool is_template_database = 7
1780+
[(google.api.field_behavior) = OPTIONAL];
17371781
}

google/cloud/alloydb/v1alpha/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: "/v1alpha/{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)