Skip to main content

users

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

Overview

Nameusers
TypeResource
Idgoogle.alloydb.users

Fields

NameDatatypeDescription
namestringOutput only. Name of the resource in the form of projects/{project}/locations/{location}/cluster/{cluster}/users/{user}.
databaseRolesarrayOptional. List of database roles this user has. The database role strings are subject to the PostgreSQL naming conventions.
keepExtraRolesbooleanInput only. If the user already exists and it has additional roles, keep them granted.
passwordstringInput only. Password for the user.
userTypestringOptional. Type of this user.

Methods

NameAccessible byRequired ParamsDescription
getSELECTclustersId, locationsId, projectsId, usersIdGets details of a single User.
listSELECTclustersId, locationsId, projectsIdLists Users in a given project and location.
createINSERTclustersId, locationsId, projectsIdCreates a new User in a given project, location, and cluster.
deleteDELETEclustersId, locationsId, projectsId, usersIdDeletes a single User.
patchUPDATEclustersId, locationsId, projectsId, usersIdUpdates the parameters of a single User.

SELECT examples

Lists Users in a given project and location.

SELECT
name,
databaseRoles,
keepExtraRoles,
password,
userType
FROM google.alloydb.users
WHERE clustersId = '{{ clustersId }}'
AND locationsId = '{{ locationsId }}'
AND projectsId = '{{ projectsId }}';

INSERT example

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

/*+ create */
INSERT INTO google.alloydb.users (
clustersId,
locationsId,
projectsId,
password,
databaseRoles,
userType,
keepExtraRoles
)
SELECT
'{{ clustersId }}',
'{{ locationsId }}',
'{{ projectsId }}',
'{{ password }}',
'{{ databaseRoles }}',
'{{ userType }}',
{{ keepExtraRoles }}
;

UPDATE example

Updates a users resource.

/*+ update */
UPDATE google.alloydb.users
SET
password = '{{ password }}',
databaseRoles = '{{ databaseRoles }}',
userType = '{{ userType }}',
keepExtraRoles = true|false
WHERE
clustersId = '{{ clustersId }}'
AND locationsId = '{{ locationsId }}'
AND projectsId = '{{ projectsId }}'
AND usersId = '{{ usersId }}';

DELETE example

Deletes the specified users resource.

/*+ delete */
DELETE FROM google.alloydb.users
WHERE clustersId = '{{ clustersId }}'
AND locationsId = '{{ locationsId }}'
AND projectsId = '{{ projectsId }}'
AND usersId = '{{ usersId }}';