create method
- Assignment request,
- String parent, {
- String? assignmentId,
- String? $fields,
Creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified reservation.
Currently a resource (project, folder, organization) can only have one
assignment per each (job_type, location) combination, and that reservation
will be used for all jobs of the matching type. Different assignments can
be created on different levels of the projects, folders or organization
hierarchy. During query execution, the assignment is looked up at the
project, folder and organization levels in that order. The first
assignment found is applied to the query. When creating assignments, it
does not matter if other assignments exist at higher levels. Example: *
The organization organizationA
contains two projects, project1
and
project2
. * Assignments for all three entities (organizationA
,
project1
, and project2
) could all be created and mapped to the same or
different reservations. "None" assignments represent an absence of the
assignment. Projects assigned to None use on-demand pricing. To create a
"None" assignment, use "none" as a reservation_id in the parent. Example
parent: projects/myproject/locations/US/reservations/none
. Returns
google.rpc.Code.PERMISSION_DENIED
if user does not have 'bigquery.admin'
permissions on the project using the reservation and the project that owns
this reservation. Returns google.rpc.Code.INVALID_ARGUMENT
when location
of the assignment does not match location of the reservation.
request
- The metadata request object.
Request parameters:
parent
- Required. The parent resource name of the assignment E.g.
projects/myproject/locations/US/reservations/team1-prod
Value must have pattern
^projects/\[^/\]+/locations/\[^/\]+/reservations/\[^/\]+$
.
assignmentId
- The optional assignment ID. Assignment name will be
generated automatically if this field is empty. This field must only
contain lower case alphanumeric characters or dashes. Max length is 64
characters.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a Assignment.
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<Assignment> create(
Assignment request,
core.String parent, {
core.String? assignmentId,
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if (assignmentId != null) 'assignmentId': [assignmentId],
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/assignments';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return Assignment.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}