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. |
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. |
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 | name, databaseRoles, host, revokeExistingRoles | 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 |
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,
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,
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__name,
data__databaseRoles,
data__host,
data__etag,
data__iamEmail,
data__type,
data__passwordPolicy,
data__password,
data__instance,
data__project,
data__iamStatus,
data__kind,
data__dualPasswordType,
data__sqlserverUserDetails,
project,
instance
)
SELECT
'{{ name }}',
'{{ databaseRoles }}',
'{{ host }}',
'{{ etag }}',
'{{ iamEmail }}',
'{{ type }}',
'{{ passwordPolicy }}',
'{{ password }}',
'{{ instance }}',
'{{ project }}',
'{{ iamStatus }}',
'{{ kind }}',
'{{ dualPasswordType }}',
'{{ sqlserverUserDetails }}',
'{{ 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: 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: databaseRoles
value:
- "{{ databaseRoles }}"
description: |
Optional. Role memberships of the user
- 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: etag
value: "{{ etag }}"
description: |
This field is deprecated and will be removed from a future version of the API.
- 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: 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']
- name: passwordPolicy
description: |
User level password validation policy.
value:
enablePasswordVerification: {{ enablePasswordVerification }}
allowedFailedAttempts: {{ allowedFailedAttempts }}
passwordExpirationDuration: "{{ passwordExpirationDuration }}"
enableFailedAttemptsCheck: {{ enableFailedAttemptsCheck }}
status:
locked: {{ locked }}
passwordExpirationTime: "{{ passwordExpirationTime }}"
- name: password
value: "{{ password }}"
description: |
The password for the user.
- 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: 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: iamStatus
value: "{{ iamStatus }}"
description: |
Indicates if a group is active or inactive for IAM database authentication.
valid_values: ['IAM_STATUS_UNSPECIFIED', 'INACTIVE', 'ACTIVE']
- name: kind
value: "{{ kind }}"
description: |
This is always `sql#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: sqlserverUserDetails
description: |
Represents a Sql Server user on the Cloud SQL instance.
value:
disabled: {{ disabled }}
serverRoles:
- "{{ serverRoles }}"
REPLACE examples
- update
Updates an existing user in a Cloud SQL instance.
REPLACE google.sqladmin.users
SET
data__name = '{{ name }}',
data__databaseRoles = '{{ databaseRoles }}',
data__host = '{{ host }}',
data__etag = '{{ etag }}',
data__iamEmail = '{{ iamEmail }}',
data__type = '{{ type }}',
data__passwordPolicy = '{{ passwordPolicy }}',
data__password = '{{ password }}',
data__instance = '{{ instance }}',
data__project = '{{ project }}',
data__iamStatus = '{{ iamStatus }}',
data__kind = '{{ kind }}',
data__dualPasswordType = '{{ dualPasswordType }}',
data__sqlserverUserDetails = '{{ sqlserverUserDetails }}'
WHERE
project = '{{ project }}' --required
AND instance = '{{ instance }}' --required
AND name = '{{ name}}'
AND databaseRoles = '{{ databaseRoles}}'
AND host = '{{ host}}'
AND revokeExistingRoles = {{ revokeExistingRoles}}
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 }}'
;