
    )                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	l
mZ ddlmZ dd
lmZ ddlmZ ddlmZ  e	j*                  e	j,                  j.                  e	j,                  j0                  e	j,                  j2                        e	j4                   G d de	j6                                      Zy)zHCommand for updating a Cloud Security Command Center NotificationConfig.    )absolute_import)division)print_function)unicode_literals)securitycenter_client)base)flags)util)notification_util)log)
propertiesc                   2    e Zd ZdZddddZed        Zd Zy)	Updatez5Update a Security Command Center notification config.a        Update a Security Command Center notification config.

      Notification configs that are created with Security Command Center API V2
      and later include a `location` attribute. If the `location` attribute is
      included in the resource name of a Notification configs, you must specify
      it when referencing the Notification config. For example, the following
      Notification configs name has `location=eu`:
      `organizations/123/locations/eu/notificationConfigs/test-config`.
      aX        Update all mutable fields under an organization parent `test-config`
      (description + pubsub topic + filter):

        $ {command} scc notifications update test-config --organization=123             --description="New description"             --pubsub-topic="projects/22222/topics/newtopic"

      Update all mutable fields under a folder parent `test-config`
      (description + pubsub topic + filter):

        $ {command} scc notifications update test-config --folder=456             --description="New description"             --pubsub-topic="projects/22222/topics/newtopic"

      Update all mutable fields under a project parent `test-config`
      (description + pubsub topic + filter):

        $ {command} scc notifications update test-config --project=789             --description="New description"             --pubsub-topic="projects/22222/topics/newtopic"

      Update test-config's description

        $ {command} test-config --organization=123 --description="New description"

      Update test-config's pubsub-topic

        $ {command} test-config --organization=123
        --pubsub-topic="projects/22222/topics/newtopic"

      Update test-config's filter

        $ {command} test-config --organization=123 --filter='state = \"ACTIVE\"'

      Update all mutable fields for `test-config` with `location=global` under an
      organization parent (description + pubsub topic + filter):

        $ {command} scc notifications update test-config --organization=123             --description="New description"             --pubsub-topic="projects/22222/topics/newtopic" --location=global
      z      This command uses the Security Command Center API. For more information,
      see [Security Command Center API.](https://cloud.google.com/security-command-center/docs/reference/rest)
      )DESCRIPTIONEXAMPLESzAPI REFERENCEc                 $   t         j                  j                  |        t         j                  j                  |        t         j                  j                  |        t        j
                  |        t        j                  |        t        j                  j                  |        t         j                  j                  |        | j                  j                  t        j                  j                  j                  j!                                y )N)notifications_flagsDESCRIPTION_FLAGAddToParserFILTER_FLAG_LONG_DESCRIPTIONPUBSUB_TOPIC_OPTIONAL_FLAG'AddNotificationConfigPositionalArgumentAddParentGroup	scc_flagsAPI_VERSION_FLAG(UPDATE_NOTIFICATION_CONFIG_LOCATION_FLAGdisplay_info	AddFormatr   VALUEScoredefault_formatGet)parsers    'lib/surface/scc/notifications/update.pyArgszUpdate.Argsb   s     ((44V<44@@H22>>vF??G&&v.**62@@LL !!*"3"3"8"8"G"G"K"K"MN    c                 <   t        j                  ||j                  d      }t        j                  |      }t        j
                  |      }t        j                  |      }t        j                  ||       |dk(  r7|j                         }t        j                  |      |_        |j                  }n6|j                         }t        j                  |      |_        |j                  }g }|j!                         |_        |j%                  d      r,|j'                  d       |j(                  |j"                  _        |j%                  d      r,|j'                  d       |j*                  |j"                  _        |j%                  d      rC|j'                  d       |j/                         }	|j0                  |	_        |	|j"                  _        d	j5                  |      |_        d |_        |j9                  |      }
t:        j<                  j?                  d
       |
S )NT)"version_specific_existing_resourcev1descriptionpubsub_topicpubsubTopicfilterzstreamingConfig.filter,zUpdated.) scc_utilGetVersionFromArgumentsNOTIFICATIONCONFIGIDr   GetMessages	GetClientGetParentFromNamedArgumentsr    ValidateMutexOnConfigIdAndParent:SecuritycenterOrganizationsNotificationConfigsPatchRequest&ValidateAndGetNotificationConfigV1Namename!organizations_notificationConfigsCSecuritycenterOrganizationsLocationsNotificationConfigsPatchRequest&ValidateAndGetNotificationConfigV2Name+organizations_locations_notificationConfigsNotificationConfignotificationConfigIsKnownAndSpecifiedappendr*   r+   r,   StreamingConfigr-   streamingConfigjoin
updateMaskPatchr   statusPrint)selfargsversionmessagesclientparentreqendpointcomputed_update_maskstreaming_configresults              r$   Runz
Update.Runs   s    ..d''DG %009H",,W5F11$7F66tVD$

M
M
O 
 #II$Och99h 
V
V
X 
 #II$OchCCh%88:C.!!-0+/+;+;c(/!!-0+/+<+<c()!!":;!113 $/?c, XX23CN DK^^C FJJZ Mr&   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr%   rS    r&   r$   r   r       s;    
 >	
)
T
k9-v O O 1r&   r   N)rW   
__future__r   r   r   r   googlecloudsdk.api_lib.sccr   googlecloudsdk.callioper   googlecloudsdk.command_lib.sccr	   r   r
   r/   ,googlecloudsdk.command_lib.scc.notificationsr   r   googlecloudsdk.corer   r   ReleaseTracksReleaseTrackGABETAALPHADefaultUniverseOnlyUpdateCommandr   rZ   r&   r$   <module>rh      s    O &  % ' < ( = ; U J # * $++00$2C2C2I2I @T @ @r&   