create method

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

Creates a new topic.

request - The metadata request object.

Request parameters:

parent - Required. The parent location in which to create the topic. Structured like projects/{project_number}/locations/{location}. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+$.

topicId - Required. The ID to use for the topic, which will become the final component of the topic's name. This value is structured like: my-topic-name.

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

Completes with a Topic.

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

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

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