create method

Future<SavedQuery> create(
  1. SavedQuery request,
  2. String parent, {
  3. String? savedQueryId,
  4. String? $fields,
})

Creates a saved query in a parent project/folder/organization.

request - The metadata request object.

Request parameters:

parent - Required. The name of the project/folder/organization where this saved_query should be created in. It can only be an organization number (such as "organizations/123"), a folder number (such as "folders/123"), a project ID (such as "projects/my-project-id"), or a project number (such as "projects/12345"). Value must have pattern ^\[^/\]+/\[^/\]+$.

savedQueryId - Required. The ID to use for the saved query, which must be unique in the specified parent. It will become the final component of the saved query's resource name. This value should be 4-63 characters, and valid characters are a-z-. Notice that this field is required in the saved query creation, and the name field of the saved_query will be ignored.

$fields - Selector specifying which fields to include in a partial response.

Completes with a SavedQuery.

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<SavedQuery> create(
  SavedQuery request,
  core.String parent, {
  core.String? savedQueryId,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (savedQueryId != null) 'savedQueryId': [savedQueryId],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/savedQueries';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return SavedQuery.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}