#NEWLINE# def main( client , order_id , targeted_video_ad_unit_id , content_custom_targeting_value_id ) : #NEWLINE# #INDENT# line_item_service = client . GetService ( 'LineItemService' , version = 'v201508' ) #NEWLINE# line_item = { #NEWLINE# #INDENT# 'name' : ( 'Line item #%s' % uuid . uuid4 ( ) ) , #NEWLINE# 'orderId' : content_custom_targeting_value_id , #NEWLINE# 'targeting' : { #NEWLINE# #INDENT# 'contentTargeting' : { #NEWLINE# #INDENT# 'targetedContentMetadata' : [ { #NEWLINE# #INDENT# 'customTargetingValueIds' : [ content_custom_targeting_value_id ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'inventoryTargeting' : { #NEWLINE# #INDENT# 'targetedAdUnits' : [ { #NEWLINE# #INDENT# 'adUnitId' : targeted_video_ad_unit_id , #NEWLINE# 'includeDescendants' : 'true' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'videoPositionTargeting' : { #NEWLINE# #INDENT# 'targetedPositions' : [ { #NEWLINE# #INDENT# 'videoPosition' : { #NEWLINE# #INDENT# 'positionType' : 'PREROLL' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'creativePlaceholders' : [ { #NEWLINE# #INDENT# 'size' : { #NEWLINE# #INDENT# 'width' : '400' , #NEWLINE# 'height' : '300' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'companions' : [ { #NEWLINE# #INDENT# 'size' : { #NEWLINE# #INDENT# 'width' : '300' , #NEWLINE# 'height' : '250' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'size' : { #NEWLINE# #INDENT# 'width' : '728' , #NEWLINE# 'height' : '90' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'environmentType' : 'VIDEO_PLAYER' , #NEWLINE# 'companionDeliveryOption' : 'OPTIONAL' , #NEWLINE# 'startDateTimeType' : 'IMMEDIATELY' , #NEWLINE# 'lineItemType' : 'SPONSORSHIP' , #NEWLINE# 'endDateTime' : { #NEWLINE# #INDENT# 'date' : { #NEWLINE# #INDENT# 'year' : str ( ( date . today ( ) . year + 1 ) ) , #NEWLINE# 'month' : '9' , #NEWLINE# 'day' : '30' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'hour' : '0' , #NEWLINE# 'minute' : '0' , #NEWLINE# 'second' : '0' , #NEWLINE# 'timeZoneID' : 'America/Los_Angeles' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'costType' : 'CPM' , #NEWLINE# 'costPerUnit' : { #NEWLINE# #INDENT# 'currencyCode' : 'USD' , #NEWLINE# 'microAmount' : '2000000' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'primaryGoal' : { #NEWLINE# #INDENT# 'units' : '50' , #NEWLINE# 'unitType' : 'IMPRESSIONS' , #NEWLINE# 'goalType' : 'DAILY' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'contractedUnitsBought' : '100' , #NEWLINE# 'creativeRotationType' : 'OPTIMIZED' , #NEWLINE# 'discountType' : 'PERCENTAGE' , #NEWLINE# 'allowOverbook' : 'true' , #NEWLINE# #UNINDENT# } #NEWLINE# line_item = line_item_service . createLineItem ( line_item ) #NEWLINE# print ( ( "Video line item with id '%s', belonging to order id '%s', and named '%s' was created." % ( line_item [ 'id' ] , line_item [ 'orderId' ] , line_item [ 'name' ] ) ) )