
    7                     "   S 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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'S jr S r!S(S jr"S  r#S! r$S" r%g))z Design Center Command Lib Flags.    )absolute_import)division)unicode_literals)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   Nc                     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   SpaceResourceAttributeConfigr1   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   r1   r   r)   r0   s     r   GetSpaceResourceSpecr5   ]   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   r5   r   s       r   GetSpaceResourceArgr7   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   CatalogAttributeConfigr:   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%   r3   The ID of the space.)r   revisionsIdtemplatesId
catalogsIdr4   r+   r   )r   r   r(   r=   r:   r1   r)   r   r   r   r   &GetCatalogTemplateRevisionResourceSpecrD      sW    			K;;%H 12')+G5KL)+::
 r   c                 4    [        SS9R                  U 5        g )NT)r!   )r.   AddToParserparsers    r   AddDescribeLocationFlagsrI      s    D)55f=r   c                 6    [        5       R                  U 5        g Nr7   rF   rG   s    r   AddGetIamPolicyFlagsrM          ##F+r   c                 6    [        5       R                  U 5        g rK   rL   rG   s    r   AddSetIamPolicyFlagsrP      rN   r   c                 6    [        5       R                  U 5        g rK   rL   rG   s    r   AddTestIamPermissionsFlagsrR      rN   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`)rU   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"`.typerU   N)	r	   r   r   rD   rF   add_argument	add_groupr   YAMLFileContents)rH   source_groupdev_connect_groupgit_source_groupoci_repo_groups        r   %AddCreateCatalogTemplateRevisionFlagsra      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.
r3   r@   r0   TrV   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}rT   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)r7   rF   r[   rZ   r   
ASYNC_FLAGrH   r]   s     r   AddRegisterWithApphubFlagsre      s     & K!!t!<,      	 	J   //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.
r3   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}`)rY   metavarrU   z--use-gemini
store_trueFz Use Gemini to infer connections.actiondefaultrU   N)r   rc   rF   r7   rZ   r   ArgListrG   s    r   AddInferConnectionsFlagsrn   E  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%   r3   r@   )r   applicationTemplatesIdr4   r+   r   )r   r   r(   r1   r)   r   r   s    r   "GetApplicationTemplateResourceSpecrs   a  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   rs   r   rF   rH   verbs     r   !AddApplicationTemplateResourceArgrx   o  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%   r3   r@   )r   applicationsIdr   r+   r4   )r   r   r(   r   r)   r1   rr   s    r   GetApplicationResourceSpecr|   x  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.APPLICATIONzThe application {} IaC.Tr   N)r	   r   r   r|   r   rF   rv   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).rT   z--iac-module-from-filezGPath to a local YAML or JSON file containing the IaC module definition.rX   z--allow-partial-importri   FzCIf set, partially import valid IaC changes and ignore invalid ones.rj   z--validate-iacz/Validate the IaC without performing the import.N)add_mutually_exclusive_grouprZ   r   FileContentsrd   s     r   AddImportIacFlagsr     s    44d4C,*  
 ##%   		   	<	  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)r   NFT)r$   NFT)r3   N)r3   NTT)application_template_id)rz   )&__doc__
__future__r   r   r   googlecloudsdk.callioper   r    googlecloudsdk.calliope.conceptsr   (googlecloudsdk.command_lib.util.conceptsr	   googlecloudsdk.corer
   r   r"   r)   r,   r.   r1   r5   r7   r:   r=   rD   rI   rM   rP   rR   ra   re   rn   rs   rx   r|   r   r   r   r   r   r   <module>r      s    ' &  ' / ( 5 D $ 	  	" AE" >,,,tn"&J8)):9r   