Skip to main content

roles

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

Overview

Nameroles
TypeResource
Idgoogle.iam.roles

Fields

NameDatatypeDescription
namestringThe name of the role. When Role is used in CreateRole, the role name must not be set. When Role is used in output and other input such as UpdateRole, the role name is the complete path. For example, roles/logging.viewer for predefined roles, organizations/{ORGANIZATION_ID}/roles/myRole for organization-level custom roles, and projects/{PROJECT_ID}/roles/myRole for project-level custom roles.
descriptionstringOptional. A human-readable description for the role.
deletedbooleanThe current deleted state of the role. This field is read only. It will be ignored in calls to CreateRole and UpdateRole.
etagstringUsed to perform a consistent read-modify-write.
includedPermissionsarrayThe names of the permissions this role grants when bound in an IAM policy.
stagestringThe current launch stage of the role. If the ALPHA launch stage has been selected for a role, the stage field will not be included in the returned definition for the role.
titlestringOptional. A human-readable title for the role. Typically this is limited to 100 UTF-8 bytes.

Methods

NameAccessible byRequired ParamsDescription
getSELECTrolesIdGets the definition of a Role.
get_org_rolesSELECTorganizationsId, rolesIdGets the definition of a Role.
get_project_rolesSELECTprojectsId, rolesIdGets the definition of a Role.
listSELECTLists every predefined Role that IAM supports, or every custom role that is defined for an organization or project.
list_org_rolesSELECTorganizationsIdLists every predefined Role that IAM supports, or every custom role that is defined for an organization or project.
list_project_rolesSELECTprojectsIdLists every predefined Role that IAM supports, or every custom role that is defined for an organization or project.
create_org_rolesINSERTorganizationsIdCreates a new custom Role.
create_project_rolesINSERTprojectsIdCreates a new custom Role.
delete_org_rolesDELETEorganizationsId, rolesIdDeletes a custom Role. When you delete a custom role, the following changes occur immediately: You cannot bind a principal to the custom role in an IAM Policy. Existing bindings to the custom role are not changed, but they have no effect. By default, the response from ListRoles does not include the custom role. A deleted custom role still counts toward the custom role limit until it is permanently deleted. You have 7 days to undelete the custom role. After 7 days, the following changes occur: The custom role is permanently deleted and cannot be recovered. If an IAM policy contains a binding to the custom role, the binding is permanently removed. The custom role no longer counts toward your custom role limit.
delete_project_rolesDELETEprojectsId, rolesIdDeletes a custom Role. When you delete a custom role, the following changes occur immediately: You cannot bind a principal to the custom role in an IAM Policy. Existing bindings to the custom role are not changed, but they have no effect. By default, the response from ListRoles does not include the custom role. A deleted custom role still counts toward the custom role limit until it is permanently deleted. You have 7 days to undelete the custom role. After 7 days, the following changes occur: The custom role is permanently deleted and cannot be recovered. If an IAM policy contains a binding to the custom role, the binding is permanently removed. The custom role no longer counts toward your custom role limit.
patch_org_rolesUPDATEorganizationsId, rolesIdUpdates the definition of a custom Role.
patch_project_rolesUPDATEprojectsId, rolesIdUpdates the definition of a custom Role.
query_grantable_rolesEXECLists roles that can be granted on a Google Cloud resource. A role is grantable if the IAM policy for the resource can contain bindings to the role.
undelete_org_rolesEXECorganizationsId, rolesIdUndeletes a custom Role.
undelete_project_rolesEXECprojectsId, rolesIdUndeletes a custom Role.

SELECT examples

Lists every predefined Role that IAM supports, or every custom role that is defined for an organization or project.

SELECT
name,
description,
deleted,
etag,
includedPermissions,
stage,
title
FROM google.iam.roles
;

INSERT example

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

/*+ create */
INSERT INTO google.iam.roles (
projectsId,
roleId,
role
)
SELECT
'{{ projectsId }}',
'{{ roleId }}',
'{{ role }}'
;

UPDATE example

Updates a roles resource.

/*+ update */
UPDATE google.iam.roles
SET
name = '{{ name }}',
title = '{{ title }}',
description = '{{ description }}',
includedPermissions = '{{ includedPermissions }}',
stage = '{{ stage }}',
etag = '{{ etag }}',
deleted = true|false
WHERE
projectsId = '{{ projectsId }}'
AND rolesId = '{{ rolesId }}';

DELETE example

Deletes the specified roles resource.

/*+ delete */
DELETE FROM google.iam.roles
WHERE projectsId = '{{ projectsId }}'
AND rolesId = '{{ rolesId }}';