def sink_get(self, sink_name): """Retrieve a sink resource. Args: sink_name (str): The resource name of the sink, including the parent resource and the sink identifier: :: "projects/[PROJECT_ID]/sinks/[SINK_ID]" "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" "folders/[FOLDER_ID]/sinks/[SINK_ID]" Returns: dict: The sink object returned from the API (converted from a protobuf to a dictionary). """ sink_pb = self._gapic_api.get_sink(sink_name=sink_name) # NOTE: LogSink message type does not have an ``Any`` field # so `MessageToDict`` can safely be used. return MessageToDict( LogSink.pb(sink_pb), preserving_proto_field_name=False, including_default_value_fields=False, )
def sink_update( self, sink_name, filter_, destination, *, unique_writer_identity=False, ): """Update a sink resource. Args: sink_name (str): Required. The resource name of the sink, including the parent resource and the sink identifier: :: "projects/[PROJECT_ID]/sinks/[SINK_ID]" "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" "folders/[FOLDER_ID]/sinks/[SINK_ID]" filter_ (str): The advanced logs filter expression defining the entries exported by the sink. destination (str): destination URI for the entries exported by the sink. unique_writer_identity (Optional[bool]): determines the kind of IAM identity returned as writer_identity in the new sink. Returns: dict: The sink resource returned from the API (converted from a protobuf to a dictionary). """ name = sink_name.split("/")[-1] # parse name out of full resoure name sink_pb = LogSink( name=name, filter=filter_, destination=destination, ) request = UpdateSinkRequest( sink_name=sink_name, sink=sink_pb, unique_writer_identity=unique_writer_identity, ) sink_pb = self._gapic_api.update_sink(request=request) # NOTE: LogSink message type does not have an ``Any`` field # so `MessageToDict`` can safely be used. return MessageToDict( LogSink.pb(sink_pb), preserving_proto_field_name=False, including_default_value_fields=False, )
def sink_create(self, parent, sink_name, filter_, destination, *, unique_writer_identity=False): """Create a sink resource. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create Args: parent(str): The resource in which to create the sink, including the parent resource and the sink identifier: :: "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]". sink_name (str): The name of the sink. filter_ (str): The advanced logs filter expression defining the entries exported by the sink. destination (str): Destination URI for the entries exported by the sink. unique_writer_identity (Optional[bool]): determines the kind of IAM identity returned as writer_identity in the new sink. Returns: dict: The sink resource returned from the API (converted from a protobuf to a dictionary). """ sink_pb = LogSink(name=sink_name, filter=filter_, destination=destination) request = CreateSinkRequest( parent=parent, sink=sink_pb, unique_writer_identity=unique_writer_identity) created_pb = self._gapic_api.create_sink(request=request) return MessageToDict( LogSink.pb(created_pb), preserving_proto_field_name=False, including_default_value_fields=False, )