client = Client(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN,
                ACCESS_TOKEN_SECRET)

account = client.accounts(ADS_ACCOUNT)

video = Video(account)
video.video_media_id = media_id  # from previous step
video.description = "My sample videos"
video.title = "Video tutorial test"
video.save()

#grab the video_id from the response
video_id = video.id
print video_id

account_media = AccountMedia(account)
account_media.video_id = video_id
account_media.creative_type = CREATIVE_TYPE.PREROLL
account_media.save()

# create a campaign
campaign = Campaign(account)
campaign.name = "Video tutorial test"
# get the first funding instrument on the account
campaign.funding_instrument_id = account.funding_instruments().first.id
campaign.daily_budget_amount_local_micro = 1000000000
campaign.entity_status = ENTITY_STATUS.PAUSED
campaign.start_time = datetime.utcnow()
campaign.save()

# create a line item with the VIDEO_VIEWS_PREROLL
                ACCESS_TOKEN_SECRET)

# load the advertiser account instance
account = client.accounts(ACCOUNT_ID)

# grab the first line_item on the account
line_item_id = account.line_items().first.id

# retrive the `id` of the media creative associated with a line item
print(account.media_creatives().first.id)

# retrieve the `id` of the first account media associated with the account
account_media_id = account.account_media().first.id

# create a new account media
account_media = AccountMedia(account)
account_media.media_id = 'your-media-id'
# OR account_media.video_id OR account_media.vast_url
# see the media_upload.py example for more details
account_media.creative_type = CREATIVE_TYPE.BANNER
account_media.save()

#create a new media creative
media_creative = MediaCreative(account)
media_creative.line_item_id = line_item_id
media_creative.account_media_id = account_media_id
media_creative.landing_url = "https://my-landing-url"
media_creative.save()

# delete the media creative
media_creative.delete()
client = Client(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

# load the advertiser account instance
account = client.accounts(ACCOUNT_ID)

# grab the first line_item on the account
line_item_id = account.line_items().first.id

# retrive the `id` of the media creative associated with a line item
print account.media_creatives().first.id

# retrieve the `id` of the first account media associated with the account
account_media_id = account.account_media().first.id

# create a new account media
account_media = AccountMedia(account)
account_media.media_id = "your-media-id"
# OR account_media.video_id OR account_media.vast_url
# see the media_upload.py example for more details
account_media.creative_type = CREATIVE_TYPE.BANNER
account_media.save()


# create a new media creative
media_creative = MediaCreative(account)
media_creative.line_item_id = line_item_id
media_creative.account_media_id = account_media_id
media_creative.landing_url = "https://my-landing-url"
media_creative.save()

# delete the media creative
client = Client(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

account = client.accounts(ADS_ACCOUNT)

video = Video(account)
video.video_media_id = media_id  # from previous step
video.description = "My sample videos"
video.title = "Video tutorial test"
video.save()

# grab the video_id from the response
video_id = video.id
print video_id

account_media = AccountMedia(account)
account_media.video_id = video_id
account_media.creative_type = CREATIVE_TYPE.PREROLL
account_media.save()

# create a campaign
campaign = Campaign(account)
campaign.name = "Video tutorial test"
# get the first funding instrument on the account
campaign.funding_instrument_id = account.funding_instruments().first.id
campaign.daily_budget_amount_local_micro = 1000000000
campaign.paused = True
campaign.start_time = datetime.utcnow()
campaign.save()

# create a line item with the VIDEO_VIEWS_PREROLL