
    {#                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr  SS	 jrSS
 jr " S S\5      rg)z<Client for interaction with Gateway CRUD on API Gateway API.    )absolute_import)division)unicode_literalsN)
list_pager)apis)iam_utilc                 ,    [         R                  " SXS9$ )N
apigateway)no_http)r   GetClientInstance)versionr   s     .lib/googlecloudsdk/api_lib/api_gateway/base.pyr   r      s    			g	GG    c                 0    [         R                  " SU 5      $ )Nr
   )r   GetMessagesModule)r   s    r   r   r   "   s    			g	66r   c                   D    \ rS rSrSrSS jrS rS rSS jrS r	S	 r
S
rg)
BaseClient&   zBase for building API Clients.Nc                 T   U=(       d
    [        5       U l        U R                  R                  U l        [	        U R                  US 5      U l        [	        U R                  US-   S 5      U l        [	        U R                  US-   S 5      U l        [	        U R                  US-   S 5      U l        [	        U R                  US-   S 5      U l	        [	        U R                  US-   S 5      U l
        [	        U R                  US-   S 5      U l        [	        U R                  US-   S 5      U l        g )N
GetRequestCreateRequestListRequestPatchRequestDeleteRequestGetIamPolicyRequestSetIamPolicyRequest)r   clientMESSAGES_MODULEmessagesgetattrserviceget_requestcreate_requestlist_requestpatch_requestdelete_requestget_iam_policy_requestset_iam_policy_request)selfr   message_baseservice_names       r   __init__BaseClient.__init__)   s   /-/DKKK//DM4;;d;DL t}}l\.I4PD!$--"."@"&(D   ,} < $&D !!-!>!%'D "$--"."@"&(D
 #*$--*69N*N*.#0D #*$--*69N*N*.#0Dr   c                 L    S n[        U S[        R                  " X5      5        g)z0Defines basic get function on an assigned class.c                 r    U R                  UR                  5       S9nU R                  R                  U5      $ )zGets an object.

Args:
  self: The self of the class this is set on.
  object_ref: Resource, resource reference for object to get.

Returns:
  The object requested.
name)r"   RelativeNamer!   Getr)   
object_refreqs      r   r3   !BaseClient.DefineGet.<locals>.GetG   s5     *"9"9";<c\\c""r   r3   Nsetattrtypes
MethodType)r)   r3   s     r   	DefineGetBaseClient.DefineGetE   s     # D%))#45r   c                 L    S n[        U S[        R                  " X5      5        g)z3Defines basic delete function on an assigned class.c                 r    U R                  UR                  5       S9nU R                  R                  U5      $ )zDeletes a given object given an object name.

Args:
  self: The self of the class this is set on.
  object_ref: Resource, resource reference for object to delete.

Returns:
  Long running operation.
r0   )r&   r2   r!   Deleter4   s      r   r@   'BaseClient.DefineDelete.<locals>.DeleteZ   s5     Z%<%<%>?c\\  %%r   r@   Nr8   )r)   r@   s     r   DefineDeleteBaseClient.DefineDeleteX   s     & D(E,,V:;r   c                 `   ^^   SUU4S jjn[        U S[        R                  " X05      5        g)zDefines the List functionality on the calling class.

Args:
  field_name: The name of the field on the list response to list
  is_operations: Operations have a slightly altered message structure, set
                 to true in operations client
Nc           	         > T(       a  U R                  X!S9nOU R                  X!US9n[        R                  " U R                  UUSUTS9$ )a  Lists the objects under a given parent.

Args:
  self: the self object function will be bound to.
  parent_name: Resource name of the parent to list under.
  filters: Filters to be applied to results (optional).
  limit: Limit to the number of results per page (optional).
  page_size: the number of results per page (optional).
  sort_by: Instructions about how to sort the results (optional).

Returns:
  List Pager.
)filterr1   )rF   parentorderBypageSize)limitbatch_size_attribute
batch_sizefield)r$   r   YieldFromListr!   )	r)   parent_namefiltersrJ   	page_sizesort_byr6   
field_nameis_operationss	          r   List#BaseClient.DefineList.<locals>.Lists   sb     
wA w(/   1 %%
,,
) r   rU   )NNNNr8   )r)   rS   rT   rU   s    `` r   
DefineListBaseClient.DefineListk   s0     EI > D&%**467r   c                 X   ^ SU4S jjn[        U S[        R                  " X 5      5        g)zDefines the Update functionality on the calling class.

Args:
  update_field_name: the field on the patch_request to assign updated object
                     to
Nc                    > U R                  UR                  US9n[        UTU5        U R                  R	                  U5      $ )zUpdates an object.

Args:
  self: The self of the class this is set on.
  updating_object: Object which is being updated.
  update_mask: A string saying which fields have been updated.

Returns:
  Long running operation.
)r1   
updateMask)r%   r1   r9   r!   Patch)r)   updating_objectupdate_maskr6   update_field_names       r   Update'BaseClient.DefineUpdate.<locals>.Update   sG     O$8$8*5  7cc$o6\\$$r   r`   Nr8   )r)   r_   r`   s    ` r   DefineUpdateBaseClient.DefineUpdate   s!    %$ D(E,,V:;r   c                 *   S nS
S jnS nS n[        U S[        R                  " X5      5        [        U S[        R                  " X 5      5        [        U S[        R                  " UU 5      5        [        U S	[        R                  " X@5      5        g)z:Defines all of the IAM functionality on the calling class.c                 r    U R                  UR                  5       S9nU R                  R                  U5      $ )zGets an IAM Policy on an object.

Args:
  self: The self of the class this is set on.
  object_ref: Resource, reference for object IAM policy belongs to.

Returns:
  The IAM policy.
)resource)r'   r2   r!   GetIamPolicyr4   s      r   rh   9BaseClient.DefineIamPolicyFunctions.<locals>.GetIamPolicy   s5     ''1H1H1J'Kc\\&&s++r   Nc                     U R                   R                  UUS9nU R                  UUR                  5       S9nU R                  R                  U5      $ )a  Sets an IAM Policy on an object.

