
    &                        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  e	j(                  e	j*                  j,                  e	j*                  j.                  e	j*                  j0                        e	j2                   G d de	j4                                      Zd Zy)zHCommand for creating a Cloud Security Command Center NotificationConfig.    )absolute_import)division)print_function)unicode_literals)securitycenter_client)base)flags)util)notification_util)logc                   2    e Zd ZdZddddZed        Zd Zy)	Createz5Create a Security Command Center notification config.a        Create a Security Command Center notification config.

      Notification configs that are created with Security Command Center API V2
      and later include a `location` attribute. If a location is not specified,
      the default `global` location is used. For example, the following
      Notification config name has `location=global` attribute:
      `organizations/123/locations/global/notificationConfigs/my-config`.a        Create a notification config test-config under organization 123 for
      findings for pubsub-topic projects/test-project/topics/notification-test
      with a filter on resource name:

        $ {command} test-config --organization=123
          --pubsub-topic=projects/test-project/topics/notification-test
          --filter="resource_name: \"a\""

      Create a notification config `test-config` under folder `456` for findings
      for pubsub-topic `projects/test-project/topics/notification-test` with a
      filter on resource name:

        $ {command} test-config --folder=456
          --pubsub-topic=projects/test-project/topics/notification-test
          --filter="resource_name: \"a\""

      Create a notification config `test-config` under project `789` for
      findings for pubsub-topic `projects/test-project/topics/notification-test`
      with a filter on resource name:

        $ {command} test-config --project=789
          --pubsub-topic=projects/test-project/topics/notification-test
          --filter="resource_name: \"a\""

      Create a notification config `test-config` under organization `123` for
      findings for `pubsub-topic projects/test-project/topics/notification-test`
      with a filter on resource name and `location=eu`

        $ {command} test-config --project=789
          --pubsub-topic=projects/test-project/topics/notification-test
          --filter="resource_name: \"a\"" --location=eu
      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                  |        y )N)
notifications_flagsPUBSUB_TOPIC_REQUIRED_FLAGAddToParserDESCRIPTION_FLAGFILTER_FLAG'AddNotificationConfigPositionalArgumentAddParentGroup	scc_flagsAPI_VERSION_FLAG(CREATE_NOTIFICATION_CONFIG_LOCATION_FLAG)parsers    'lib/surface/scc/notifications/create.pyArgszCreate.ArgsW   s     22>>vF((44V<##//7??G&&v.**62@@LL    c                 X   t        j                  |      }t        j                  ||       t        j                  ||j
                  d      }t        j                  |      }t        j                  |      }|dk(  r&|j                         }t        j                  |      }n%|j                         }t        j                  |      }t        j                  |      |_        t        |      |_        |j#                         |_        |j&                  |j$                  _        |j(                  |j$                  _        d|j
                  v r||j$                  _        n|j
                  |j$                  _        |j/                         }|j0                  d|_        n|j0                  |_        ||j$                  _        d |_        |dk(  r|j4                  j7                  |      }	n|j8                  j7                  |      }	t:        j<                  j?                  d       |	j,                  S )NT)"version_specific_existing_resourcev1z/notificationConfigs/ zCreated.) scc_utilGetParentFromNamedArgumentsr    ValidateMutexOnConfigIdAndParentGetVersionFromArgumentsNOTIFICATIONCONFIGIDr   GetMessages	GetClient;SecuritycenterOrganizationsNotificationConfigsCreateRequest&ValidateAndGetNotificationConfigV1NameDSecuritycenterOrganizationsLocationsNotificationConfigsCreateRequest&ValidateAndGetNotificationConfigV2Name#GetParentFromNotificationConfigNameparent_GetNotificationConfigIdconfigIdNotificationConfignotificationConfigdescriptionpubsub_topicpubsubTopicnameStreamingConfigfilterstreamingConfig!organizations_notificationConfigsr   +organizations_locations_notificationConfigsr   statusPrint)
selfargsr0   versionmessagesclientreqconfig_namestreaming_configresults
             r   Runz
Create.Runf   s   11$7F66tVD ..d''DG %009H",,W5F $

N
N
P 
 &LL
k
 
W
W
Y 
 &LL
k #FFCJ ,K8CL%88:C)-)9)9C&)-):):C& $";";;$/c!$($=$=c!  //1{{ " $-=C* DK$77>>sCfAAHHMfJJZ ;;r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   rI    r   r   r   r       s;    
 >M 
B
U.-`  @r   r   c                 .    | j                  d      }|d   S )N/)split)resource_nameparams_as_lists     r   r1   r1      s     &&s+.		r   N)rM   
__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   ReleaseTracksReleaseTrackGABETAALPHADefaultUniverseOnlyCreateCommandr   r1   rP   r   r   <module>rd      s     O &  % ' < ( = ; U J # $++00$2C2C2I2I BT B BJr   