
    }S                     2   S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  S r    S&S	 jrS
 rS r    S'S jrS rS(S jr S)S jrS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S*S jr"S r#S+S  jr$S! r%S" r&S# r'S$ r(S% r)g),z Design Center Command Lib Flags.    N)arg_parsers)base)concepts)concept_parsers)yamlc                  J    [         R                  " SS[         R                  S9$ )Nzdesigncenter.projectsproject)resource_name
projectsId)r   ResourceSpec DEFAULT_PROJECT_ATTRIBUTE_CONFIG     5lib/googlecloudsdk/command_lib/design_center/flags.pyGetProjectResourceSpecr      s$    			::
 r   c                     U=(       d    Sn[         R                  R                  SR                  U(       a  SOSU 5      [	        5       UUS9$ )z5Constructs and returns the Project Resource Argument.zProject ID.{}{} --required)r   ConceptParserForResourceformatr   arg_name	help_text
positionalr   s       r   GetProjectResourceArgr   $   sJ     (=)		&	&	2	2mm*B$9	 
3 
 r   c                  ,    [         R                  " SSS9$ )Nlocationz&The Cloud location for the {resource}.namer   r    ResourceParameterAttributeConfigr   r   r   LocationAttributeConfigr&   4   s    		2	28
 r   c                  \    [         R                  " SS[        5       [         R                  S9$ )Nzdesigncenter.projects.locationsr!   )r
   locationsIdr   )r   r   r&   r   r   r   r   GetLocationResourceSpecr)   ;   s*    			')+::	
 r   c                     U=(       d    Sn[         R                  R                  SR                  U(       a  SOSU 5      [	        5       UUS9$ )z6Constructs and returns the Location Resource Argument.z	Location.r   r   r   r   )r   r   r   r   r)   r   s       r   GetLocationResourceArgr+   D   sJ     &;)		&	&	2	2mm*B$9	 
3 
 r   c                 ,    [         R                  " U US9$ )z9Helper function for constructing ResourceAttributeConfig.r"   r$   r   r   s     r   SpaceResourceAttributeConfigr.   U   s    		2	2
 r   c                 p    [         R                  " SS[        X5      [         R                  [	        5       S9$ )z<Constructs and returns the Resource specification for Space.z&designcenter.projects.locations.spacesspace)r
   spacesIdr   r(   )r   r   r.   r   r&   r-   s     r   GetSpaceResourceSpecr2   ]   s2    			.+H@::)+
 r   c                     U=(       d    Sn[         R                  R                  SR                  U(       a  SOSU 5      [	        X5      UUS9$ )z6Constructs and returns the Space ID Resource Argument.zThe Space ID.r   r   r   r   )r   r   r   r   r2   r   s       r   GetSpaceResourceArgr4   h   sL     *?)		&	&	2	2mm*B$98/	 
3 
 r   c                  ,    [         R                  " SSS9$ )z,Creates an attribute config for the catalog.catalogzThe ID of the catalog.r"   r$   r   r   r   CatalogAttributeConfigr7   y   s    		2	2(
 r   c                  ,    [         R                  " SSS9$ )z-Creates an attribute config for the template.templatezThe ID of the template.r"   r$   r   r   r   CatalogTemplateAttributeConfigr:      s    		2	2)
 r   c                      [         R                  " SS[         R                  " SSS9[        5       [	        5       [        SS5      [        5       [         R                  S9$ )z)Creates the resource spec for a revision.zCdesigncenter.projects.locations.spaces.catalogs.templates.revisionsrevisionz!The ID of the revision to create.r"   r0   The ID of the space.)r
   revisionsIdtemplatesId
catalogsIdr1   r(   r   )r   r   r%   r:   r7   r.   r&   r   r   r   r   &GetCatalogTemplateRevisionResourceSpecrA      sW    			K;;%H 12')+G5KL)+::
 r   c                 4    [        SS9R                  U 5        g )NT)r   )r+   AddToParserparsers    r   AddDescribeLocationFlagsrF      s    D)55f=r   c                 6    [        5       R                  U 5        g Nr4   rC   rD   s    r   AddGetIamPolicyFlagsrJ          ##F+r   c                 6    [        5       R                  U 5        g rH   rI   rD   s    r   AddSetIamPolicyFlagsrM      rK   r   c                 6    [        5       R                  U 5        g rH   rI   rD   s    r   AddTestIamPermissionsFlagsrO      rK   r   c                    [         R                  R                  S[        5       SSS9R	                  U 5        U R                  SSS9  U R                  SSS9nUR                  S	S9nUR                  S
SSS9  UR                  SSSS9  UR                  SSSS9  UR                  SS9nUR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  SS9nUR                  SSSS9  UR                  S S!SS9  U R                  S"[        R                  " 5       S#S$9  g%)&zAdds all flags for the create revision command.

Args:
  parser: An argparse.ArgumentParser-like object. It is mocked out in tests.
r<   zThe revision to create.Tr   z--descriptionzA description for the revision.helpmutexr   z#Flags for Developer Connect source.z--developer-connect-repozThe Developer Connect repository to use as a source. Example: `projects/my-project/locations/us-central1/connections/my-connection/gitRepositoryLinks/my-repo`rR   r   z--developer-connect-repo-refzThe Git ref (branch or tag) within the repository to use. Example: `"refs/tags/v1.0.0"` or `"refs/heads/main"` or `"refs/commits/269b518b99d06b31ff938a2d182e75f5e41941c7"`.z--developer-connect-repo-dirzKThe directory within the repository to use. Example: `"modules/my-product"`zFlags for Git source.z--git-source-repozXGit repository for Git source. Example: `GoogleCloudPlatform/terraform-google-cloud-run`z--git-source-ref-tagz5Git reference tag for Git source. Example: `"v1.0.0"`z--git-source-dirzVGit directory for Git source. Example: `"modules/my-product"`. This field is optional.Fz&--application-template-revision-sourcezApplication template revision to use as source. Example: `projects/my-project/locations/us-central1/spaces/my-space/catalogs/my-catalog/templates/my-template/revisions/r1`z--gcs-source-urizKGoogle Cloud Storage URI for source. Example: `gs://my-bucket/my-template`.zFlags for OCI Repo source.z--oci-repo-urizfOCI Repo URI for OCI Repo source. Example: `oci://us-west1-docker.pkg.dev/my-project/my-repo/my-chart`z--oci-repo-versionzQOCI Repo version for OCI Repo source. Example: `"1.0.0"`. This field is optional.z
--metadataz_Path to a local YAML file containing the template metadata. Example: `"path/to/metadata.yaml"`.typerR   N)	r   r   r   rA   rC   add_argument	add_groupr   YAMLFileContents)rE   source_groupdev_connect_groupgit_source_groupoci_repo_groups        r   %AddCreateCatalogTemplateRevisionFlagsr_      s#    ++,.	 , 
 Ko,MN!!t!<,",,0 -     (  !    $G  !    $$  !  "++" ,  :	    B   
 %     .@    +     ))/K)L.I        	'')(	  r   c                     [        SSS9R                  U 5        U R                  SSS9nUR                  SSS9  UR                  S	S
S9  U R                  SSS9  [        R
                  R                  U 5        g)zAdds all flags for the register with apphub command.

Args:
  parser: An argparse.ArgumentParser-like object. It is mocked out in tests.
r0   r=   r-   TrS   z--apphub-application-urizAppHub application URI to register the deployed resource using application template as source in the space. Format: `projects/{projectId}/locations/{locationId}/applications/{applicationId}rQ   z--adc-application-uria  The Application Design Center application URI to register the deployed resources with the AppHub application using Application Design Center application as source in the space. Format: `projects/{projectId}/locations/{locationId}/spaces/{spaceId}/applications/{applicationId}`z--tfstate-locationz=Path to the Terraform state file (e.g., `terraform.tfstate`).N)r4   rC   rY   rX   r   
ASYNC_FLAGrE   r[   s     r   AddRegisterWithApphubFlagsrc      s     & K!!t!<,      	 	J   //f%r   c                 d    U R                  SSS9nUR                  SSS9  UR                  SSS9  g)	zAdds flags for specifying the Terraform state source.

Args:
  parser: An argparse.ArgumentParser-like object. It is mocked out in tests.
TrS   z--terraform-statezhThe Terraform state (tfstate) content as a raw JSON string. Example: '{"version":4, "resources": [...]}'rQ   z--tfstate-signed-gcs-urizA securely signed Cloud Storage URI pointing to the tfstate file. Example: `https://storage.googleapis.com/my-bucket/tfstate.json?x-goog-signature=...`N)rY   rX   )rE   tfstate_source_groups     r   AddTfStateSourceFlagsrf   E  sR      ))t)D##< $  ## # $ r   c                 &    U R                  SSSS9  g)zsAdds the service account flag.

Args:
  parser: An argparse.ArgumentParser-like object. It is mocked out in tests.
--service-accountzThe email address of the service account to use for this operation. Format: `projects/{PROJECT}/serviceAccounts/{EMAIL_ADDRESS}`FrU   N)rX   rD   s    r   AddServiceAccountFlagri   ]  s%     	J   r   c                     [         R                  R                  S[        5       SSS9R	                  U 5        [        U 5        [        U 5        [        R                  R	                  U 5        g)zAdds flags for the register deployed application command.

Args:
  parser: An argparse.ArgumentParser-like object. It is mocked out in tests.
APPLICATIONz<The application with which the resources will be registered.Tr   N)	r   r   r   GetApplicationResourceSpecrC   rf   ri   r   ra   rD   s    r   #AddRegisterDeployedApplicationFlagsrm   m  sZ     ++ "D	 ,  ![(//f%r   c                     [        SSS9R                  U 5        U R                  SSSS9  [        U 5        [	        U 5        [
        R                  R                  U 5        g)	zAdds flags for the register deployed resources command.

Args:
  parser: An argparse.ArgumentParser-like object. It is mocked out in tests.
r0   zThe parent space.r-   z--apphub-applicationzpThe name of the AppHub Application. Format: `projects/{project}/locations/{location}/applications/{application}`TrU   N)r4   rC   rX   rf   ri   r   ra   rD   s    r   !AddRegisterDeployedResourcesFlagsro   }  sc     # KR    //f%r   c                     [         R                  R                  U 5        [        SS5      R                  U 5        U R	                  S[
        R                  " 5       SSS9  U R	                  SSS	S
S9  g)zAdds all flags for the infer connections command.

