#NEWLINE# def main( client , adgroup_id ) : #NEWLINE# #INDENT# 'Runs the example.' #NEWLINE# adgroup_criterion_service = client . GetService ( 'AdGroupCriterionService' , version = 'v201601' ) #NEWLINE# helper = ProductPartitionHelper ( adgroup_id ) #NEWLINE# root = helper . CreateSubdivision ( ) #NEWLINE# new_product_canonical_condition = { #NEWLINE# #INDENT# 'xsi_type' : 'ProductCanonicalCondition' , #NEWLINE# 'condition' : 'NEW' , #NEWLINE# #UNINDENT# } #NEWLINE# used_product_canonical_condition = { #NEWLINE# #INDENT# 'xsi_type' : 'ProductCanonicalCondition' , #NEWLINE# 'condition' : 'USED' , #NEWLINE# #UNINDENT# } #NEWLINE# other_product_canonical_condition = { #NEWLINE# #INDENT# 'xsi_type' : 'ProductCanonicalCondition' , #NEWLINE# #UNINDENT# } #NEWLINE# helper . CreateUnit ( root , new_product_canonical_condition , 200000 ) #NEWLINE# helper . CreateUnit ( root , used_product_canonical_condition , 100000 ) #NEWLINE# other_condition = helper . CreateSubdivision ( root , other_product_canonical_condition ) #NEWLINE# cool_product_brand = { #NEWLINE# #INDENT# 'xsi_type' : 'ProductBrand' , #NEWLINE# 'value' : 'CoolBrand' , #NEWLINE# #UNINDENT# } #NEWLINE# cheap_product_brand = { #NEWLINE# #INDENT# 'xsi_type' : 'ProductBrand' , #NEWLINE# 'value' : 'CheapBrand' , #NEWLINE# #UNINDENT# } #NEWLINE# other_product_brand = { #NEWLINE# #INDENT# 'xsi_type' : 'ProductBrand' , #NEWLINE# #UNINDENT# } #NEWLINE# helper . CreateUnit ( other_condition , cool_product_brand , 900000 ) #NEWLINE# helper . CreateUnit ( other_condition , cheap_product_brand , 10000 ) #NEWLINE# other_brand = helper . CreateSubdivision ( other_condition , other_product_brand ) #NEWLINE# luggage_category = { #NEWLINE# #INDENT# 'xsi_type' : 'ProductBiddingCategory' , #NEWLINE# 'type' : 'BIDDING_CATEGORY_L1' , #NEWLINE# 'value' : '-5914235892932915235' , #NEWLINE# #UNINDENT# } #NEWLINE# generic_category = { #NEWLINE# #INDENT# 'xsi_type' : 'ProductBiddingCategory' , #NEWLINE# 'type' : 'BIDDING_CATEGORY_L1' , #NEWLINE# #UNINDENT# } #NEWLINE# helper . CreateUnit ( other_brand , luggage_category , 750000 ) #NEWLINE# helper . CreateUnit ( other_brand , generic_category , 110000 ) #NEWLINE# result = adgroup_criterion_service . mutate ( helper . GetOperations ( ) ) #NEWLINE# children = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# root_node = None #NEWLINE# for adgroup_criterion in result [ 'value' ] : #NEWLINE# #INDENT# children [ adgroup_criterion [ 'criterion' ] [ 'id' ] ] = [ ] #NEWLINE# if ( 'parentCriterionId' in adgroup_criterion [ 'criterion' ] ) : #NEWLINE# #INDENT# children [ adgroup_criterion [ 'criterion' ] [ 'parentCriterionId' ] ] . append ( adgroup_criterion [ 'criterion' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# root_node = adgroup_criterion [ 'criterion' ] #NEWLINE# #UNINDENT# #UNINDENT# DisplayTree ( root_node , result )