Sinks#

Define Stackdriver Logging API Sinks.

class google.cloud.logging.sink.Sink(name, filter_=None, destination=None, client=None)[source]#

Bases: object

Sinks represent filtered exports for log entries.

See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks

Parameters:
  • name (str) – the name of the sink
  • filter (str) – the advanced logs filter expression defining the entries exported by the sink. If not passed, the instance should already exist, to be refreshed via reload().
  • destination (str) – destination URI for the entries exported by the sink. If not passed, the instance should already exist, to be refreshed via reload().
  • client (google.cloud.logging.client.Client) – A client which holds credentials and project configuration for the sink (which requires a project).
client#

Clent bound to the sink.

create(client=None)[source]#

API call: create the sink via a PUT request

See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current sink.
delete(client=None)[source]#

API call: delete a sink via a DELETE request

See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/delete

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current sink.
exists(client=None)[source]#

API call: test for the existence of the sink via a GET request

See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current sink.
Return type:bool
Returns:Boolean indicating existence of the sink.
classmethod from_api_repr(resource, client)[source]#

Factory: construct a sink given its API representation

Parameters:
  • resource (dict) – sink resource representation returned from the API
  • client (google.cloud.logging.client.Client) – Client which holds credentials and project configuration for the sink.
Return type:

google.cloud.logging.sink.Sink

Returns:

Sink parsed from resource.

Raises:

ValueError if client is not None and the project from the resource does not agree with the project from the client.

full_name#

Fully-qualified name used in sink APIs

path#

URL path for the sink’s APIs

project#

Project bound to the sink.

reload(client=None)[source]#

API call: sync local sink configuration via a GET request

See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current sink.
update(client=None)[source]#

API call: update sink configuration via a PUT request

See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current sink.