HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib/google-cloud-sdk/lib/surface/logging/sinks/__pycache__/create.cpython-312.pyc
�

���%��V�dZddlmZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZdd	lm
Z
e	je	je	j j"e	j j$e	j j&�Gd
�de	j(���Zy)
z'logging sinks create' command.�)�absolute_import)�division)�unicode_literals)�util)�arg_parsers)�base)�log)�
console_ioc�8�eZdZdZed��Zd�Zd�Zd�Zd�Z	y)�Createa�Create a log sink.

  Create a log sink used to route log entries to a destination. The sink routes
  all log entries that match its *--log-filter* flag.

  An empty filter matches all logs.

  Detailed information about filters can be found at:
  [](https://cloud.google.com/logging/docs/view/logging-query-language)

  The sink's destination can be a Cloud Logging log bucket, a Cloud Storage
  bucket, a BigQuery dataset, a Cloud Pub/Sub topic, or a Google Cloud project.

  The destination must already exist.

  If creating a log sink to route logs to a destination outside of Cloud Logging
  or to a Cloud Logging log bucket in another project, the log sink's service
  account must be granted permission to write to the destination.

  For more information about destination permissions, see:
  https://cloud.google.com/logging/docs/export/configure_export_v2#dest-auth

  Matching log entries are routed to the destination after the sink is created.

  ## EXAMPLES

  To route all Google Compute Engine logs to BigQuery, run:

    $ {command} my-bq-sink
    bigquery.googleapis.com/projects/my-project/datasets/my_dataset --log-filter='resource.type="gce_instance"'

  To route "syslog" from App Engine Flexible to a Cloud Storage bucket, run:

    $ {command} my-gcs-sink storage.googleapis.com/my-bucket --log-filter='logName="projects/my-project/appengine.googleapis.com%2Fsyslog"'

  To route Google App Engine logs with ERROR severity, run:

    $ {command} my-error-logs
    bigquery.googleapis.com/projects/my-project/datasets/my_dataset --log-filter='resource.type="gae_app" AND severity=ERROR'

  To route all logs to a log bucket in a different project, run:

    $ {command} my-sink
    logging.googleapis.com/projects/my-central-project/locations/global/buckets/my-central-bucket

  To route all logs to another project, run:

    $ {command} my-sink
    logging.googleapis.com/projects/my-destination-project
  c��|jdd��|jdtjdd����|jdd	d
��|jdd	d
d��|jdd	d
d��|jddd��|jd��}|jdd	d
d��|jddtjt
t
t
td�ddg��d� �|jd!d"��|jd#d
d$�%�tj|d&�|jjd'�y')(z Register flags for this command.�	sink_namezThe name for the sink.)�help�destinationzThe destination for the sink.z*Some destination types are not supported
.)�default�
universe_helpz--log-filterFz_A filter expression for the sink. If present, the filter specifies which log entries to export.)�requiredrz--include-children�
store_truezpWhether to export logs from all child projects and folders. Only applies to sinks for organizations and folders.)r�actionrz--intercept-childrenzsWhether to intercept logs from all child projects and folders. Only applies to sinks for organizations and folders.z--custom-writer-identity�SERVICE_ACCOUNT_EMAILz�Writer identity for the sink. This flag can only be used if the destination is a log bucket in a different project. The writer identity is automatically generated when it is not provided for a sink.)�metavarrz-Settings for sink exporting data to BigQuery.z--use-partitioned-tablesa(If specified, use BigQuery's partitioned tables. By default, Logging creates dated tables based on the log entries' timestamps, e.g. 'syslog_20170523'. Partitioned tables remove the suffix and special query syntax (https://cloud.google.com/bigquery/docs/querying-partitioned-tables) must be used.z--exclusion�append)�name�description�filter�disabledrr)�spec�
required_keysaDSpecify an exclusion filter for a log entry that is not to be exported. This flag can be repeated.

The ``name'' and ``filter'' attributes are required. The following keys are accepted:

*name*::: An identifier, such as ``load-balancer-exclusion''. Identifiers are limited to 100 characters and can include only letters, digits, underscores, hyphens, and periods.

*description*::: A description of this exclusion.

*filter*::: An advanced log filter that matches the log entries to be excluded.

*disabled*::: If this exclusion should be disabled and not exclude the log entries.)r�typerz
--descriptionzDescription of the sink.z
--disabledz9Sink will be disabled. Disabled sinks do not export logs.)rrzsink to createN)�add_argumentr�UniverseHelpText�add_argument_group�ArgDict�str�boolr�
AddParentArgs�display_info�AddCacheUpdater)�parser�bigquery_groups  �#lib/surface/logging/sinks/create.py�ArgszCreate.ArgsVs�������*B��C�
����
�
)�
)�3�G�
��������7��9�
������E�	�G�������
C������"�'�
�	�	��.�.�
<�/�>�N����"���;�	 �	=������
�
 �
 ��"�� �	�"�8�,�.�)��+�0����.H��I�
