1// Copyright 2023 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.sql.v1; 18 19import "google/api/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/cloud/sql/v1/cloud_sql_resources.proto"; 23import "google/protobuf/duration.proto"; 24import "google/protobuf/timestamp.proto"; 25 26option go_package = "cloud.google.com/go/sql/apiv1/sqlpb;sqlpb"; 27option java_multiple_files = true; 28option java_outer_classname = "CloudSqlUsersProto"; 29option java_package = "com.google.cloud.sql.v1"; 30 31// Cloud SQL users service. 32service SqlUsersService { 33 option (google.api.default_host) = "sqladmin.googleapis.com"; 34 option (google.api.oauth_scopes) = 35 "https://www.googleapis.com/auth/cloud-platform," 36 "https://www.googleapis.com/auth/sqlservice.admin"; 37 38 // Deletes a user from a Cloud SQL instance. 39 rpc Delete(SqlUsersDeleteRequest) returns (Operation) { 40 option (google.api.http) = { 41 delete: "/v1/projects/{project}/instances/{instance}/users" 42 }; 43 } 44 45 // Retrieves a resource containing information about a user. 46 rpc Get(SqlUsersGetRequest) returns (User) { 47 option (google.api.http) = { 48 get: "/v1/projects/{project}/instances/{instance}/users/{name}" 49 }; 50 } 51 52 // Creates a new user in a Cloud SQL instance. 53 rpc Insert(SqlUsersInsertRequest) returns (Operation) { 54 option (google.api.http) = { 55 post: "/v1/projects/{project}/instances/{instance}/users" 56 body: "body" 57 }; 58 } 59 60 // Lists users in the specified Cloud SQL instance. 61 rpc List(SqlUsersListRequest) returns (UsersListResponse) { 62 option (google.api.http) = { 63 get: "/v1/projects/{project}/instances/{instance}/users" 64 }; 65 } 66 67 // Updates an existing user in a Cloud SQL instance. 68 rpc Update(SqlUsersUpdateRequest) returns (Operation) { 69 option (google.api.http) = { 70 put: "/v1/projects/{project}/instances/{instance}/users" 71 body: "body" 72 }; 73 } 74} 75 76message SqlUsersDeleteRequest { 77 // Host of the user in the instance. 78 string host = 1; 79 80 // Database instance ID. This does not include the project ID. 81 string instance = 2; 82 83 // Name of the user in the instance. 84 string name = 3; 85 86 // Project ID of the project that contains the instance. 87 string project = 4; 88} 89 90// Request message for Users Get RPC 91message SqlUsersGetRequest { 92 // Database instance ID. This does not include the project ID. 93 string instance = 1; 94 95 // User of the instance. 96 string name = 2; 97 98 // Project ID of the project that contains the instance. 99 string project = 3; 100 101 // Host of a user of the instance. 102 string host = 4; 103} 104 105message SqlUsersInsertRequest { 106 // Database instance ID. This does not include the project ID. 107 string instance = 1; 108 109 // Project ID of the project that contains the instance. 110 string project = 2; 111 112 User body = 100; 113} 114 115message SqlUsersListRequest { 116 // Database instance ID. This does not include the project ID. 117 string instance = 1; 118 119 // Project ID of the project that contains the instance. 120 string project = 2; 121} 122 123message SqlUsersUpdateRequest { 124 // Optional. Host of the user in the instance. 125 string host = 1 [(google.api.field_behavior) = OPTIONAL]; 126 127 // Database instance ID. This does not include the project ID. 128 string instance = 2; 129 130 // Name of the user in the instance. 131 string name = 3; 132 133 // Project ID of the project that contains the instance. 134 string project = 4; 135 136 User body = 100; 137} 138 139// User level password validation policy. 140message UserPasswordValidationPolicy { 141 // Number of failed login attempts allowed before user get locked. 142 int32 allowed_failed_attempts = 1; 143 144 // Expiration duration after password is updated. 145 google.protobuf.Duration password_expiration_duration = 2; 146 147 // If true, failed login attempts check will be enabled. 148 bool enable_failed_attempts_check = 3; 149 150 // Output only. Read-only password status. 151 PasswordStatus status = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; 152 153 // If true, the user must specify the current password before changing the 154 // password. This flag is supported only for MySQL. 155 bool enable_password_verification = 5; 156} 157 158// Read-only password status. 159message PasswordStatus { 160 // If true, user does not have login privileges. 161 bool locked = 1; 162 163 // The expiration time of the current password. 164 google.protobuf.Timestamp password_expiration_time = 2; 165} 166 167// A Cloud SQL user resource. 168message User { 169 // The user type. 170 enum SqlUserType { 171 // The database's built-in user type. 172 BUILT_IN = 0; 173 174 // Cloud IAM user. 175 CLOUD_IAM_USER = 1; 176 177 // Cloud IAM service account. 178 CLOUD_IAM_SERVICE_ACCOUNT = 2; 179 180 // Cloud IAM group non-login user. 181 CLOUD_IAM_GROUP = 3; 182 183 // Cloud IAM group login user. 184 CLOUD_IAM_GROUP_USER = 4; 185 186 // Cloud IAM group login service account. 187 CLOUD_IAM_GROUP_SERVICE_ACCOUNT = 5; 188 } 189 190 // The type of retained password. 191 enum DualPasswordType { 192 // The default value. 193 DUAL_PASSWORD_TYPE_UNSPECIFIED = 0; 194 195 // Do not update the user's dual password status. 196 NO_MODIFY_DUAL_PASSWORD = 1; 197 198 // No dual password usable for connecting using this user. 199 NO_DUAL_PASSWORD = 2; 200 201 // Dual password usable for connecting using this user. 202 DUAL_PASSWORD = 3; 203 } 204 205 // This is always `sql#user`. 206 string kind = 1; 207 208 // The password for the user. 209 string password = 2; 210 211 // This field is deprecated and will be removed from a future version of the 212 // API. 213 string etag = 3; 214 215 // The name of the user in the Cloud SQL instance. Can be omitted for 216 // `update` because it is already specified in the URL. 217 string name = 4; 218 219 // Optional. The host from which the user can connect. For `insert` 220 // operations, host defaults to an empty string. For `update` 221 // operations, host is specified as part of the request URL. The host name 222 // cannot be updated after insertion. For a MySQL instance, it's required; 223 // for a PostgreSQL or SQL Server instance, it's optional. 224 string host = 5 [(google.api.field_behavior) = OPTIONAL]; 225 226 // The name of the Cloud SQL instance. This does not include the project ID. 227 // Can be omitted for `update` because it is already specified on the 228 // URL. 229 string instance = 6; 230 231 // The project ID of the project containing the Cloud SQL database. The Google 232 // apps domain is prefixed if applicable. Can be omitted for `update` because 233 // it is already specified on the URL. 234 string project = 7; 235 236 // The user type. It determines the method to authenticate the user during 237 // login. The default is the database's built-in user type. 238 SqlUserType type = 8; 239 240 // User details for specific database type 241 oneof user_details { 242 SqlServerUserDetails sqlserver_user_details = 9; 243 } 244 245 // User level password validation policy. 246 UserPasswordValidationPolicy password_policy = 12; 247 248 // Dual password status for the user. 249 optional DualPasswordType dual_password_type = 13; 250} 251 252// Represents a Sql Server user on the Cloud SQL instance. 253message SqlServerUserDetails { 254 // If the user has been disabled 255 bool disabled = 1; 256 257 // The server roles for this user 258 repeated string server_roles = 2; 259} 260 261// User list response. 262message UsersListResponse { 263 // This is always `sql#usersList`. 264 string kind = 1; 265 266 // List of user resources in the instance. 267 repeated User items = 2; 268 269 // Unused. 270 string next_page_token = 3 [deprecated = true]; 271} 272