Skip to main content

users

Creates, updates, deletes, gets or lists a users resource.

Overview

Nameusers
TypeResource
Idgoogle.sqladmin.users

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringThe name of the user in the Cloud SQL instance. Can be omitted for update because it is already specified in the URL.
dualPasswordTypestringDual password status for the user.
etagstringThis field is deprecated and will be removed from a future version of the API.
hoststringOptional. The host from which the user can connect. For insert operations, host defaults to an empty string. For update operations, host is specified as part of the request URL. The host name cannot be updated after insertion. For a MySQL instance, it's required; for a PostgreSQL or SQL Server instance, it's optional.
instancestringThe name of the Cloud SQL instance. This does not include the project ID. Can be omitted for update because it is already specified on the URL.
kindstringThis is always sql#user.
passwordstringThe password for the user.
passwordPolicyobjectUser level password validation policy. (id: UserPasswordValidationPolicy)
projectstringThe project ID of the project containing the Cloud SQL database. The Google apps domain is prefixed if applicable. Can be omitted for update because it is already specified on the URL.
sqlserverUserDetailsobjectRepresents a Sql Server user on the Cloud SQL instance. (id: SqlServerUserDetails)
typestringThe user type. It determines the method to authenticate the user during login. The default is the database's built-in user type.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectproject, instance, namehostRetrieves a resource containing information about a user.
listselectproject, instanceLists users in the specified Cloud SQL instance.
insertinsertproject, instanceCreates a new user in a Cloud SQL instance.
updatereplaceproject, instancehost, nameUpdates an existing user in a Cloud SQL instance.
deletedeleteproject, instancehost, nameDeletes a user from a Cloud SQL instance.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
instancestring
namestring
projectstring
hoststring
namestring

SELECT examples

Retrieves a resource containing information about a user.

SELECT
name,
dualPasswordType,
etag,
host,
instance,
kind,
password,
passwordPolicy,
project,
sqlserverUserDetails,
type
FROM google.sqladmin.users
WHERE project = '{{ project }}' -- required
AND instance = '{{ instance }}' -- required
AND name = '{{ name }}' -- required
AND host = '{{ host }}';

INSERT examples

Creates a new user in a Cloud SQL instance.

INSERT INTO google.sqladmin.users (
data__kind,
data__password,
data__etag,
data__name,
data__host,
data__instance,
data__project,
data__type,
data__sqlserverUserDetails,
data__passwordPolicy,
data__dualPasswordType,
project,
instance
)
SELECT
'{{ kind }}',
'{{ password }}',
'{{ etag }}',
'{{ name }}',
'{{ host }}',
'{{ instance }}',
'{{ project }}',
'{{ type }}',
'{{ sqlserverUserDetails }}',
'{{ passwordPolicy }}',
'{{ dualPasswordType }}',
'{{ project }}',
'{{ instance }}'
RETURNING
name,
acquireSsrsLeaseContext,
apiWarning,
backupContext,
endTime,
error,
exportContext,
importContext,
insertTime,
kind,
operationType,
selfLink,
startTime,
status,
subOperationType,
targetId,
targetLink,
targetProject,
user
;

REPLACE examples

Updates an existing user in a Cloud SQL instance.

REPLACE google.sqladmin.users
SET
data__kind = '{{ kind }}',
data__password = '{{ password }}',
data__etag = '{{ etag }}',
data__name = '{{ name }}',
data__host = '{{ host }}',
data__instance = '{{ instance }}',
data__project = '{{ project }}',
data__type = '{{ type }}',
data__sqlserverUserDetails = '{{ sqlserverUserDetails }}',
data__passwordPolicy = '{{ passwordPolicy }}',
data__dualPasswordType = '{{ dualPasswordType }}'
WHERE
project = '{{ project }}' --required
AND instance = '{{ instance }}' --required
AND host = '{{ host}}'
AND name = '{{ name}}'
RETURNING
name,
acquireSsrsLeaseContext,
apiWarning,
backupContext,
endTime,
error,
exportContext,
importContext,
insertTime,
kind,
operationType,
selfLink,
startTime,
status,
subOperationType,
targetId,
targetLink,
targetProject,
user;

DELETE examples

Deletes a user from a Cloud SQL instance.

DELETE FROM google.sqladmin.users
WHERE project = '{{ project }}' --required
AND instance = '{{ instance }}' --required
AND host = '{{ host }}'
AND name = '{{ name }}';