Skip to main content

users

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

Overview

Nameusers
TypeResource
Idgoogle.sqladmin.users

Fields

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.
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.
typestringThe user type. It determines the method to authenticate the user during login. The default is the database's built-in user type.

Methods

NameAccessible byRequired ParamsDescription
getSELECTinstance, name, projectRetrieves a resource containing information about a user.
listSELECTinstance, projectLists users in the specified Cloud SQL instance.
insertINSERTinstance, projectCreates a new user in a Cloud SQL instance.
deleteDELETEinstance, projectDeletes a user from a Cloud SQL instance.
updateREPLACEinstance, projectUpdates an existing user in a Cloud SQL instance.

SELECT examples

Lists users in the specified Cloud SQL instance.

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

INSERT example

Use the following StackQL query and manifest file to create a new users resource.

/*+ create */
INSERT INTO google.sqladmin.users (
instance,
project,
password,
etag,
name,
host,
instance,
project,
type,
sqlserverUserDetails,
passwordPolicy,
dualPasswordType
)
SELECT
'{{ instance }}',
'{{ project }}',
'{{ password }}',
'{{ etag }}',
'{{ name }}',
'{{ host }}',
'{{ instance }}',
'{{ project }}',
'{{ type }}',
'{{ sqlserverUserDetails }}',
'{{ passwordPolicy }}',
'{{ dualPasswordType }}'
;

REPLACE example

Replaces all fields in the specified users resource.

/*+ update */
REPLACE google.sqladmin.users
SET
password = '{{ password }}',
etag = '{{ etag }}',
name = '{{ name }}',
host = '{{ host }}',
instance = '{{ instance }}',
project = '{{ project }}',
type = '{{ type }}',
sqlserverUserDetails = '{{ sqlserverUserDetails }}',
passwordPolicy = '{{ passwordPolicy }}',
dualPasswordType = '{{ dualPasswordType }}'
WHERE
instance = '{{ instance }}'
AND project = '{{ project }}';

DELETE example

Deletes the specified users resource.

/*+ delete */
DELETE FROM google.sqladmin.users
WHERE instance = '{{ instance }}'
AND project = '{{ project }}';