create method
Creates a new custom Role.
request
- The metadata request object.
Request parameters:
parent
- The parent
parameter's value depends on the target resource
for the request, namely
projects
or
organizations.
Each resource type's parent
value format is described below: *
projects.roles.create:
projects/{PROJECT_ID}
. This method creates project-level
custom roles.
Example request URL:
https://iam.googleapis.com/v1/projects/{PROJECT_ID}/roles
*
organizations.roles.create:
organizations/{ORGANIZATION_ID}
. This method creates organization-level
custom roles.
Example request URL:
https://iam.googleapis.com/v1/organizations/{ORGANIZATION_ID}/roles
Note: Wildcard (*) values are invalid; you must specify a complete project
ID or organization ID.
Value must have pattern ^organizations/\[^/\]+$
.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a Role.
Completes with a commons.ApiRequestError if the API endpoint returned an error.
If the used http.Client
completes with an error when making a REST call,
this method will complete with the same error.
Implementation
async.Future<Role> create(
CreateRoleRequest request,
core.String parent, {
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/roles';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return Role.fromJson(response_ as core.Map<core.String, core.dynamic>);
}