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