users
Creates, updates, deletes, gets or lists a users resource.
Overview
| Name | users |
| Type | Resource |
| Id | google.sqladmin.users |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
name | string | The name of the user in the Cloud SQL instance. Can be omitted for update because it is already specified in the URL. |
databaseRoles | array | Optional. Role memberships of the user |
dualPasswordType | string | Dual password status for the user. (DUAL_PASSWORD_TYPE_UNSPECIFIED, NO_MODIFY_DUAL_PASSWORD, NO_DUAL_PASSWORD, DUAL_PASSWORD) |
etag | string | This field is deprecated and will be removed from a future version of the API. |
host | string | Optional. 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. |
iamEmail | string | Optional. The full email for an IAM user. For normal database users, this will not be filled. Only applicable to MySQL database users. |
iamStatus | string | Indicates if a group is active or inactive for IAM database authentication. (IAM_STATUS_UNSPECIFIED, INACTIVE, ACTIVE) |
instance | string | The 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. |
kind | string | This is always sql#user. |
password | string | The password for the user. |
passwordPolicy | object | User level password validation policy. (id: UserPasswordValidationPolicy) |
project | string | The 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. |
serverRoles | array | Optional. The server roles for the SQL Server login. |
sqlserverUserDetails | object | Represents a Sql Server user on the Cloud SQL instance. (id: SqlServerUserDetails) |
type | string | The user type. It determines the method to authenticate the user during login. The default is the database's built-in user type. (BUILT_IN, CLOUD_IAM_USER, CLOUD_IAM_SERVICE_ACCOUNT, CLOUD_IAM_GROUP, CLOUD_IAM_GROUP_USER, CLOUD_IAM_GROUP_SERVICE_ACCOUNT, CLOUD_IAM_WORKFORCE_IDENTITY, ENTRAID_USER) |
| Name | Datatype | Description |
|---|---|---|
name | string | The name of the user in the Cloud SQL instance. Can be omitted for update because it is already specified in the URL. |
databaseRoles | array | Optional. Role memberships of the user |
dualPasswordType | string | Dual password status for the user. (DUAL_PASSWORD_TYPE_UNSPECIFIED, NO_MODIFY_DUAL_PASSWORD, NO_DUAL_PASSWORD, DUAL_PASSWORD) |
etag | string | This field is deprecated and will be removed from a future version of the API. |
host | string | Optional. 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. |
iamEmail | string | Optional. The full email for an IAM user. For normal database users, this will not be filled. Only applicable to MySQL database users. |
iamStatus | string | Indicates if a group is active or inactive for IAM database authentication. (IAM_STATUS_UNSPECIFIED, INACTIVE, ACTIVE) |
instance | string | The 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. |
kind | string | This is always sql#user. |
password | string | The password for the user. |
passwordPolicy | object | User level password validation policy. (id: UserPasswordValidationPolicy) |
project | string | The 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. |
serverRoles | array | Optional. The server roles for the SQL Server login. |
sqlserverUserDetails | object | Represents a Sql Server user on the Cloud SQL instance. (id: SqlServerUserDetails) |
type | string | The user type. It determines the method to authenticate the user during login. The default is the database's built-in user type. (BUILT_IN, CLOUD_IAM_USER, CLOUD_IAM_SERVICE_ACCOUNT, CLOUD_IAM_GROUP, CLOUD_IAM_GROUP_USER, CLOUD_IAM_GROUP_SERVICE_ACCOUNT, CLOUD_IAM_WORKFORCE_IDENTITY, ENTRAID_USER) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | project, instance, name | host | Retrieves a resource containing information about a user. |
list | select | project, instance | Lists users in the specified Cloud SQL instance. | |
insert | insert | project, instance | Creates a new user in a Cloud SQL instance. | |
update | replace | project, instance | databaseRoles, host, name, revokeExistingRoles, revokeExistingServerRoles, serverRoles | Updates an existing user in a Cloud SQL instance. |
delete | delete | project, instance | host, name | Deletes 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.
| Name | Datatype | Description |
|---|---|---|
instance | string | |
name | string | |
project | string | |
databaseRoles | string | |
host | string | |
name | string | |
revokeExistingRoles | boolean | |
revokeExistingServerRoles | boolean | |
serverRoles | string |
SELECT examples
- get
- list
Retrieves a resource containing information about a user.
SELECT
name,
databaseRoles,
dualPasswordType,
etag,
host,
iamEmail,
iamStatus,
instance,
kind,
password,
passwordPolicy,
project,
serverRoles,
sqlserverUserDetails,
type
FROM google.sqladmin.users
WHERE project = '{{ project }}' -- required
AND instance = '{{ instance }}' -- required
AND name = '{{ name }}' -- required
AND host = '{{ host }}'
;
Lists users in the specified Cloud SQL instance.
SELECT
name,
databaseRoles,
dualPasswordType,
etag,
host,
iamEmail,
iamStatus,
instance,
kind,
password,
passwordPolicy,
project,
serverRoles,
sqlserverUserDetails,
type
FROM google.sqladmin.users
WHERE project = '{{ project }}' -- required
AND instance = '{{ instance }}' -- required
;
INSERT examples
- insert
- Manifest
Creates a new user in a Cloud SQL instance.
INSERT INTO google.sqladmin.users (
data__databaseRoles,
data__dualPasswordType,
data__etag,
data__host,
data__iamEmail,
data__iamStatus,
data__instance,
data__kind,
data__name,
data__password,
data__passwordPolicy,
data__project,
data__serverRoles,
data__sqlserverUserDetails,
data__type,
project,
instance
)
SELECT
'{{ databaseRoles }}',
'{{ dualPasswordType }}',
'{{ etag }}',
'{{ host }}',
'{{ iamEmail }}',
'{{ iamStatus }}',
'{{ instance }}',
'{{ kind }}',
'{{ name }}',
'{{ password }}',
'{{ passwordPolicy }}',
'{{ project }}',
'{{ serverRoles }}',
'{{ sqlserverUserDetails }}',
'{{ type }}',
'{{ project }}',
'{{ instance }}'
RETURNING
name,
acquireSsrsLeaseContext,
apiWarning,
backupContext,
endTime,
error,
exportContext,
importContext,
insertTime,
kind,
operationType,
preCheckMajorVersionUpgradeContext,
selfLink,
startTime,
status,
subOperationType,
targetId,
targetLink,
targetProject,
user
;
# Description fields are for documentation purposes
- name: users
props:
- name: project
value: "{{ project }}"
description: Required parameter for the users resource.
- name: instance
value: "{{ instance }}"
description: Required parameter for the users resource.
- name: databaseRoles
value:
- "{{ databaseRoles }}"
description: |
Optional. Role memberships of the user
- name: dualPasswordType
value: "{{ dualPasswordType }}"
description: |
Dual password status for the user.
valid_values: ['DUAL_PASSWORD_TYPE_UNSPECIFIED', 'NO_MODIFY_DUAL_PASSWORD', 'NO_DUAL_PASSWORD', 'DUAL_PASSWORD']
- name: etag
value: "{{ etag }}"
description: |
This field is deprecated and will be removed from a future version of the API.
- name: host
value: "{{ host }}"
description: |
Optional. 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.
- name: iamEmail
value: "{{ iamEmail }}"
description: |
Optional. The full email for an IAM user. For normal database users, this will not be filled. Only applicable to MySQL database users.
- name: iamStatus
value: "{{ iamStatus }}"
description: |
Indicates if a group is active or inactive for IAM database authentication.
valid_values: ['IAM_STATUS_UNSPECIFIED', 'INACTIVE', 'ACTIVE']
- name: instance
value: "{{ instance }}"
description: |
The 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.
- name: kind
value: "{{ kind }}"
description: |
This is always `sql#user`.
- name: name
value: "{{ name }}"
description: |
The name of the user in the Cloud SQL instance. Can be omitted for `update` because it is already specified in the URL.
- name: password
value: "{{ password }}"
description: |
The password for the user.
- name: passwordPolicy
description: |
User level password validation policy.
value:
allowedFailedAttempts: {{ allowedFailedAttempts }}
enableFailedAttemptsCheck: {{ enableFailedAttemptsCheck }}
enablePasswordVerification: {{ enablePasswordVerification }}
passwordExpirationDuration: "{{ passwordExpirationDuration }}"
status:
locked: {{ locked }}
passwordExpirationTime: "{{ passwordExpirationTime }}"
- name: project
value: "{{ project }}"
description: |
The 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.
- name: serverRoles
value:
- "{{ serverRoles }}"
description: |
Optional. The server roles for the SQL Server login.
- name: sqlserverUserDetails
description: |
Represents a Sql Server user on the Cloud SQL instance.
value:
disabled: {{ disabled }}
serverRoles:
- "{{ serverRoles }}"
- name: type
value: "{{ type }}"
description: |
The user type. It determines the method to authenticate the user during login. The default is the database's built-in user type.
valid_values: ['BUILT_IN', 'CLOUD_IAM_USER', 'CLOUD_IAM_SERVICE_ACCOUNT', 'CLOUD_IAM_GROUP', 'CLOUD_IAM_GROUP_USER', 'CLOUD_IAM_GROUP_SERVICE_ACCOUNT', 'CLOUD_IAM_WORKFORCE_IDENTITY', 'ENTRAID_USER']
REPLACE examples
- update
Updates an existing user in a Cloud SQL instance.
REPLACE google.sqladmin.users
SET
data__databaseRoles = '{{ databaseRoles }}',
data__dualPasswordType = '{{ dualPasswordType }}',
data__etag = '{{ etag }}',
data__host = '{{ host }}',
data__iamEmail = '{{ iamEmail }}',
data__iamStatus = '{{ iamStatus }}',
data__instance = '{{ instance }}',
data__kind = '{{ kind }}',
data__name = '{{ name }}',
data__password = '{{ password }}',
data__passwordPolicy = '{{ passwordPolicy }}',
data__project = '{{ project }}',
data__serverRoles = '{{ serverRoles }}',
data__sqlserverUserDetails = '{{ sqlserverUserDetails }}',
data__type = '{{ type }}'
WHERE
project = '{{ project }}' --required
AND instance = '{{ instance }}' --required
AND databaseRoles = '{{ databaseRoles}}'
AND host = '{{ host}}'
AND name = '{{ name}}'
AND revokeExistingRoles = {{ revokeExistingRoles}}
AND revokeExistingServerRoles = {{ revokeExistingServerRoles}}
AND serverRoles = '{{ serverRoles}}'
RETURNING
name,
acquireSsrsLeaseContext,
apiWarning,
backupContext,
endTime,
error,
exportContext,
importContext,
insertTime,
kind,
operationType,
preCheckMajorVersionUpgradeContext,
selfLink,
startTime,
status,
subOperationType,
targetId,
targetLink,
targetProject,
user;
DELETE examples
- delete
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 }}'
;