Args:
  self: The self of the class this is set on.
  object_ref: Resource, reference for object IAM policy belongs to.
  policy: the policy to be set.
  update_mask: fields being update on the IAM policy.

Returns:
  The IAM policy.
)policyr[   )apigatewaySetIamPolicyRequestrg   )r   ApigatewaySetIamPolicyRequestr(   r2   r!   SetIamPolicy)r)   r5   rk   r^   policy_requestr6   s         r   rn   9BaseClient.DefineIamPolicyFunctions.<locals>.SetIamPolicy   sa     }}BB  C "n ''(6**, ( .c \\&&s++r   c                     U R                  U5      n[        R                  " U R                  R                  UX#5        U R                  XS5      $ )a"  Adds an IAM role to a member on an object.

Args:
  self: The self of the class this is set on.
  object_ref: Resource, reference for object IAM policy belongs to.
  member: the member the binding is being added to.
  role: the role which to bind to the member.

Returns:
  The IAM policy.
bindings,etag)rh   r   AddBindingToIamPolicyr   ApigatewayBindingrn   r)   r5   memberrolerk   s        r   AddIamPolicyBinding@BaseClient.DefineIamPolicyFunctions.<locals>.AddIamPolicyBinding   sF       ,f$$T]]%D%Df%+3z?CCr   c                 v    U R                  U5      n[        R                  " XBU5        U R                  XS5      $ )a&  Adds an IAM role for a member on an object.

Args:
  self: The self of the class this is set on
  object_ref: Resource, reference for object IAM policy belongs to
  member: the member the binding is removed for
  role: the role which is being removed from the member

Returns:
  The IAM policy
rr   )rh   r   RemoveBindingFromIamPolicyrn   ru   s        r   RemoveIamPolicyBindingCBaseClient.DefineIamPolicyFunctions.<locals>.RemoveIamPolicyBinding   s7       ,f))&$?z?CCr   rh   rn   rx   r|   rb   r8   )r)   rh   rn   rx   r|   s        r   DefineIamPolicyFunctions#BaseClient.DefineIamPolicyFunctions   s    ,,(D"D" D.%"2"2<"FGD.%"2"2<"FGD')9)9:M:>*@ AD*E,<,<-& 'r   )
r   r#   r&   r'   r"   r$   r   r%   r!   r(   )NNN)F)__name__
__module____qualname____firstlineno____doc__r,   r<   rB   rW   rc   r~   __static_attributes__ r   r   r   r   &   s%    &086&<&'8R<6K'r   r   )v1F)r   )r   
__future__r   r   r   r:   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.command_lib.iamr   r   r   objectr   r   r   r   <module>r      s9     C &  '  ' , 3H7T' T'r   