
    S)                     6   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dZ ej                   ej"                  j$                  ej"                  j&                        ej(                   G d dej*                                      Zy)zCommand to create a pipeline.    )absolute_import)division)unicode_literals)	pipelines)base)flags)labels_util)logz{description}a           To create a new pipeline `my-pipeline` in location `us-central1` with its destination targeting HTTP endpoint URI 'https://example-endpoint.com' and network attachment 'my-network-attachment', run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination and a message binding template, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',http_endpoint_message_binding_template='{"headers": {"new-header-key": "new-header-value"}}',network_attachment=my-network-attachment

        To create a new pipeline `my-pipeline` in location `us-central1` with a Cloud Workflow destination `my-workflow`, run:

          $ {command} my-pipeline --location=us-central1 --destinations=workflow=my-workflow

        To create a new pipeline `my-pipeline` in location `us-central1` with a message bus destination `my-message-bus`, run:

          $ {command} my-pipeline --location=us-central1 --destinations=message_bus=my-message-bus

        To create a new pipeline `my-pipeline` in location `us-central1` with a Cloud Pub/Sub Topic destination `my-topic`, run:

          $ {command} my-pipeline --location=us-central1 --destinations=pubsub_topic=my-topic

        To create a new pipeline `my-pipeline` in location `us-central1` with a Cloud Workflow in project `example-project` and location `us-east1`, run:

          $ {command} my-pipeline --location=us-central1 --destinations=workflow=my-workflow,project=example-project,location=us-east1

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and a service account `example-service-account@example-project.gserviceaccount.iam.com` for OIDC authentication, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment,google_oidc_authentication_service_account=example-service-account@example-project.gserviceaccount.iam.com

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and a service account `example-service-account@example-project.gserviceaccount.iam.com` for OIDC authentication with audience `https://example.com`, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment,google_oidc_authentication_service_account=example-service-account@example-project.gserviceaccount.iam.com,google_oidc_authentication_audience='https://example.com'

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and a service account `example-service-account@example-project.gserviceaccount.iam.com` for OAuth token authentication, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment,oauth_token_authentication_service_account=example-service-account@example-project.gserviceaccount.iam.com

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and a service account `example-service-account@example-project.gserviceaccount.iam.com` for OAuth token authentication with scope `https://www.googleapis.com/auth/cloud-platform`, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment,oauth_token_authentication_service_account=example-service-account@example-project.gserviceaccount.iam.com,oauth_token_authentication_scope='https://www.googleapis.com/auth/cloud-platform'

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and the JSON input and output payload formats, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment,output_payload_format_json= --input-payload-format-json=

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and the Avro input and output payload formats, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment,output_payload_format_avro_schema_definition='{"type": "record", "name": "my_record", "fields": [{"name": "my_field", "type": "string"}]}' --input-payload-format-avro-schema-definition='{"type": "record", "name": "my_record", "fields": [{"name": "my_field", "type": "string"}]}'

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and the Protobuf input and output payload formats, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment,output_payload_format_protobuf_schema_definition='syntax = "proto3"; message Location { string home_address = 1; }' --input-payload-format-protobuf-schema-definition='syntax = "proto3"; message Location { string home_address = 1; }'

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and a transformation mediation, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment --mediations=transformation_template='message.removeFields(["data.credit_card_number","data.ssn"])'

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and a INFO level logging configuration, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment --logging_config=INFO

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and a custom retry policy, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment --max-retry-attempts=10 --min-retry-delay=2s --max-retry-delay=64s

        To create a new pipeline `my-pipeline` in location `us-central1` with an HTTP endpoint URI destination `https://example-endpoint.com` and a Cloud KMS CryptoKey, run:

          $ {command} my-pipeline --location=us-central1 --destinations=http_endpoint_uri='https://example-endpoint.com',network_attachment=my-network-attachment --crypto-key=projects/PROJECT_ID/locations/KMS_LOCATION/keyRings/KEYRING/cryptoKeys/KEY
        )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)CreatezCreate an Eventarc pipeline.c                    t        j                  |dd       t        j                  |d       t        j                  |       t        j                  |       t        j
                  |d       t        j                  |       t        j                  |dd       t        j                  |       t        j                  j                  |       y )NzThe pipeline to create.T)requiredz#The logging config of the pipeline.F)
with_clearhidden)r   AddPipelineResourceArgAddPipelineDestinationsArgAddInputPayloadFormatArgsAddMediationsArgAddLoggingConfigArgAddRetryPolicyArgsAddCryptoKeyArgr	   AddCreateLabelsFlagsr   
ASYNC_FLAGAddToParser)clsparsers     (lib/surface/eventarc/pipelines/create.pyArgszCreate.Argsl   s    	  )D 
$$Vd;	##F+	6"	f&KL	V$	&U5A$$V,OO'    c                    t        j                         }|j                  j                  j	                         }t        j                  dj                  |j                  |j                  |j                               |j                  ||j                  ||j                  |j                  |j                  |j                   |j"                  |j$                  |j&                  |j(                  |j*                  |j,                  t/        j0                  ||j3                                           }|j4                  r|S |j7                  |d|      S )zRun the create command.z2Creating pipeline {} for project {} in location {})pipeline_refdestinationsinput_payload_format_json+input_payload_format_avro_schema_definition/input_payload_format_protobuf_schema_definition
mediationslogging_configmax_retry_attemptsmin_retry_delaymax_retry_delaycrypto_key_namelabelsCreating)r   PipelineClientV1CONCEPTSpipelineParser
   debugformatpipelinesId
projectsIdlocationsIdr   BuildPipeliner$   r%   r&   r'   r(   r)   r*   r+   r,   
crypto_keyr	   ParseCreateArgsLabelsValueClassasync_WaitFor)selfargsclientpipelines_ref	operations        r   Runz
Create.Runz   s   '')FMM**002MII<CC%%$$%%	
 &**&*&D&D8<8h8h<@<p<p..#66 00 00 OO..tV5L5L5NO 	 	
I$ {{>>)Z??r!   N)	__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpclassmethodr    rD    r!   r   r   r   e   s$     % -( ( @r!   r   N)rH   
__future__r   r   r   googlecloudsdk.api_lib.eventarcr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.eventarcr   $googlecloudsdk.command_lib.util.argsr	   googlecloudsdk.corer
   rI   ReleaseTracksReleaseTrackBETAGADefaultUniverseOnlyCreateCommandr   rL   r!   r   <module>rY      s    $ &  ' 5 ( 5 < # #DGT D%%**D,=,=,@,@A3@T 3@  B3@r!   