<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import urllib <EOL> import gdata . apps . organization . data <EOL> import gdata . client <EOL> CUSTOMER_ID_URI_TEMPLATE = '<STR_LIT>' <EOL> ORGANIZATION_UNIT_URI_TEMPLATE = '<STR_LIT>' <EOL> ORGANIZATION_UNIT_FEED = '<STR_LIT>' <EOL> ORGANIZATION_USER_FEED = '<STR_LIT>' <EOL> class OrganizationUnitProvisioningClient ( gdata . client . GDClient ) : <EOL> """<STR_LIT>""" <EOL> host = '<STR_LIT>' <EOL> api_version = '<STR_LIT>' <EOL> auth_service = '<STR_LIT>' <EOL> auth_scopes = gdata . gauth . AUTH_SCOPES [ '<STR_LIT>' ] <EOL> ssl = True <EOL> def __init__ ( self , domain , auth_token = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> gdata . client . GDClient . __init__ ( self , auth_token = auth_token , ** kwargs ) <EOL> self . domain = domain <EOL> def make_organization_unit_provisioning_uri ( <EOL> self , feed_type , customer_id , org_unit_path_or_user_email = None , <EOL> params = None ) : <EOL> """<STR_LIT>""" <EOL> uri = ORGANIZATION_UNIT_URI_TEMPLATE % ( feed_type , self . api_version , <EOL> customer_id ) <EOL> if org_unit_path_or_user_email : <EOL> uri += '<STR_LIT:/>' + org_unit_path_or_user_email <EOL> if params : <EOL> uri += '<STR_LIT:?>' + urllib . urlencode ( params ) <EOL> return uri <EOL> MakeOrganizationUnitProvisioningUri = make_organization_unit_provisioning_uri <EOL> def make_organization_unit_orgunit_provisioning_uri ( self , customer_id , <EOL> org_unit_path = None , <EOL> params = None ) : <EOL> """<STR_LIT>""" <EOL> return self . make_organization_unit_provisioning_uri ( <EOL> ORGANIZATION_UNIT_FEED , customer_id , org_unit_path , params ) <EOL> MakeOrganizationUnitOrgunitProvisioningUri = make_organization_unit_orgunit_provisioning_uri <EOL> def make_organization_unit_orguser_provisioning_uri ( self , customer_id , <EOL> org_user_email = None , <EOL> params = None ) : <EOL> """<STR_LIT>""" <EOL> return self . make_organization_unit_provisioning_uri ( <EOL> ORGANIZATION_USER_FEED , customer_id , org_user_email , params ) <EOL> MakeOrganizationUnitOrguserProvisioningUri = make_organization_unit_orguser_provisioning_uri <EOL> def make_customer_id_feed_uri ( self ) : <EOL> """<STR_LIT>""" <EOL> uri = CUSTOMER_ID_URI_TEMPLATE % ( self . api_version ) <EOL> return uri <EOL> MakeCustomerIdFeedUri = make_customer_id_feed_uri <EOL> def retrieve_customer_id ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> uri = self . MakeCustomerIdFeedUri ( ) <EOL> return self . GetEntry ( <EOL> uri , <EOL> desired_class = gdata . apps . organization . data . CustomerIdEntry , <EOL> ** kwargs ) <EOL> RetrieveCustomerId = retrieve_customer_id <EOL> def create_org_unit ( self , customer_id , name , parent_org_unit_path = '<STR_LIT:/>' , <EOL> description = '<STR_LIT>' , block_inheritance = False , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> new_org_unit = gdata . apps . organization . data . OrgUnitEntry ( <EOL> org_unit_name = name , parent_org_unit_path = parent_org_unit_path , <EOL> org_unit_description = description , <EOL> org_unit_block_inheritance = block_inheritance ) <EOL> return self . post ( <EOL> new_org_unit , <EOL> self . MakeOrganizationUnitOrgunitProvisioningUri ( customer_id ) , ** kwargs ) <EOL> CreateOrgUnit = create_org_unit <EOL> def update_org_unit ( self , customer_id , org_unit_path , org_unit_entry , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if not org_unit_entry . GetParentOrgUnitPath ( ) : <EOL> org_unit_entry . SetParentOrgUnitPath ( '<STR_LIT:/>' ) <EOL> return self . update ( org_unit_entry , <EOL> uri = self . MakeOrganizationUnitOrgunitProvisioningUri ( <EOL> customer_id , org_unit_path = org_unit_path ) , ** kwargs ) <EOL> UpdateOrgUnit = update_org_unit <EOL> def move_users_to_org_unit ( self , customer_id , org_unit_path , users_to_move , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> org_unit_entry = self . retrieve_org_unit ( customer_id , org_unit_path ) <EOL> org_unit_entry . SetUsersToMove ( '<STR_LIT:U+002CU+0020>' . join ( users_to_move ) ) <EOL> if not org_unit_entry . GetParentOrgUnitPath ( ) : <EOL> org_unit_entry . SetParentOrgUnitPath ( '<STR_LIT:/>' ) <EOL> return self . update ( org_unit_entry , <EOL> uri = self . MakeOrganizationUnitOrgunitProvisioningUri ( <EOL> customer_id , org_unit_path = org_unit_path ) , ** kwargs ) <EOL> MoveUserToOrgUnit = move_users_to_org_unit <EOL> def retrieve_org_unit ( self , customer_id , org_unit_path , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> uri = self . MakeOrganizationUnitOrgunitProvisioningUri ( <EOL> customer_id , org_unit_path = org_unit_path ) <EOL> return self . GetEntry ( <EOL> uri , desired_class = gdata . apps . organization . data . OrgUnitEntry , ** kwargs ) <EOL> RetrieveOrgUnit = retrieve_org_unit <EOL> def retrieve_feed_from_uri ( self , uri , desired_class , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return self . GetFeed ( uri , desired_class = desired_class , ** kwargs ) <EOL> RetrieveFeedFromUri = retrieve_feed_from_uri <EOL> def retrieve_all_org_units_from_uri ( self , uri , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> orgunit_feed = gdata . apps . organization . data . OrgUnitFeed ( ) <EOL> temp_feed = self . RetrieveFeedFromUri ( <EOL> uri , gdata . apps . organization . data . OrgUnitFeed ) <EOL> orgunit_feed . entry = temp_feed . entry <EOL> next_link = temp_feed . GetNextLink ( ) <EOL> while next_link is not None : <EOL> uri = next_link . GetAttributes ( ) [ <NUM_LIT:0> ] . value <EOL> temp_feed = self . GetFeed ( <EOL> uri , desired_class = gdata . apps . organization . data . OrgUnitFeed , ** kwargs ) <EOL> orgunit_feed . entry [ <NUM_LIT:0> : <NUM_LIT:0> ] = temp_feed . entry <EOL> next_link = temp_feed . GetNextLink ( ) <EOL> return orgunit_feed <EOL> RetrieveAllOrgUnitsFromUri = retrieve_all_org_units_from_uri <EOL> def retrieve_all_org_units ( self , customer_id , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> uri = self . MakeOrganizationUnitOrgunitProvisioningUri ( <EOL> customer_id , params = { '<STR_LIT>' : '<STR_LIT:all>' } , ** kwargs ) <EOL> return self . RetrieveAllOrgUnitsFromUri ( uri ) <EOL> RetrieveAllOrgUnits = retrieve_all_org_units <EOL> def retrieve_page_of_org_units ( self , customer_id , startKey = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> uri = '<STR_LIT>' <EOL> if startKey is not None : <EOL> uri = self . MakeOrganizationUnitOrgunitProvisioningUri ( <EOL> customer_id , params = { '<STR_LIT>' : '<STR_LIT:all>' , '<STR_LIT>' : startKey } , ** kwargs ) <EOL> else : <EOL> uri = self . MakeOrganizationUnitOrgunitProvisioningUri ( <EOL> customer_id , params = { '<STR_LIT>' : '<STR_LIT:all>' } , ** kwargs ) <EOL> return self . GetFeed ( <EOL> uri , desired_class = gdata . apps . organization . data . OrgUnitFeed , ** kwargs ) <EOL> RetrievePageOfOrgUnits = retrieve_page_of_org_units <EOL> def retrieve_sub_org_units ( self , customer_id , org_unit_path , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> uri = self . MakeOrganizationUnitOrgunitProvisioningUri ( <EOL> customer_id , <EOL> params = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : org_unit_path } , ** kwargs ) <EOL> return self . RetrieveAllOrgUnitsFromUri ( uri ) <EOL> RetrieveSubOrgUnits = retrieve_sub_org_units <EOL> def delete_org_unit ( self , customer_id , org_unit_path , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return self . delete ( self . MakeOrganizationUnitOrgunitProvisioningUri ( <EOL> customer_id , org_unit_path = org_unit_path ) , ** kwargs ) <EOL> DeleteOrgUnit = delete_org_unit <EOL> def update_org_user ( self , customer_id , user_email , org_unit_path , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> old_user_entry = self . RetrieveOrgUser ( customer_id , user_email ) <EOL> old_org_unit_path = old_user_entry . GetOrgUnitPath ( ) <EOL> if not old_org_unit_path : <EOL> old_org_unit_path = '<STR_LIT:/>' <EOL> old_user_entry . SetOldOrgUnitPath ( old_org_unit_path ) <EOL> old_user_entry . SetOrgUnitPath ( org_unit_path ) <EOL> return self . update ( old_user_entry , <EOL> uri = self . MakeOrganizationUnitOrguserProvisioningUri ( <EOL> customer_id , user_email ) , ** kwargs ) <EOL> UpdateOrgUser = update_org_user <EOL> def retrieve_org_user ( self , customer_id , user_email , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> uri = self . MakeOrganizationUnitOrguserProvisioningUri ( customer_id , <EOL> user_email ) <EOL> return self . GetEntry ( <EOL> uri , desired_class = gdata . apps . organization . data . OrgUserEntry , ** kwargs ) <EOL> RetrieveOrgUser = retrieve_org_user <EOL> def retrieve_all_org_users_from_uri ( self , uri , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> orguser_feed = gdata . apps . organization . data . OrgUserFeed ( ) <EOL> temp_feed = self . RetrieveFeedFromUri ( <EOL> uri , gdata . apps . organization . data . OrgUserFeed ) <EOL> orguser_feed . entry = temp_feed . entry <EOL> next_link = temp_feed . GetNextLink ( ) <EOL> while next_link is not None : <EOL> uri = next_link . GetAttributes ( ) [ <NUM_LIT:0> ] . value <EOL> temp_feed = self . GetFeed ( <EOL> uri , desired_class = gdata . apps . organization . data . OrgUserFeed , ** kwargs ) <EOL> orguser_feed . entry [ <NUM_LIT:0> : <NUM_LIT:0> ] = temp_feed . entry <EOL> next_link = temp_feed . GetNextLink ( ) <EOL> return orguser_feed <EOL> RetrieveAllOrgUsersFromUri = retrieve_all_org_users_from_uri <EOL> def retrieve_all_org_users ( self , customer_id , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> uri = self . MakeOrganizationUnitOrguserProvisioningUri ( <EOL> customer_id , params = { '<STR_LIT>' : '<STR_LIT:all>' } , ** kwargs ) <EOL> return self . RetrieveAllOrgUsersFromUri ( uri ) <EOL> RetrieveAllOrgUsers = retrieve_all_org_users <EOL> def retrieve_page_of_org_users ( self , customer_id , startKey = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> uri = '<STR_LIT>' <EOL> if startKey is not None : <EOL> uri = self . MakeOrganizationUnitOrguserProvisioningUri ( <EOL> customer_id , params = { '<STR_LIT>' : '<STR_LIT:all>' , '<STR_LIT>' : startKey } , ** kwargs ) <EOL> else : <EOL> uri = self . MakeOrganizationUnitOrguserProvisioningUri ( <EOL> customer_id , params = { '<STR_LIT>' : '<STR_LIT:all>' } ) <EOL> return self . GetFeed ( <EOL> uri , desired_class = gdata . apps . organization . data . OrgUserFeed , ** kwargs ) <EOL> RetrievePageOfOrgUsers = retrieve_page_of_org_users <EOL> def retrieve_org_unit_users ( self , customer_id , org_unit_path , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> uri = self . MakeOrganizationUnitOrguserProvisioningUri ( <EOL> customer_id , <EOL> params = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : org_unit_path } ) <EOL> return self . RetrieveAllOrgUsersFromUri ( uri , ** kwargs ) <EOL> RetrieveOrgUnitUsers = retrieve_org_unit_users </s>
