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__/update.cpython-312.pyc
�

��K6��b�dZddlmZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Zdd	lm
Z
dd
lmZe	j e	j"e	j$j&e	j$j(e	j$j*�Gd�de	j,���Zy
)z'logging sinks update' command.�)�absolute_import)�division)�unicode_literals)�util)�arg_parsers)�base)�
exceptions)�log)�
console_ioc�>�eZdZdZed��Zd�Zd�Zd�Zd�Z	d�Z
y)	�Updatea�Update a sink.

  Change the *[DESTINATION]* or *--log-filter* associated with a sink.
  The new destination must already exist and Cloud Logging must have
  permission to write to it.

  Log entries are exported to the new destination immediately.

  ## EXAMPLES

  To only update a sink filter, run:

    $ {command} my-sink --log-filter='severity>=ERROR'

  Detailed information about filters can be found at:
  [](https://cloud.google.com/logging/docs/view/logging-query-language)
  c�\�|jdd��|jddtjdd���	�|jd
d��|jdd
dd��|jdd
dd��|jddd��tj|d�|jd��}|jddd��|jddd��|jdtj�dd �!�|jd"d#tjttttd$�d%d&g�'�d(�)�|jd*d#tjttttd$�d%g�'�d+�)�|jd,d-��|jd.dd/��y0)1z Register flags for this command.�	sink_namezThe name of the sink to update.)�help�destination�?zYA new destination for the sink. If omitted, the sink's existing destination is unchanged.z*Some destination types are not supported
.)�default�
universe_help)�nargsr�--log-filterzcA new filter expression for the sink. If omitted, the sink's existing filter (if any) is unchanged.z--include-childrenF�
store_truezpWhether to export logs from all child projects and folders. Only applies to sinks for organizations and folders.)�required�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.)�metavarrzsink to updatez-Settings for sink exporting data to BigQuery.�--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.)rr�--clear-exclusionsz,Remove all logging exclusions from the sink.�--remove-exclusionszEXCLUSION IDz7Specify the name of the Logging exclusion(s) to delete.)�typerrz--add-exclusion�append)�name�filter�description�disabledr!r")�spec�
required_keysa�Add an exclusion filter for log entries that are not to be routed to the sink' destination. This flag can be repeated.

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

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

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

*filter*::: Required. Entries that match this advanced log filter will be excluded. Filter cannot be empty.

*disabled*::: Optional. By default, an exclusion is not disabled. To disable an exclusion, include this key and specify any value.

)rrr�--update-exclusiona�Update an exclusion filter for a log entry that is not to be exported. This flag can be repeated.

The ``name'' attribute is required. The following keys are accepted:

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

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

*filter*::: Optional. Entries that match this advanced log filter will be excluded. Filter cannot be empty.

*disabled*::: Optional. To disable an exclusion, include this key and specify any value. To enable a disabled exclusion, include this key, but do not specify any value. Do not include this key unless you want to change its value.

z
--descriptionzDescription of the sink.z
--disabledz�Disable the sink. Disabled sinks do not route logs to the sink destination. Specify --no-disabled to enable a disabled sink. If this flag is not specified, the value will not be updated.N)
�add_argumentr�UniverseHelpTextr�
AddParentArgs�add_argument_group�ArgList�ArgDict�str�bool)�parser�bigquery_groups  �#lib/surface/logging/sinks/update.py�ArgszUpdate.Args4s*������*K��L�
�����
�
)�
)�6�H�
��
�����O��Q�������
C���������
C������"�'�
�	�	�	���v�/�0��.�.�
<�/�>�N����"��;� �=������<��?�����
�
 �
 �
"��G�	�J�
�����
�
 �
 ���"� �	�"�8�,�.�
��!�4�����
�
 �
 ���"� �	�"�(�$�B��D�6����.H��I�
�����N��P�c	���tj�jjtj�jtj|d|j����S)z*Returns a sink specified by the arguments.�sinks)�sinkName)r�	GetClient�projects_sinks�Get�GetMessages�LoggingProjectsSinksGetRequest�CreateResourceName�sinksId)�self�parent�sink_refs   r2�GetSinkzUpdate.GetSink�s\���>�>��*�*�.�.�����9�9��,�,�V�W�-5�-=�-=�?�	:�	@�A�Ar4c
��tj�}tj�jj	|jtj|d|d�|jdi|��ddj|�|���S)z*Patches a sink specified by the arguments.r6r!T�,)r7�logSink�uniqueWriterIdentity�
updateMask�customWriterIdentity�)	rr;r8r9�Patch� LoggingProjectsSinksPatchRequestr=�LogSink�join)r?r@�	sink_data�update_mask�custom_writer_identity�messagess      r2�	PatchSinkzUpdate.PatchSink�s������!�H��>�>��*�*�0�0��1�1��,�,�V�W�-6�v�->�@�$�H�$�$�1�y�1�!%��x�x��,�!7�
	2�	9�:�:r4c�
