
    W                         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dl	m
Z
 ddlmZ dd	lmZ d
 Z G d de      Zy)z%API library for Authorized Orgs Desc.    )absolute_import)division)unicode_literals)
list_pager)util)waiter)log)	resourcesc                 F    |t        || |       |j                  |        yy)a  Sets specified field to the provided value and adds it to update mask.

  Args:
    field_name: The name of the field to set the value of.
    field_value: The value to set the field to. If it is None, the field will
      NOT be set.
    obj: The object on which the value is to be set.
    update_mask: The update mask to add this field to.

  Returns:
    True if the field was set and False otherwise.
  TF)setattrappend)
field_namefield_valueobjupdate_masks       Blib/googlecloudsdk/api_lib/accesscontextmanager/authorized_orgs.py_SetIfNotNoner      s*     C[)z"	    c                   4    e Zd ZdZddZd Zd	dZd Zd	dZy)
Clientz*High-level API client for Authorized Orgs.Nc                     |xs t        j                  |      | _        |xs | j                  j                  | _        y )N)version)r   	GetClientclientMESSAGES_MODULEmessages)selfr   r   r   s       r   __init__zClient.__init__4   s-    ;DNN7;DK; ; ;DMr   c                     | j                   j                  j                  | j                  j	                  |j                                     S )N)name)r   "accessPolicies_authorizedOrgsDescsGetr   ?AccesscontextmanagerAccessPoliciesAuthorizedOrgsDescsGetRequestRelativeName)r   authorized_orgs_desc_refs     r   r"   z
Client.Get8   sC    ;;99==	H	H)668 
I 
:; ;r   c                     | j                   j                  |j                               }t        j                  | j
                  j                  ||dd d      S )N)parentpageSizeauthorizedOrgsDescs)limitbatch_size_attribute
batch_sizefield)r   @AccesscontextmanagerAccessPoliciesAuthorizedOrgsDescsListRequestr$   r   YieldFromListr   r!   )r   
policy_refr*   reqs       r   ListzClient.List>   sW    
--
X
X&&( Y *C##66'#% %r   c                    | j                   }|j                  } |||j                         dj                  |            }| j                  j
                  j                  |      }t        j                  | j                  j
                  | j                  j                  |      }t        j                  j                  |j                  d      }	t        j                  ||	dj!                  |	j#                                     S )z5Applies a PATCH to the provided Authorized Orgs Desc.,)authorizedOrgsDescr    
updateMaskzaccesscontextmanager.operations)
collectionz Waiting for PATCH operation [{}])r   AAccesscontextmanagerAccessPoliciesAuthorizedOrgsDescsPatchRequestr$   joinr   r!   Patchr   OperationPoller
operationscore_resourcesREGISTRYParser    r   WaitForformatName)
r   r%   authorized_orgs_descr   mrequest_typerequest	operationpolleroperation_refs
             r   _ApplyPatchzClient._ApplyPatchI   s     	A	KK /%22488K(G
 >>DDWMI!!668N8N "F #++11#D 2 FM>>*11-2D2D2FGI Ir   c                     | j                   }|j                         }g }t        d|||       |st        j                  d       |S | j                  |||      S )aD  Patch an authorized orgs desc.

    Args:
      authorized_orgs_desc_ref: AuthorizedOrgsDesc, reference to the
        authorizedOrgsDesc to patch
      orgs: list of str, the names of orgs ( 'organizations/...') or None if not
        updating.

    Returns:
      AuthorizedOrgsDesc, the updated Authorized Orgs Desc.
    orgszHThe update specified results in an identical resource. Skipping request.)r   AuthorizedOrgsDescr   r	   warningrJ   )r   r%   rL   rD   rC   r   s         r   r:   zClient.Patch^   sh     	A//1K&$ 4kB 	kk
T "!46J') )r   )NNv1)N)	__name__
__module____qualname____doc__r   r"   r2   rJ   r:    r   r   r   r   1   s    2<;	%I*)r   r   N)rS   
__future__r   r   r   apitools.base.pyr   +googlecloudsdk.api_lib.accesscontextmanagerr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer	   r
   r=   r   objectr   rT   r   r   <module>r[      s5    , &  ' ' < . # ;(G)V G)r   