
    #                     ^    S 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.    N)
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   r0   !BaseClient.DefineGet.<locals>.GetD   s5     *"9"9";<c\\c""r   r0   Nsetattrtypes
MethodType)r&   r0   s     r   	DefineGetBaseClient.DefineGetB   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.
r-   )r#   r/   r   Deleter1   s      r   r=   'BaseClient.DefineDelete.<locals>.DeleteW   s5     Z%<%<%>?c\\  %%r   r=   Nr5   )r&   r=   s     r   DefineDeleteBaseClient.DefineDeleteU   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.
)filterr.   )rC   parentorderBypageSize)limitbatch_size_attribute
batch_sizefield)r!   r   YieldFromListr   )	r&   parent_namefiltersrG   	page_sizesort_byr3   
field_nameis_operationss	          r   List#BaseClient.DefineList.<locals>.Listp   sb     
wA w(/   1 %%
,,
) r   rR   )NNNNr5   )r&   rP   rQ   rR   s    `` r   
DefineListBaseClient.DefineListh   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.
)r.   
updateMask)r"   r.   r6   r   Patch)r&   updating_objectupdate_maskr3   update_field_names       r   Update'BaseClient.DefineUpdate.<locals>.Update   sG     O$8$8*5  7cc$o6\\$$r   r]   Nr5   )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$   r/   r   GetIamPolicyr1   s      r   re   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.
)policyrX   )apigatewaySetIamPolicyRequestrd   )r   ApigatewaySetIamPolicyRequestr%   r/   r   SetIamPolicy)r&   r2   rh   r[   policy_requestr3   s         r   rk   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)re   r   AddBindingToIamPolicyr   ApigatewayBindingrk   r&   r2   memberrolerh   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
ro   )re   r   RemoveBindingFromIamPolicyrk   rr   s        r   RemoveIamPolicyBindingCBaseClient.DefineIamPolicyFunctions.<locals>.RemoveIamPolicyBinding   s7       ,f))&$?z?CCr   re   rk   ru   ry   r_   r5   )r&   re   rk   ru   ry   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)   r9   r?   rT   r`   r{   __static_attributes__ r   r   r   r   #   s%    &086&<&'8R<6K'r   r   )v1F)r   )r   r7   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.command_lib.iamr   r	   r   objectr   r   r   r   <module>r      s2     C  ' , 3H7T' T'r   