�tj|j|�}|jtj|�|�}d|j
i}g}|j
d�r |j|d<|jd�|j
d�rY|j|d<|jd�|jr-|js!|jstjd�|j
d�rY|j|d<|jd�|jr-|js!|jstjd�|j
d	�r |j|d
<|jd
�ddg}|j!d
dg�|j
d�r'i}|j"|d<||d<|jd�|j
d�r |j$|d<|jd�|j
d�r |j&|d<|jd�|j
d�s4|j
d�s#|j
d�s|j
d��r�g|d<|jd�|j
d�r|j(ng}|j
d�r|j*ng}	|j,D]�}
|
j.|vr|j1|
j.��-t3t5|	��D]j}|
j.|	|dk(s�|	|j7�D]*\}}
|dk(r|
|
_|d
k(r|
|
_|dk(s�$|
|
_�,|	j;|�n|dj|
���|r4t=j>ddjAdjC|����|	rEt=j>ddjAdjC|	D�
cgc]}
|
d��	c}
����|j
d�rg|d<|j
d�r|dxx|jDz
cc<d}|j
d�r|jF}|j!dg�|st=jH|d ��|jJr&d!|jJvrtMjNd"d#d$�%�|jQtj|�|||�}tjR|�|j
d�r"|j|_*|jJ|_+|Scc}
w)&Nr!r�include_children�includeChildrenzQinclude-children only has an effect for sinks at the folder or organization level�intercept_children�interceptChildrenzSintercept-children only has an effect for sinks at the folder or organization level�
log_filterr"z
[destination]rrr�use_partitioned_tables�usePartitionedTables�bigqueryOptionsz'bigquery_options.use_partitioned_tablesr#r$�clear_exclusions�remove_exclusions�
add_exclusion�update_exclusion�
exclusionsrzExclusions {0} do not existrDr'rPz--custom_writer_identityz.Please specify at least one property to updatezcloud-logs@aThis update will create a new writerIdentity (service account) for the sink. In order for the sink to continue working, grant that service account correct permission on the destination. The service account will be displayed after a successful update operation.TF)�cancel_on_nor),r�GetSinkReferencerrB�GetParentFromArgsr>�IsSpecifiedrr rT�organization�folderr
�warningrVrX�extendrYr#r$r]r_r`r!�remove�range�len�itemsr"�pop�calliope_exceptions�InvalidArgumentException�formatrMr^rP�MinimumArgumentException�writerIdentityr�PromptContinuerR�UpdatedResource�_epilog_result_destination�_epilog_writer_identity)r?�argsrA�sinkrNrO�parameter_names�bigquery_options�exclusions_to_remove�exclusions_to_update�	exclusion�i�key�valuerP�results                r2�_RunzUpdate._Run�s!���$�$�T�^�^�T�:�H��<�<��.�.�t�4�h�?�D���)�)�*�I��K����
�&�!%�!1�!1�i�
������'����*�+�%)�%:�%:�i�!�"����+�,�	
�	�	��(9�(9�T�[�[����
$�	
�
���,�-�'+�'>�'>�i�#�$����-�.�	
�	 �	 �$�*;�*;�t�{�{����
$�	
�
����%� �O�O�i�������"�&��7�O����6�8L�M�N����0�1���15�1L�1L��-�.�%5�i�!�"����B�C����
�&�!%�!1�!1�i�
������'����
�#�"�m�m�i�
������$����+�,����,�-�����)����+�,� "�i�������&��
�
�1�
2��
 �
 �8:��$(�#3�#3�4F�#G�$�
�
�R�����)��>�>�1�1�
�
%�
%�i�n�n�
5���1�2�3�a��~�~�!5�a�!8��!@�@� 4�Q� 7� =� =� ?�*�#�u��-�'�*/�)�'��(�?�%*�)�"��*�$�',�)�$�
!@�#�&�&�q�)��4��L�
!�
(�
(��
3�'�"
�!�:�:�!�#@�#G�#G����-�.�$0�1�	1�
�!�:�:� �"?�"F�"F�s�x�x�4H�I�4H�y��6�"�4H�I�HK�#L�M�	M�
�	�	�,�	-�"$�	�,��	
�	�	�/�	*��,��4�#5�#5�5��!�����0�1�#�:�:�����8�9�:���8�8�
�K�
M�M�
���}��0C�0C�C����K���
��^�^����t�$�i��� �F�����!����
�&�(.�(:�(:�d�%�%+�%:�%:�d�"��M��IJs�U
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 updated sink with its new destination.
    )r�)r?rws  r2�Runz
Update.RunGs���9�9�T�?�r4c�r�t|d�r+tj|j|j�yy)Nru)�hasattrr�PrintPermissionInstructionsrurv)r?�unused_resources_were_displayeds  r2�Epilogz
Update.EpilogSs2���t�1�2�
�&�&�t�'F�'F�'+�'C�'C�E�3r4N)�__name__�
__module__�__qualname__�__doc__�staticmethodr3rBrRr�r�r�rIr4r2r
r
s=��
�$�AP��AP�FA�
:�z�x
�Er4r
N)r��
__future__rrr�googlecloudsdk.api_lib.loggingr�googlecloudsdk.callioperrr	rn�googlecloudsdk.corer
�googlecloudsdk.core.consoler�UniverseCompatible�
ReleaseTracks�ReleaseTrack�GA�BETA�ALPHA�
UpdateCommandr
rIr4r2�<module>r�s���&�&��'�/�/�(�E�#�2�������������$�+�+�0�0�$�2C�2C�2I�2I��uE�T�
�
�uE���uEr4