
                         z    d 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	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zy)z1Utilities for manipulating organization policies.    )absolute_import)division)unicode_literals)serviceorganizationfolderprojectc                 b    | j                   rt        }|S | j                  rt        }|S t        }|S )zReturns the resource type from the user-specified arguments.

  Args:
    args: argparse.Namespace, An object that contains the values for the
      arguments specified in the Args method.
  )r   ORGANIZATIONr   FOLDERPROJECTargsresource_types     =lib/googlecloudsdk/api_lib/resource_manager/settings/utils.pyComputeResourceTyper      s=     
 M 
 {{M 
 M	    c                 \   t        j                         j                  |||      }| t        k(  r't        j                         j	                  ||      }|S | t
        k(  r't        j                         j                  ||      }|S t        j                         j                  ||      }|S )a  Returns the Setting from the user-specified arguments.

  Args:
    resource_type: A String object that contains the resource type
    name: The resource name of the setting and has the following syntax:
      [organizations|folders|projects]/{resource_id}/settings/{setting_name}.
    local_value: The configured value of the setting at the given parent
      resource
    etag: A fingerprint used for optimistic concurrency.
  )namevalueetag)r   setting)settings_serviceResourceSettingsMessagesSettingr   5CloudresourcemanagerOrganizationsSettingsPatchRequestr   /CloudresourcemanagerFoldersSettingsPatchRequest0CloudresourcemanagerProjectsSettingsPatchRequest)r   r   local_valuer   r   requests         r   GetPatchRequestFromResourceTyper!   -   s     55 G{  / 
 l"77 ;;7 < $  
. 77 557 6 $  
.	 77 667 7 $  
.r   c                 V   t        j                         }| j                  r*|r|j                  |      }|S |j	                  |      }|S | j
                  r*|r|j                  |      }|S |j                  |      }|S |r|j                  |      }|S |j                  |      }|S )aO  Returns the get_request from the user-specified arguments.

  Args:
    args: argparse.Namespace, An object that contains the values for the
      arguments specified in the Args method.
    setting_name: setting name such as `settings/iam-projectCreatorRoles`
    is_effective: indicate if it is requesting for an effective setting
  r   )
r   r   r   <CloudresourcemanagerOrganizationsEffectiveSettingsGetRequest3CloudresourcemanagerOrganizationsSettingsGetRequestr   6CloudresourcemanagerFoldersEffectiveSettingsGetRequest-CloudresourcemanagerFoldersSettingsGetRequest7CloudresourcemanagerProjectsEffectiveSettingsGetRequest.CloudresourcemanagerProjectsSettingsGetRequest)r   setting_nameis_effectivemessagesget_requests        r   GetDescribeRequestFromArgsr.   M   s    668(	

O
O P  D 
7 
F
F G  8 
/ {{

I
I J  * 
 JJ K k 
 

J
J K   
	 KK L k 
r   c                     t        j                         }| j                  r|j                  |      }|S | j                  r|j                  |      }|S |j                  |      }|S )a   Returns the get_request from the user-specified arguments.

  Args:
    args: argparse.Namespace, An object that contains the values for the
      arguments specified in the Args method.
    parent_resource: resource location such as `organizations/123`
  )parent)r   r   r   4CloudresourcemanagerOrganizationsSettingsListRequestr   .CloudresourcemanagerFoldersSettingsListRequest/CloudresourcemanagerProjectsSettingsListRequest)r   parent_resourcer,   r-   s       r   GetListRequestFromArgsr5      s     668(	OO P  K 
 {{II J  K 
 JJ K  K 
r   c                     t        j                         }| j                  r|j                  |      }|S | j                  r|j                  |      }|S |j                  |      }|S )a  Returns the get_request from the user-specified arguments.

  Args:
    args: argparse.Namespace, An object that contains the values for the
      arguments specified in the Args method.
    setting_name: setting name such as `settings/iam-projectCreatorRoles`
  r#   )r   r   r   5CloudresourcemanagerOrganizationsSettingsClearRequestr   /CloudresourcemanagerFoldersSettingsClearRequest0CloudresourcemanagerProjectsSettingsClearRequest)r   r*   r,   r-   s       r   GetDeleteValueRequestFromArgsr:      s     668(	FF 	G 	
  
 {{JJ K K 
	 KK L K 
r   c                 .    t        |       }t        |      S zReturns the service from the user-specified arguments.

  Args:
    args: argparse.Namespace, An object that contains the values for the
      arguments specified in the Args method.
  )r   GetServiceFromResourceTyper   s     r   GetServiceFromArgsr>      s     &d+-	#M	22r   c                     | t         k(  rt        j                         }|S | t        k(  rt        j                         }|S t        j
                         }|S zReturns the service from the resource type input.

  Args:
    resource_type: A String object that contains the resource type
  )r   r   OrganizationsSettingsServicer   FoldersSettingsServiceProjectsSettingsServicer   r   s     r   r=   r=      sU     l";;=G 
. 557G 
. 668G	.r   c                 .    t        |       }t        |      S r<   )r   #GetEffectiveServiceFromResourceTyper   s     r   GetEffectiveServiceFromArgsrG      s     &d+-	,]	;;r   c                     | t         k(  rt        j                         }|S | t        k(  rt        j                         }|S t        j
                         }|S r@   )r   r   %OrganizationsEffectiveSettingsServicer   FoldersEffectiveSettingsService ProjectsEffectiveSettingsServicerD   s     r   rF   rF      sU     l"DDFG 
. >>@G 
. ??AG	.r   N)__doc__
__future__r   r   r   0googlecloudsdk.api_lib.resource_manager.settingsr   r   r   r   r   r   r!   r.   r5   r:   r>   r=   rG   rF    r   r   <module>rP      sT    8 &  ' X	
"@0f0:
3"
<r   