createSink method

Future<LogSink> createSink(
  1. CreateSinkRequest request
)

Creates a sink that exports specified log entries to a destination. The export of newly-ingested log entries begins immediately, unless the sink's writer_identity is not permitted to write to the destination. A sink can export log entries only from the resource owning the sink.

Throws a http.ClientException if there were problems communicating with the API service. Throws a ServiceException if the API method failed for any reason.

Implementation

Future<LogSink> createSink(CreateSinkRequest request) async {
  final url = _endPoint.replace(
    path: '/v2/${request.parent}/sinks',
    queryParameters: {
      if (request.uniqueWriterIdentity case final $1 when $1.isNotDefault)
        'uniqueWriterIdentity': '${$1}',
    },
  );
  final response = await _client.post(url, body: request.sink);
  return LogSink.fromJson(response);
}