Args:
  parser: An argparse.ArgumentParser-like object. It is mocked out in tests.
r0   zThe space ID.z --catalog-template-revision-urisCATALOG_TEMPLATE_REVISION_URIag  A comma-separated list of catalog template revision URIs to infer connections for. If not provided, the system infers connections for the latest revisions of all catalog templates in all the catalogs present in the space. Format: `projects/{projectId}/locations/{locationId}/spaces/{spaceId}/catalogs/{catalogId}/templates/{templateId}/revisions/{revisionId}`)rW   metavarrR   z--use-gemini
store_trueFz Use Gemini to infer connections.actiondefaultrR   N)r   ra   rC   r4   rX   r   ArgListrD   s    r   AddInferConnectionsFlagsrx     sw     //f%g/;;FC( -P   	-	  r   c           	          [         R                  " SS[         R                  " U SS9[        SS5      [	        5       [         R
                  S9$ )zKConstructs and returns the Resource specification for Application Template.z;designcenter.projects.locations.spaces.applicationTemplatesapplication_templatez#The ID of the application template.r"   r0   r=   )r
   applicationTemplatesIdr1   r(   r   )r   r   r%   r.   r&   r   r   s    r   "GetApplicationTemplateResourceSpecr}     sK    			C*%FF#H ,G5KL)+::	
 	r   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)zDAdds the Application Template resource argument to the given parser.APPLICATION_TEMPLATEz The application template {} IaC.Tr   N)r   r   r   r}   r   rC   rE   verbs     r   !AddApplicationTemplateResourceArgr     sA    ++(*(//5	 ,  ![(r   c                     [         R                  " SS[         R                  " U SS9[         R                  [	        5       [        SS5      S9$ )zBConstructs and returns the Resource specification for Application.z3designcenter.projects.locations.spaces.applicationsapplicationzThe ID of the application.r"   r0   r=   )r
   applicationsIdr   r(   r1   )r   r   r%   r   r&   r.   r|   s    r   rl   rl     sK    			;!>>#? ::)++G5KL	
 	r   c                     [         R                  R                  S[        5       SR	                  U5      SS9R                  U 5        g)z;Adds the Application resource argument to the given parser.rk   zThe application {} IaC.Tr   N)r   r   r   rl   r   rC   r   s     r   AddApplicationResourceArgr     sA    ++ "&&t,	 ,  ![(r   c                     U R                  SS9nUR                  SSS9  UR                  S[        R                  " 5       SS9  U R                  S	S
SSS9  U R                  SS
SSS9  g)z7Adds flags for import-iac commands to the given parser.Tr   z	--gcs-urizGThe Cloud Storage URI of the Terraform code (e.g., gs://my-bucket/iac).rQ   z--iac-module-from-filezGPath to a local YAML or JSON file containing the IaC module definition.rV   z--allow-partial-importrs   FzCIf set, partially import valid IaC changes and ignore invalid ones.rt   z--validate-iacz/Validate the IaC without performing the import.N)add_mutually_exclusive_grouprX   r   FileContentsrb   s     r   AddImportIacFlagsr     s    44d4C,*  
 ##%   		   	<	  r   c                    U R                  SSSSS9  U R                  S[        R                  " SS5      [        R                  " S	5      S
9  U R                  S[        R                  " S5      S9  U R                  SSSS9  g)zAdds all flags for the deploy application command.

Args:
  parser: An argparse.ArgumentParser-like object. It is mocked out in tests.
z	--replacers   Fz|Flag to update the existing deployment. If not set or false, deploy will fail if application state is in the DEPLOYED state.rt   --worker-pool0projects/[^/]+/locations/[^/]+/workerPools/[^/]+yThe worker pool resource name must be in the format: `projects/{project}/locations/{location}/workerPools/{workerPoolId}`            The user-specified Worker Pool resource in which the Cloud Build job
          will execute. Format:
          projects/{project}/locations/{location}/workerPools/{workerPoolId}
          If this flag is omitted, the worker pool already defined on the
          application will be used. If no worker pool is defined on the
          application, the default Cloud Build worker pool is used. The
          worker pool must exist in the same region as the application.      rV   rh   ac            The service account to use for this deployment.

          * If provided, this service account will be used to execute the
            deployment process, taking precedence over any service_account
            specified on the Application resource.
          * The caller must have the "iam.serviceAccounts.actAs" permission on
            this service account.
          * If this field is omitted, the system will use the "service_account"
            defined within the Application resource.
          * If this field is omitted with --create-sa flag, the system will create a new and unique service_account
            and use it for the deployment.
          * We recommend that you provide a service account here or on the
            Application resource. If you don't provide a service account, the
            deployment will fail.
          * If the `--create-sa` flag is also provided, this value is the ID of
            a new service account to be created (e.g., `my-new-sa`).

          Format: `projects/{PROJECT}/serviceAccounts/{EMAIL_ADDRESS}` (when not
          using `--create-sa`)
          rQ   --create-saz0Create a new service account for the deployment.ru   rR   NrX   r   RegexpValidatortextwrapdedentrD   s    r   AddDeployApplicationFlagsr     s     	F   	&&
=Q
 ?? 
   $ 	??    0 	=  r   c                      [         R                  " U 5      $ ! [         a*  n[        R                  " SR                  U5      5      eSnAff = f)z5Parses YAML or JSON file contents into a Python dict.z#Failed to parse IaC module file: {}N)r   load	Exceptionr   ArgumentTypeErrorr   )file_contentses     r   ParseIacModuleFiler   =  sG    999]##	 9

'
'-44Q79 99s    
A%AAc                     U R                  S[        R                  " SS5      [        R                  " S5      S9  U R                  S[        R                  " S5      S9  U R                  S	S
SS9  g)zAdds all flags for the preview application command.

Args:
  parser: An argparse.ArgumentParser-like object. It is mocked out in tests.
r   r   r   r   rV   rh   aW            The service account to use for this preview.

          * If provided, this service account will be used to execute the
            preview process, taking precedence over any service_account
            specified on the Application resource.
          * The caller must have the "iam.serviceAccounts.actAs" permission on
            this service account.
          * If this field is omitted, the system will use the "service_account"
            defined within the Application resource.
          * If this field is omitted with --create-sa flag, the system will create a new and unique service_account
            and use it for the preview.
          * We recommend that you provide a service account here or on the
            Application resource. If you don't provide a service account, the
            preview will fail.
          * If the `--create-sa` flag is also provided, this value is the ID of
            a new service account to be created (e.g., `my-new-sa`).

          Format: `projects/{PROJECT}/serviceAccounts/{EMAIL_ADDRESS}` (when not
          using `--create-sa`)
          rQ   r   rs   z-Create a new service account for the preview.r   Nr   rD   s    r   AddPreviewApplicationFlagsr   F  s     	&&
=Q
 ?? 
   $ 	??    0 	:  r   )r	   NFT)r!   NFT)r0   N)r0   NTT)application_template_id)r   )*__doc__rer   googlecloudsdk.callioper   r    googlecloudsdk.calliope.conceptsr   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   r   r&   r)   r+   r.   r2   r4   r7   r:   rA   rF   rJ   rM   rO   r_   rc   rf   ri   rm   ro   rx   r}   r   rl   r   r   r   r   r   r   r   r   <module>r      s    ' 
  / ( 5 D $ 	  	" AE" >,,,tn"&J0 & &.<)):=@94r   