
    h                     f    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 Zd Z	d	 Z
d
edefdZy)zUtilities for bms commands.    )absolute_import)division)unicode_literals)
properties)	resourcesc                       y)zDReturns 'global' to be used as a fallthrough hook in resources.yaml.global r
       *lib/googlecloudsdk/command_lib/bms/util.pyDefaultToGlobalr      s    	r   c                 
   | j                         }|j                         }|j                  d|j                               }t        j                  j                  |d   ||j                         dd      j                         S )z<Returns the full GCP name of the NFS allowed client network.znetwork-project-idnetwork)
projectsIdlocationsIdz-baremetalsolution.projects.locations.networks)params
collection)ParentgetNamer   REGISTRYParseRelativeName)nfs_share_resourceallowed_client_dict
nfs_regionnfs_projectnetwork_project_ids        r   NFSNetworkFullNamer      s     "((**!!#+*../C/:/?/?/AC				!	!)$*#* A 
" 
B CO,.Qr   c                 L   t               }|D ]%  }t        | |      }|j                  ||d   f       ' g }|D ]A  }|j                  |j                  f}||v r|j                  |       1|j                  |       C |D ]"  }	t        dj                  |	d   |	d                |S )zORemoves the allowed clients specified by remove_key_dicts from allowed_clients.)r   r   cidrzECannot find an existing allowed client for network [{}] and CIDR [{}]r      )	setr   addr   allowedClientsCidrremoveappendLookupErrorformat)
r   allowed_clientsremove_key_dictskeys_to_removekey_dictkey_network_full_nameoutallowed_clientcurr_keykeys
             r   RemoveAllowedClientsr3   .   s     5."h.-$ -x/?@A # 	#'n&&(I(IJH>!H%	jj  ( c
 ,,2F3q636q6-;< <  
*r   regionreturnc                     | | j                         S t        j                  j                  j                  j                  d      }dj                  |      S )zIReturns projects/$project/location/$location parent path based on region.T)requiredzprojects/{}/locations/global)r   r   VALUEScoreprojectGetr)   )r4   r:   s     r   FixParentPathWithGlobalRegionr<   G   sM      ""**...='	'	.	.w	77r   N)__doc__
__future__r   r   r   googlecloudsdk.corer   r   r   r   r3   strr<   r
   r   r   <module>rA      s<    " &  ' * )
Q 28# 8# 8r   