create method
Creates a sink that exports specified log entries to a destination.
The export begins upon ingress, 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.
request
- The metadata request object.
Request parameters:
parent
- Required. The resource in which to create the sink:
"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]"
"billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" For
examples:"projects/my-project" "organizations/123456789"
Value must have pattern ^projects/\[^/\]+$
.
customWriterIdentity
- Optional. A service account provided by the
caller that will be used to write the log entries. The format must be
serviceAccount:some@email. This field can only be specified if you are
routing logs to a destination outside this sink's project. If not
specified, a Logging service account will automatically be generated.
uniqueWriterIdentity
- Optional. Determines the kind of IAM identity
returned as writer_identity in the new sink. If this value is omitted or
set to false, and if the sink's parent is a project, then the value
returned as writer_identity is the same group or service account used by
Cloud Logging before the addition of writer identities to this API. The
sink's destination must be in the same project as the sink itself.If this
field is set to true, or if the sink is owned by a non-project resource
such as an organization, then the value of writer_identity will be a
service agent
(https://cloud.google.com/iam/docs/service-account-types#service-agents)
used by the sinks with the same parent. For more information, see
writer_identity in LogSink.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a LogSink.
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<LogSink> create(
LogSink request,
core.String parent, {
core.String? customWriterIdentity,
core.bool? uniqueWriterIdentity,
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if (customWriterIdentity != null)
'customWriterIdentity': [customWriterIdentity],
if (uniqueWriterIdentity != null)
'uniqueWriterIdentity': ['${uniqueWriterIdentity}'],
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v2/' + core.Uri.encodeFull('$parent') + '/sinks';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return LogSink.fromJson(response_ as core.Map<core.String, core.dynamic>);
}