�����I��L�
	���v�/�0�
���'�'��-�c
���tj�}tj�jj	|j||jdi|��d|���S)z-Creates a v2 sink specified by the arguments.T)�parent�logSink�uniqueWriterIdentity�customWriterIdentity�)r�GetMessages�	GetClient�projects_sinksr�!LoggingProjectsSinksCreateRequest�LogSink)�selfr/�	sink_data�custom_writer_identity�messagess     r+�
CreateSinkzCreate.CreateSink�s_�����!�H��>�>��*�*�1�1��2�2��$�H�$�$�1�y�1�!%�!7�		3�	9�:�:r-c�8�|jstjdd��|jsN|jsB|j
rt
jd�|jrt
jd�tj|j|�}|j|jd�}|jd�r|j
|d<|jd	�r|j|d
<|jd�r|j|d<|jd
�ri}|j|d<||d<|jd�r|j |d<|jd�r|j"|d<|jd�r|j$|d<d}|jd�r|j&}|j)tj*|�||�}t
j,|�|j|_|j0|_|S)Nz+Sink with empty filter matches all entries.T)�cancel_on_nozQinclude-children only has an effect for sinks at the folder or organization levelzSintercept-children only has an effect for sinks at the folder or organization level)rr�include_children�includeChildren�intercept_children�interceptChildren�
log_filterr�use_partitioned_tables�usePartitionedTables�bigqueryOptions�	exclusion�
exclusionsrrr;)rDr
�PromptContinue�organization�folderr@r	�warningrBr�GetSinkReferencer�sinksIdr�IsSpecifiedrErHrrr;r=�GetParentFromArgs�CreatedResource�_epilog_result_destination�writerIdentity�_epilog_writer_identity)r9�args�sink_refr:�bigquery_optionsr;�results       r+�_RunzCreate._Run�s����?�?����
7�d�L�
������	
�	�	����
$�	
�
�	 �	 ����
$�	
�
�$�$�T�^�^�T�:�H�� � ��'�'��I�
���*�+�%)�%:�%:�i�!�"����,�-�'+�'>�'>�i�#�$�����%� �O�O�i������0�1���15�1L�1L��-�.�%5�i�!�"�����$� $���i������
�&�!%�!1�!1�i�
�����
�#�"�m�m�i�
��!�����0�1�#�:�:��
�_�_����t�$�i�1G�I�F�����!�&,�&8�&8�D�#�#)�#8�#8�D� ��Mr-c�$�|j|�S)z�This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      The created sink with its destination.
    )rZ)r9rVs  r+�Runz
Create.Run�s���9�9�T�?�r-c�X�tj|j|j�y)N)r�PrintPermissionInstructionsrSrU)r9�unused_resources_were_displayeds  r+�Epilogz
Create.Epilog�s"���$�$�T�%D�%D�%)�%A�%A�Cr-N)
�__name__�
__module__�__qualname__�__doc__�staticmethodr,r=rZr\r`r3r-r+rrs5��1�h�T.��T.�l:�9�v
�Cr-rN)rd�
__future__rrr�googlecloudsdk.api_lib.loggingr�googlecloudsdk.callioperr�googlecloudsdk.corer	�googlecloudsdk.core.consoler
�UniverseCompatible�
ReleaseTracks�ReleaseTrack�GA�BETA�ALPHA�
CreateCommandrr3r-r+�<module>rrs���&�&��'�/�/�(�#�2�������������$�+�+�0�0�$�2C�2C�2I�2I��`C�T�
�
�`C���`Cr-